Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
YoYInflationCurveObserverStatic< Interpolator > Class Template Reference

Inflation term structure based on the interpolation of zero rates. More...

#include <qle/termstructures/yoyinflationcurveobserverstatic.hpp>

+ Inheritance diagram for YoYInflationCurveObserverStatic< Interpolator >:
+ Collaboration diagram for YoYInflationCurveObserverStatic< Interpolator >:

Public Member Functions

 YoYInflationCurveObserverStatic (const Date &referenceDate, const Calendar &calendar, const DayCounter &dayCounter, const Period &lag, Frequency frequency, bool indexIsInterpolated, const std::vector< Date > &dates, const std::vector< Handle< Quote > > &rates, const QuantLib::ext::shared_ptr< Seasonality > &seasonality=QuantLib::ext::shared_ptr< Seasonality >(), const Interpolator &interpolator=Interpolator())
 
InflationTermStructure interface
Date baseDate () const
 
Date maxDate () const
 
Inspectors
const std::vector< Date > & dates () const
 
const std::vector< Time > & times () const
 
const std::vector< Real > & data () const
 
const std::vector< Rate > & rates () const
 
std::vector< std::pair< Date, Rate > > nodes () const
 
const std::vector< Handle< Quote > > & quotes () const
 
Observer interface
void update ()
 

Private Member Functions

LazyObject interface
void performCalculations () const
 

YoYInflationTermStructure Interface

std::vector< Date > dates_
 
std::vector< Handle< Quote > > quotes_
 
bool indexIsInterpolated_
 
Rate yoyRateImpl (Time t) const
 

Detailed Description

template<class Interpolator>
class QuantExt::YoYInflationCurveObserverStatic< Interpolator >

Inflation term structure based on the interpolation of zero rates.

Definition at line 40 of file yoyinflationcurveobserverstatic.hpp.

Constructor & Destructor Documentation

◆ YoYInflationCurveObserverStatic()

YoYInflationCurveObserverStatic ( const Date &  referenceDate,
const Calendar &  calendar,
const DayCounter &  dayCounter,
const Period &  lag,
Frequency  frequency,
bool  indexIsInterpolated,
const std::vector< Date > &  dates,
const std::vector< Handle< Quote > > &  rates,
const QuantLib::ext::shared_ptr< Seasonality > &  seasonality = QuantLib::ext::shared_ptr<Seasonality>(),
const Interpolator &  interpolator = Interpolator() 
)

Definition at line 91 of file yoyinflationcurveobserverstatic.hpp.

96 : YoYInflationTermStructure(referenceDate, calendar, dayCounter, rates[0]->value(), lag, frequency,
97 indexIsInterpolated, seasonality),
98 InterpolatedCurve<Interpolator>(std::vector<Time>(), std::vector<Real>(), interpolator), dates_(dates),
99 quotes_(rates), indexIsInterpolated_(indexIsInterpolated) {
100
101 QL_REQUIRE(dates_.size() > 1, "too few dates: " << dates_.size());
102
103 /**
104 // check that the data starts from the beginning,
105 // i.e. referenceDate - lag, at least must be in the relevant
106 // period
107 std::pair<Date,Date> lim =
108 inflationPeriod(yTS->referenceDate() - this->observationLag(), frequency);
109 QL_REQUIRE(lim.first <= dates_[0] && dates_[0] <= lim.second,
110 "first data date is not in base period, date: " << dates_[0]
111 << " not within [" << lim.first << "," << lim.second << "]");
112 **/
113
114 // by convention, if the index is not interpolated we pull all the dates
115 // back to the start of their inflationPeriods
116 // otherwise the time calculations will be inconsistent
118 for (Size i = 0; i < dates_.size(); i++) {
119 dates_[i] = inflationPeriod(dates_[i], frequency).first;
120 }
121 }
122
123 QL_REQUIRE(this->quotes_.size() == dates_.size(),
124 "quotes/dates count mismatch: " << this->quotes_.size() << " vs " << dates_.size());
125
126 // initialise data vector, values are copied from quotes in performCalculations()
127 this->data_.resize(dates_.size());
128 for (Size i = 0; i < dates_.size(); i++)
129 this->data_[0] = 0.0;
130
131 this->times_.resize(dates_.size());
132 this->times_[0] = timeFromReference(dates_[0]);
133 for (Size i = 1; i < dates_.size(); i++) {
134 QL_REQUIRE(dates_[i] > dates_[i - 1], "dates not sorted");
135
136 // but must be greater than -1
137 QL_REQUIRE(this->data_[i] > -1.0, "zero inflation data < -100 %");
138
139 // this can be negative
140 this->times_[i] = timeFromReference(dates_[i]);
141 QL_REQUIRE(!close(this->times_[i], this->times_[i - 1]), "two dates correspond to the same time "
142 "under this curve's day count convention");
143 }
144
145 this->interpolation_ =
146 this->interpolator_.interpolate(this->times_.begin(), this->times_.end(), this->data_.begin());
147 this->interpolation_.update();
148
149 // register with each of the quotes
150 for (Size i = 0; i < quotes_.size(); i++)
151 registerWith(quotes_[i]);
152}

