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
SpreadedCorrelationCurve Class Reference

Spreaded Correlation Curve. More...

#include <qle/termstructures/spreadedcorrelationcurve.hpp>

+ Inheritance diagram for SpreadedCorrelationCurve:
+ Collaboration diagram for SpreadedCorrelationCurve:

Public Member Functions

 SpreadedCorrelationCurve (const Handle< CorrelationTermStructure > &referenceCorrelation, const std::vector< Time > &times, const std::vector< Handle< Quote > > &corrSpreads, const bool useAtmReferenceVolsOnly=false)
 
Date maxDate () const override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
Time minTime () const override
 The minimum time for which the curve can return values. More...
 
void update () override
 
- 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< CorrelationTermStructurereferenceCorrelation_
 
std::vector< Time > times_
 
std::vector< Handle< Quote > > corrSpreads_
 
bool useAtmReferenceCorrsOnly_
 
std::vector< Real > data_
 
QuantLib::ext::shared_ptr< Interpolation > interpolation_
 

Additional Inherited Members

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

Detailed Description

Spreaded Correlation Curve.

Definition at line 34 of file spreadedcorrelationcurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedCorrelationCurve()

SpreadedCorrelationCurve ( const Handle< CorrelationTermStructure > &  referenceCorrelation,
const std::vector< Time > &  times,
const std::vector< Handle< Quote > > &  corrSpreads,
const bool  useAtmReferenceVolsOnly = false 
)
  • times should be consistent with reference ts day counter
  • if useAtmReferenceCorrsOnly, only corrs with strike Null<Real>() are read from the referenceVol, otherwise the full reference vol surface (if it is one) is used

Definition at line 26 of file spreadedcorrelationcurve.cpp.

30 : CorrelationTermStructure(referenceCorrelation->dayCounter()), referenceCorrelation_(referenceCorrelation),
31 times_(times), corrSpreads_(corrSpreads), useAtmReferenceCorrsOnly_(useAtmReferenceCorrsOnly) {
32 QL_REQUIRE(!times_.empty(), "SpreadedCorrelationCurve: times are empty");
33 QL_REQUIRE(times_.size() == corrSpreads_.size(),
34 "SpreadedCorrelationCurve: size of times and quote vectors do not match");
35 if (times.size() == 1) {
36 times_.push_back(times_.back() + 1.0);
37 corrSpreads_.push_back(corrSpreads_.back());
38 }
39 data_.resize(times_.size(), 1.0);
40 for (auto const& q : corrSpreads_)
41 registerWith(q);
42 interpolation_ = QuantLib::ext::make_shared<FlatExtrapolation>(
43 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), data_.begin()));
44 interpolation_->enableExtrapolation();
45 registerWith(referenceCorrelation_);
46}
CorrelationTermStructure(const DayCounter &dc=DayCounter())
QuantLib::ext::shared_ptr< Interpolation > interpolation_
Handle< CorrelationTermStructure > referenceCorrelation_
std::vector< Handle< Quote > > corrSpreads_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 48 of file spreadedcorrelationcurve.cpp.

48{ return referenceCorrelation_->maxDate(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 49 of file spreadedcorrelationcurve.cpp.

49{ return referenceCorrelation_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 50 of file spreadedcorrelationcurve.cpp.

50{ return referenceCorrelation_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 51 of file spreadedcorrelationcurve.cpp.

51{ return referenceCorrelation_->settlementDays(); }

◆ minTime()

Time minTime ( ) const
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from CorrelationTermStructure.

Definition at line 52 of file spreadedcorrelationcurve.cpp.

52{ return referenceCorrelation_->minTime(); }

◆ update()

void update ( )
override

Definition at line 54 of file spreadedcorrelationcurve.cpp.

54 {
55 LazyObject::update();
56 CorrelationTermStructure::update();
57}

◆ correlationImpl()

Real correlationImpl ( Time  t,
Real  strike 
) const
overrideprivatevirtual

Correlation calculation.

Implements CorrelationTermStructure.

Definition at line 59 of file spreadedcorrelationcurve.cpp.

59 {
60 calculate();
61 return referenceCorrelation_->correlation(t, useAtmReferenceCorrsOnly_ ? Null<Real>() : strike) +
62 (*interpolation_)(t);
63}

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 65 of file spreadedcorrelationcurve.cpp.

65 {
66 for (Size i = 0; i < times_.size(); ++i) {
67 QL_REQUIRE(!corrSpreads_[i].empty(), "SpreadedCorrelationCurve: quote at index " << i << " is empty");
68 data_[i] = corrSpreads_[i]->value();
69 }
70 interpolation_->update();
71}

Member Data Documentation

◆ referenceCorrelation_

Handle<CorrelationTermStructure> referenceCorrelation_
private

Definition at line 56 of file spreadedcorrelationcurve.hpp.

◆ times_

std::vector<Time> times_
private

Definition at line 57 of file spreadedcorrelationcurve.hpp.

◆ corrSpreads_

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

Definition at line 58 of file spreadedcorrelationcurve.hpp.

◆ useAtmReferenceCorrsOnly_

bool useAtmReferenceCorrsOnly_
private

Definition at line 59 of file spreadedcorrelationcurve.hpp.

◆ data_

std::vector<Real> data_
mutableprivate

Definition at line 60 of file spreadedcorrelationcurve.hpp.

◆ interpolation_

QuantLib::ext::shared_ptr<Interpolation> interpolation_
private

Definition at line 61 of file spreadedcorrelationcurve.hpp.