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

Spreaded Base Correlation Curve. More...

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

+ Inheritance diagram for SpreadedBaseCorrelationCurve:
+ Collaboration diagram for SpreadedBaseCorrelationCurve:

Public Member Functions

 SpreadedBaseCorrelationCurve (const Handle< BaseCorrelationTermStructure > &baseCurve, const std::vector< Period > &tenors, const std::vector< double > &detachmentPoints, const std::vector< std::vector< Handle< Quote > > > &corrSpreads, const Date &startDate=Date(), boost::optional< DateGeneration::Rule > rule=boost::none)
 
void update () override
 
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 override
 
virtual double maxDetachmentPoint () const override
 
- Public Member Functions inherited from BaseCorrelationTermStructure
 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
 

Private Member Functions

Real correlationImpl (Time t, Real strike) const override
 Correlation calculation. More...
 
void performCalculations () const override
 

Private Attributes

Handle< BaseCorrelationTermStructurebaseCurve_
 
std::vector< std::vector< Handle< Quote > > > corrSpreads_
 
Matrix data_
 
Interpolation2D interpolation_
 

Additional Inherited Members

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

This method must be implemented in derived classes to perform the actual calculations.

- Protected Attributes inherited from BaseCorrelationTermStructure
std::vector< Period > tenors_
 
std::vector< double > detachmentPoints_
 
std::vector< Date > dates_
 
std::vector< double > times_
 

Detailed Description

Spreaded Base Correlation Curve.

Definition at line 33 of file spreadedbasecorrelationcurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedBaseCorrelationCurve()

SpreadedBaseCorrelationCurve ( const Handle< BaseCorrelationTermStructure > &  baseCurve,
const std::vector< Period > &  tenors,
const std::vector< double > &  detachmentPoints,
const std::vector< std::vector< Handle< Quote > > > &  corrSpreads,
const Date &  startDate = Date(),
boost::optional< DateGeneration::Rule >  rule = boost::none 
)

Definition at line 26 of file spreadedbasecorrelationcurve.cpp.

32 : BaseCorrelationTermStructure(baseCurve->settlementDays(), baseCurve->calendar(),
33 baseCurve->businessDayConvention(), tenors, detachmentPoints,
34 baseCurve->dayCounter(), startDate, rule),
35 baseCurve_(baseCurve), corrSpreads_(corrSpreads), data_(detachmentPoints_.size(), tenors.size(), 0.0) {
36 // Check times and detachment points
37
38 QL_REQUIRE(!times_.empty(), "SpreadedCorrelationCurve: time points are empty");
39 QL_REQUIRE(!detachmentPoints_.empty(), "SpreadedBaseCorrelationCurve: detachmentPoints are empty");
40
41 QL_REQUIRE(corrSpreads_.size() == detachmentPoints_.size(), "Mismatch between tenors and correlation quotes");
42 for (const auto& row : this->corrSpreads_) {
43 QL_REQUIRE(row.size() == tenors_.size(), "Mismatch between number of detachment points and quotes");
44 }
45
46 for (auto const& row : corrSpreads_)
47 for (auto const& q : row)
48 registerWith(q);
49
50 interpolation_ = BilinearFlat().interpolate(times_.begin(), times_.end(), detachmentPoints_.begin(),
52 interpolation_.enableExtrapolation();
53 registerWith(baseCurve_);
54}
std::vector< double > detachmentPoints() const
boost::optional< DateGeneration::Rule > rule() const
std::vector< std::vector< Handle< Quote > > > corrSpreads_
Handle< BaseCorrelationTermStructure > baseCurve_
+ Here is the call graph for this function:

Member Function Documentation

◆ update()

void update ( )
override

Definition at line 56 of file spreadedbasecorrelationcurve.cpp.

56 {
57 LazyObject::update();
58 BaseCorrelationTermStructure::update();
59}

◆ maxDate()

virtual Date maxDate ( ) const
overridevirtual

Reimplemented from BaseCorrelationTermStructure.

Definition at line 44 of file spreadedbasecorrelationcurve.hpp.

44{ return baseCurve_->maxDate(); }

◆ maxTime()

virtual Time maxTime ( ) const
overridevirtual

Reimplemented from BaseCorrelationTermStructure.

Definition at line 46 of file spreadedbasecorrelationcurve.hpp.

46{ return baseCurve_->maxTime(); }

◆ minTime()

virtual Time minTime ( ) const
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from BaseCorrelationTermStructure.

Definition at line 47 of file spreadedbasecorrelationcurve.hpp.

47{ return baseCurve_->minTime(); }

◆ minDetachmentPoint()

virtual double minDetachmentPoint ( ) const
overridevirtual

Reimplemented from BaseCorrelationTermStructure.

Definition at line 49 of file spreadedbasecorrelationcurve.hpp.

49{ return baseCurve_->minDetachmentPoint(); }

◆ maxDetachmentPoint()

virtual double maxDetachmentPoint ( ) const
overridevirtual

Reimplemented from BaseCorrelationTermStructure.

Definition at line 50 of file spreadedbasecorrelationcurve.hpp.

50{ return baseCurve_->maxDetachmentPoint(); }

◆ correlationImpl()

Real correlationImpl ( Time  t,
Real  strike 
) const
overrideprivatevirtual

Correlation calculation.

Implements CorrelationTermStructure.

Definition at line 61 of file spreadedbasecorrelationcurve.cpp.

61 {
62 calculate();
63 return std::min(
64 1.0 - QL_EPSILON,
65 std::max(baseCurve_->correlation(t, detachmentPoint) + interpolation_(t, detachmentPoint), QL_EPSILON));
66}

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 68 of file spreadedbasecorrelationcurve.cpp.

68 {
69 for (Size i = 0; i < this->detachmentPoints_.size(); ++i)
70 for (Size j = 0; j < this->times_.size(); ++j)
71 this->data_[i][j] = corrSpreads_[i][j]->value();
72 interpolation_.update();
73}

Member Data Documentation

◆ baseCurve_

Handle<BaseCorrelationTermStructure> baseCurve_
private

Definition at line 55 of file spreadedbasecorrelationcurve.hpp.

◆ corrSpreads_

std::vector<std::vector<Handle<Quote> > > corrSpreads_
private

Definition at line 56 of file spreadedbasecorrelationcurve.hpp.

◆ data_

Matrix data_
mutableprivate

Definition at line 57 of file spreadedbasecorrelationcurve.hpp.

◆ interpolation_

Interpolation2D interpolation_
mutableprivate

Definition at line 58 of file spreadedbasecorrelationcurve.hpp.