Member Function Documentation

◆ baseDate()

Date baseDate

Definition at line 154 of file yoyinflationcurveobserverstatic.hpp.

154 {
155 // if indexIsInterpolated we fixed the dates in the constructor
156 calculate();
157 return dates_.front();
158}

◆ maxDate()

Date maxDate

Definition at line 160 of file yoyinflationcurveobserverstatic.hpp.

160 {
161 Date d;
162 if (indexIsInterpolated()) {
163 d = dates_.back();
164 } else {
165 d = inflationPeriod(dates_.back(), frequency()).second;
166 }
167 return d;
168}

◆ dates()

const std::vector< Date > & dates

Definition at line 179 of file yoyinflationcurveobserverstatic.hpp.

179{ return dates_; }

◆ times()

const std::vector< Time > & times

Definition at line 175 of file yoyinflationcurveobserverstatic.hpp.

175 {
176 return this->times_;
177}

◆ data()

const std::vector< Real > & data

Definition at line 186 of file yoyinflationcurveobserverstatic.hpp.

186 {
187 calculate();
188 return this->data_;
189}

◆ rates()

const std::vector< Rate > & rates

Definition at line 181 of file yoyinflationcurveobserverstatic.hpp.

181 {
182 calculate();
183 return this->data_;
184}

◆ nodes()

std::vector< std::pair< Date, Rate > > nodes

Definition at line 191 of file yoyinflationcurveobserverstatic.hpp.

191 {
192 calculate();
193 std::vector<std::pair<Date, Rate> > results(dates_.size());
194 for (Size i = 0; i < dates_.size(); ++i)
195 results[i] = std::make_pair(dates_[i], this->data_[i]);
196 return results;
197}

◆ quotes()

const std::vector< Handle< Quote > > & quotes ( ) const

Definition at line 64 of file yoyinflationcurveobserverstatic.hpp.

64{ return quotes_; };

◆ update()

void update

Definition at line 199 of file yoyinflationcurveobserverstatic.hpp.

199 {
200 LazyObject::update();
201 YoYInflationTermStructure::update();
202}

◆ performCalculations()

void performCalculations
private

Definition at line 204 of file yoyinflationcurveobserverstatic.hpp.

204 {
205 for (Size i = 0; i < dates_.size(); ++i)
206 this->data_[i] = quotes_[i]->value();
207 this->interpolation_ =
208 this->interpolator_.interpolate(this->times_.begin(), this->times_.end(), this->data_.begin());
209 this->interpolation_.update();
210}

◆ yoyRateImpl()

Rate yoyRateImpl ( Time  t) const
protected

Definition at line 170 of file yoyinflationcurveobserverstatic.hpp.

170 {
171 calculate();
172 return this->interpolation_(t, true);
173}

Member Data Documentation

◆ dates_

std::vector<Date> dates_
mutableprotected

Definition at line 83 of file yoyinflationcurveobserverstatic.hpp.

◆ quotes_

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

Definition at line 84 of file yoyinflationcurveobserverstatic.hpp.

◆ indexIsInterpolated_

bool indexIsInterpolated_
protected

Definition at line 85 of file yoyinflationcurveobserverstatic.hpp.