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

#include <qle/termstructures/spreadedinflationcurve.hpp>

+ Inheritance diagram for SpreadedYoYInflationCurve:
+ Collaboration diagram for SpreadedYoYInflationCurve:

Public Member Functions

 SpreadedYoYInflationCurve (const Handle< YoYInflationTermStructure > &referenceCurve, const std::vector< Time > &times, const std::vector< Handle< Quote > > &quotes)
 times should be consistent with reference ts day counter More...
 
Date maxDate () const override
 
void update () override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
Date baseDate () const override
 

Protected Member Functions

void performCalculations () const override
 
Rate yoyRateImpl (Time t) const override
 

Private Attributes

Handle< YoYInflationTermStructurereferenceCurve_
 
std::vector< Time > times_
 
std::vector< Handle< Quote > > quotes_
 
std::vector< Real > data_
 
QuantLib::ext::shared_ptr< Interpolation > interpolation_
 

Detailed Description

Definition at line 62 of file spreadedinflationcurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedYoYInflationCurve()

SpreadedYoYInflationCurve ( const Handle< YoYInflationTermStructure > &  referenceCurve,
const std::vector< Time > &  times,
const std::vector< Handle< Quote > > &  quotes 
)

times should be consistent with reference ts day counter

Definition at line 71 of file spreadedinflationcurve.cpp.

74 : YoYInflationTermStructure(referenceCurve->dayCounter(), referenceCurve->baseRate(),
75 referenceCurve->observationLag(), referenceCurve->frequency(),
76 referenceCurve->indexIsInterpolated(), referenceCurve->seasonality()),
77 referenceCurve_(referenceCurve), times_(times), quotes_(quotes), data_(times_.size(), 1.0) {
78 QL_REQUIRE(times_.size() > 1, "SpreadedZeroInflationCurve: at least two times required");
79 QL_REQUIRE(times_.size() == quotes.size(),
80 "SpreadedZeroInflationCurve: size of time and quote vectors do not match");
81 for (Size i = 0; i < quotes.size(); ++i) {
82 registerWith(quotes_[i]);
83 }
84 interpolation_ = QuantLib::ext::make_shared<FlatExtrapolation>(
85 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), data_.begin()));
86 interpolation_->enableExtrapolation();
87 registerWith(referenceCurve_);
88}
Handle< YoYInflationTermStructure > referenceCurve_
std::vector< Handle< Quote > > quotes_
QuantLib::ext::shared_ptr< Interpolation > interpolation_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 92 of file spreadedinflationcurve.cpp.

92{ return referenceCurve_->maxDate(); }

◆ update()

void update ( )
override

Definition at line 94 of file spreadedinflationcurve.cpp.

94 {
95 LazyObject::update();
96 TermStructure::update();
97}

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 99 of file spreadedinflationcurve.cpp.

99{ return referenceCurve_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 101 of file spreadedinflationcurve.cpp.

101{ return referenceCurve_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 103 of file spreadedinflationcurve.cpp.

103{ return referenceCurve_->settlementDays(); }

◆ baseDate()

Date baseDate ( ) const
override

Definition at line 90 of file spreadedinflationcurve.cpp.

90{ return referenceCurve_->baseDate(); }

◆ performCalculations()

void performCalculations ( ) const
overrideprotected

Definition at line 105 of file spreadedinflationcurve.cpp.

105 {
106 for (Size i = 0; i < times_.size(); ++i) {
107 QL_REQUIRE(!quotes_[i].empty(), "SpreadedYoYInflationCurve: quote at index " << i << " is empty");
108 data_[i] = quotes_[i]->value();
109 }
110 interpolation_->update();
111}

◆ yoyRateImpl()

Real yoyRateImpl ( Time  t) const
overrideprotected

Definition at line 113 of file spreadedinflationcurve.cpp.

113 {
114 calculate();
115 return referenceCurve_->yoyRate(t) + (*interpolation_)(t);
116}

Member Data Documentation

◆ referenceCurve_

Handle<YoYInflationTermStructure> referenceCurve_
private

Definition at line 82 of file spreadedinflationcurve.hpp.

◆ times_

std::vector<Time> times_
private

Definition at line 83 of file spreadedinflationcurve.hpp.

◆ quotes_

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

Definition at line 84 of file spreadedinflationcurve.hpp.

◆ data_

std::vector<Real> data_
mutableprivate

Definition at line 85 of file spreadedinflationcurve.hpp.

◆ interpolation_

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

Definition at line 86 of file spreadedinflationcurve.hpp.