Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
BaseCorrelationTermStructure Class Reference

#include <qle/termstructures/credit/basecorrelationstructure.hpp>

+ Inheritance diagram for BaseCorrelationTermStructure:
+ Collaboration diagram for BaseCorrelationTermStructure:

Public Member Functions

 BaseCorrelationTermStructure ()
 
 BaseCorrelationTermStructure (const Date &referenceDate, const Calendar &cal, BusinessDayConvention bdc, const std::vector< Period > &tenors, const std::vector< double > &detachmentPoints, const DayCounter &dc=DayCounter(), const Date &startDate=Date(), boost::optional< DateGeneration::Rule > rule=boost::none)
 
 BaseCorrelationTermStructure (Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const std::vector< Period > &tenors, const std::vector< double > &detachmentPoints, const DayCounter &dc=DayCounter(), const Date &startDate=Date(), boost::optional< DateGeneration::Rule > rule=boost::none)
 
virtual ~BaseCorrelationTermStructure ()=default
 
virtual Date maxDate () const override
 
virtual Time maxTime () const override
 
virtual Time minTime () const override
 The minimum time for which the curve can return values. More...
 
virtual double minDetachmentPoint () const
 
virtual double maxDetachmentPoint () const
 
std::vector< double > times () const
 
std::vector< double > detachmentPoints () const
 
std::vector< Date > dates () const
 
BusinessDayConvention businessDayConvention () const
 
Date startDate () const
 
boost::optional< DateGeneration::Rule > rule () const
 
- Public Member Functions inherited from CorrelationTermStructure
 CorrelationTermStructure (const DayCounter &dc=DayCounter())
 
 CorrelationTermStructure (const Date &referenceDate, const Calendar &cal=Calendar(), const DayCounter &dc=DayCounter())
 
 CorrelationTermStructure (Natural settlementDays, const Calendar &cal, const DayCounter &dc=DayCounter())
 
Real correlation (Time t, Real strike=Null< Real >(), bool extrapolate=false) const
 
Real correlation (const Date &d, Real strike=Null< Real >(), bool extrapolate=false) const
 

Protected Member Functions

virtual void checkRange (Time t, Real strike, bool extrapolate) const override
 Extra time range check for minimum time, then calls TermStructure::checkRange. More...
 
- Protected Member Functions inherited from CorrelationTermStructure
virtual Real correlationImpl (Time t, Real strike) const =0
 Correlation calculation. More...
 

Protected Attributes

std::vector< Period > tenors_
 
std::vector< double > detachmentPoints_
 
std::vector< Date > dates_
 
std::vector< double > times_
 

Private Member Functions

void validate () const
 
void initializeDatesAndTimes () const
 

Private Attributes

BusinessDayConvention bdc_
 
Date startDate_
 
boost::optional< DateGeneration::Rule > rule_
 

Detailed Description

Definition at line 37 of file basecorrelationstructure.hpp.

Constructor & Destructor Documentation

◆ BaseCorrelationTermStructure() [1/3]

Definition at line 23 of file basecorrelationstructure.cpp.

24 : CorrelationTermStructure(), bdc_(Unadjusted) {}
CorrelationTermStructure(const DayCounter &dc=DayCounter())

◆ BaseCorrelationTermStructure() [2/3]

BaseCorrelationTermStructure ( const Date &  referenceDate,
const Calendar &  cal,
BusinessDayConvention  bdc,
const std::vector< Period > &  tenors,
const std::vector< double > &  detachmentPoints,
const DayCounter &  dc = DayCounter(),
const Date &  startDate = Date(),
boost::optional< DateGeneration::Rule >  rule = boost::none 
)

◆ BaseCorrelationTermStructure() [3/3]

BaseCorrelationTermStructure ( Natural  settlementDays,
const Calendar &  cal,
BusinessDayConvention  bdc,
const std::vector< Period > &  tenors,
const std::vector< double > &  detachmentPoints,
const DayCounter &  dc = DayCounter(),
const Date &  startDate = Date(),
boost::optional< DateGeneration::Rule >  rule = boost::none 
)

◆ ~BaseCorrelationTermStructure()

virtual ~BaseCorrelationTermStructure ( )
virtualdefault

Member Function Documentation

◆ maxDate()

virtual Date maxDate ( ) const
overridevirtual

Reimplemented in SpreadedBaseCorrelationCurve.

Definition at line 54 of file basecorrelationstructure.hpp.

54{ return dates_.back(); }

◆ maxTime()

virtual Time maxTime ( ) const
overridevirtual

Reimplemented in SpreadedBaseCorrelationCurve.

Definition at line 56 of file basecorrelationstructure.hpp.

56{ return times_.back(); }
+ Here is the caller graph for this function:

◆ minTime()

virtual Time minTime ( ) const
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from CorrelationTermStructure.

Reimplemented in SpreadedBaseCorrelationCurve.

Definition at line 57 of file basecorrelationstructure.hpp.

57{ return times_.front(); }
+ Here is the caller graph for this function:

◆ minDetachmentPoint()

virtual double minDetachmentPoint ( ) const
virtual

Reimplemented in SpreadedBaseCorrelationCurve.

Definition at line 59 of file basecorrelationstructure.hpp.

