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

Spreaded Price term structure. More...

#include <qle/termstructures/spreadedpricetermstructure.hpp>

+ Inheritance diagram for SpreadedPriceTermStructure:
+ Collaboration diagram for SpreadedPriceTermStructure:

Public Member Functions

 SpreadedPriceTermStructure (const QuantLib::Handle< PriceTermStructure > &referenceCurve, const std::vector< QuantLib::Real > &times, const std::vector< QuantLib::Handle< QuantLib::Quote > > &priceSpreads)
 times should be consistent with reference curve day counter More...
 
QuantLib::Date maxDate () const override
 
void update () override
 
const QuantLib::Date & referenceDate () const override
 
QuantLib::Calendar calendar () const override
 
QuantLib::Natural settlementDays () const override
 
QuantLib::Time minTime () const override
 The minimum time for which the curve can return values. More...
 
const QuantLib::Currency & currency () const override
 The currency in which prices are expressed. More...
 
std::vector< QuantLib::Date > pillarDates () const override
 The pillar dates for the PriceTermStructure. More...
 
- Public Member Functions inherited from PriceTermStructure
 PriceTermStructure (const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 PriceTermStructure (const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal=QuantLib::Calendar(), const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 PriceTermStructure (QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
QuantLib::Real price (QuantLib::Time t, bool extrapolate=false) const
 
QuantLib::Real price (const QuantLib::Date &d, bool extrapolate=false) const
 
void update () override
 

Private Member Functions

void performCalculations () const override
 
QuantLib::Real priceImpl (QuantLib::Time) const override
 Price calculation. More...
 

Private Attributes

QuantLib::Handle< PriceTermStructurereferenceCurve_
 
std::vector< QuantLib::Real > times_
 
std::vector< QuantLib::Handle< QuantLib::Quote > > priceSpreads_
 
std::vector< QuantLib::Real > data_
 
QuantLib::ext::shared_ptr< QuantLib::Interpolation > interpolation_
 

Additional Inherited Members

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

Detailed Description

Spreaded Price term structure.

Definition at line 33 of file spreadedpricetermstructure.hpp.

Constructor & Destructor Documentation

◆ SpreadedPriceTermStructure()

SpreadedPriceTermStructure ( const QuantLib::Handle< PriceTermStructure > &  referenceCurve,
const std::vector< QuantLib::Real > &  times,
const std::vector< QuantLib::Handle< QuantLib::Quote > > &  priceSpreads 
)

times should be consistent with reference curve day counter

Definition at line 27 of file spreadedpricetermstructure.cpp.

30 : PriceTermStructure(referenceCurve->dayCounter()), referenceCurve_(referenceCurve), times_(times),
31 priceSpreads_(priceSpreads), data_(times.size()) {
32 QL_REQUIRE(times_.size() > 1, "SpreadedPriceTermStructure: at least two times required");
33 QL_REQUIRE(times_.size() == priceSpreads_.size(),
34 "SpreadedPriceTermStructure: size of time and quote vectors do not match");
35 QL_REQUIRE(times_[0] == 0.0, "SpreadedPriceTermStructure: first time must be 0, got " << times_[0]);
36 for (auto const& q : priceSpreads_)
37 registerWith(q);
38 interpolation_ = QuantLib::ext::make_shared<FlatExtrapolation>(
39 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), data_.begin()));
40 interpolation_->enableExtrapolation();
41 registerWith(referenceCurve_);
42}
PriceTermStructure(const QuantLib::DayCounter &dc=QuantLib::DayCounter())
QuantLib::ext::shared_ptr< QuantLib::Interpolation > interpolation_
std::vector< QuantLib::Handle< QuantLib::Quote > > priceSpreads_
QuantLib::Handle< PriceTermStructure > referenceCurve_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 44 of file spreadedpricetermstructure.cpp.

44{ return referenceCurve_->maxDate(); }

◆ update()

void update ( )
override

Definition at line 46 of file spreadedpricetermstructure.cpp.

46 {
47 LazyObject::update();
48 TermStructure::update();
49}

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 51 of file spreadedpricetermstructure.cpp.

51{ return referenceCurve_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 53 of file spreadedpricetermstructure.cpp.

53{ return referenceCurve_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 55 of file spreadedpricetermstructure.cpp.

55{ return referenceCurve_->settlementDays(); }

◆ minTime()

QuantLib::Time minTime ( ) const
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from PriceTermStructure.

Definition at line 57 of file spreadedpricetermstructure.cpp.

57{ return referenceCurve_->minTime(); }

◆ currency()

const QuantLib::Currency & currency ( ) const
overridevirtual

The currency in which prices are expressed.

Implements PriceTermStructure.

Definition at line 59 of file spreadedpricetermstructure.cpp.

59{ return referenceCurve_->currency(); }

◆ pillarDates()

std::vector< QuantLib::Date > pillarDates ( ) const
overridevirtual

The pillar dates for the PriceTermStructure.

Implements PriceTermStructure.

Definition at line 61 of file spreadedpricetermstructure.cpp.

61{ return referenceCurve_->pillarDates(); }

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 63 of file spreadedpricetermstructure.cpp.

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

◆ priceImpl()

QuantLib::Real priceImpl ( QuantLib::Time  ) const
overrideprivatevirtual

Price calculation.

Implements PriceTermStructure.

Definition at line 71 of file spreadedpricetermstructure.cpp.

71 {
72 calculate();
73 return referenceCurve_->price(t) + (*interpolation_)(t);
74}

Member Data Documentation

◆ referenceCurve_

QuantLib::Handle<PriceTermStructure> referenceCurve_
private

Definition at line 54 of file spreadedpricetermstructure.hpp.

◆ times_

std::vector<QuantLib::Real> times_
mutableprivate

Definition at line 55 of file spreadedpricetermstructure.hpp.

◆ priceSpreads_

std::vector<QuantLib::Handle<QuantLib::Quote> > priceSpreads_
private

Definition at line 56 of file spreadedpricetermstructure.hpp.

◆ data_

std::vector<QuantLib::Real> data_
mutableprivate

Definition at line 58 of file spreadedpricetermstructure.hpp.

◆ interpolation_

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

Definition at line 59 of file spreadedpricetermstructure.hpp.