59{ return detachmentPoints_.front(); }
+ Here is the caller graph for this function:

◆ maxDetachmentPoint()

virtual double maxDetachmentPoint ( ) const
virtual

Reimplemented in SpreadedBaseCorrelationCurve.

Definition at line 60 of file basecorrelationstructure.hpp.

60{ return detachmentPoints_.back(); }
+ Here is the caller graph for this function:

◆ times()

std::vector< double > times ( ) const

Definition at line 62 of file basecorrelationstructure.hpp.

62{ return times_; }

◆ detachmentPoints()

std::vector< double > detachmentPoints ( ) const

Definition at line 64 of file basecorrelationstructure.hpp.

64{ return detachmentPoints_; }

◆ dates()

std::vector< Date > dates ( ) const

Definition at line 66 of file basecorrelationstructure.hpp.

66{ return dates_; }

◆ businessDayConvention()

BusinessDayConvention businessDayConvention ( ) const

Definition at line 68 of file basecorrelationstructure.hpp.

68{ return bdc_; }

◆ startDate()

Date startDate ( ) const

Definition at line 70 of file basecorrelationstructure.hpp.

70{ return startDate_; }

◆ rule()

boost::optional< DateGeneration::Rule > rule ( ) const

Definition at line 72 of file basecorrelationstructure.hpp.

72{ return rule_; }

◆ validate()

void validate ( ) const
private

Definition at line 48 of file basecorrelationstructure.cpp.

48 {
49 Period prevTenor(0, Days);
50 for (size_t i = 0; i < tenors_.size(); ++i) {
51 QL_REQUIRE(tenors_[i] > prevTenor, "Tenors need to be sorted and larger than 0 * Days");
52 }
53
54 // Ensure detachmentpoints are sorted and between 0.0 and 1.0
55 double prevDetachmentPoint = 0.0;
56 for (size_t i = 0; i < detachmentPoints_.size(); ++i) {
57 QL_REQUIRE(detachmentPoints_[i] > prevDetachmentPoint,
58 "Detachmentpoints need to be sorted and between (0, 1].");
59 QL_REQUIRE(detachmentPoints_[i] < 1.0 || QuantLib::close_enough(detachmentPoints_[i], 1.0),
60 "Detachmentpoints need to be sorted and between (0, 1].");
61 }
62}
+ Here is the caller graph for this function:

◆ initializeDatesAndTimes()

void initializeDatesAndTimes ( ) const
private

Definition at line 64 of file basecorrelationstructure.cpp.

64 {
65 const Date& refDate = referenceDate();
66 Date start = startDate_ == Date() ? refDate : startDate_;
67 Calendar cldr = calendar();
68
69 for (Size i = 0; i < tenors_.size(); i++) {
70 Date d;
71 if (rule_) {
72 d = start + tenors_[i];
73 if (*rule_ == DateGeneration::CDS2015 || *rule_ == DateGeneration::CDS ||
74 *rule_ == DateGeneration::OldCDS) {
75 d = cdsMaturity(start, tenors_[i], *rule_);
76 }
77 } else {
78 d = cldr.advance(start, tenors_[i], bdc_);
79 }
80
81 dates_.push_back(d);
82 times_.push_back(timeFromReference(d));
83
84 QL_REQUIRE(!dates_.empty(), "no dates left after removing expired dates");
85 }
86}
+ Here is the caller graph for this function:

◆ checkRange()

void checkRange ( Time  t,
Real  strike,
bool  extrapolate 
) const
overrideprotectedvirtual

Extra time range check for minimum time, then calls TermStructure::checkRange.

Reimplemented from CorrelationTermStructure.

Definition at line 88 of file basecorrelationstructure.cpp.

88 {
89 bool extrapolationNeeded =
90 t < minTime() || t > maxTime() || strike < minDetachmentPoint() || strike > maxDetachmentPoint();
91 QL_REQUIRE(extrapolate || allowsExtrapolation() || !extrapolationNeeded,
92 "No extrapolation allowed, require t = "
93 << t << " to be between (" << minTime() << ", " << maxTime() << ") and detachmentPoint = " << strike
94 << " to be between (" << minDetachmentPoint() << ", " << maxDetachmentPoint() << ").");
95}
virtual Time minTime() const override
The minimum time for which the curve can return values.
+ Here is the call graph for this function:

Member Data Documentation

◆ bdc_

BusinessDayConvention bdc_
private

Definition at line 75 of file basecorrelationstructure.hpp.

◆ startDate_

Date startDate_
private

Definition at line 76 of file basecorrelationstructure.hpp.

◆ rule_

boost::optional<DateGeneration::Rule> rule_
private

Definition at line 77 of file basecorrelationstructure.hpp.

◆ tenors_

std::vector<Period> tenors_
protected

Definition at line 86 of file basecorrelationstructure.hpp.

◆ detachmentPoints_

std::vector<double> detachmentPoints_
protected

Definition at line 87 of file basecorrelationstructure.hpp.

◆ dates_

std::vector<Date> dates_
mutableprotected

Definition at line 88 of file basecorrelationstructure.hpp.

◆ times_

std::vector<double> times_
mutableprotected

Definition at line 89 of file basecorrelationstructure.hpp.