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

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

#include <qle/termstructures/zeroinflationcurveobserverstatic.hpp>

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

Public Member Functions

 ZeroInflationCurveObserverStatic (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
 

ZeroInflationTermStructure Interface

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

Detailed Description

template<class Interpolator>
class QuantExt::ZeroInflationCurveObserverStatic< Interpolator >

Inflation term structure based on the interpolation of zero rates.

Definition at line 39 of file zeroinflationcurveobserverstatic.hpp.

Constructor & Destructor Documentation

◆ ZeroInflationCurveObserverStatic()

ZeroInflationCurveObserverStatic ( 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 90 of file zeroinflationcurveobserverstatic.hpp.

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

Member Function Documentation

◆ baseDate()

Date baseDate

Definition at line 152 of file zeroinflationcurveobserverstatic.hpp.

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

◆ maxDate()

Date maxDate

Definition at line 158 of file zeroinflationcurveobserverstatic.hpp.

158 {
159 Date d;
161 d = dates_.back();
162 } else {
163 d = inflationPeriod(dates_.back(), frequency()).second;
164 }
165 return d;
166}

◆ dates()

const std::vector< Date > & dates

Definition at line 177 of file zeroinflationcurveobserverstatic.hpp.

177{ return dates_; }

◆ times()

const std::vector< Time > & times

Definition at line 173 of file zeroinflationcurveobserverstatic.hpp.

173 {
174 return this->times_;
175}

◆ data()

const std::vector< Real > & data

Definition at line 184 of file zeroinflationcurveobserverstatic.hpp.

184 {
185 calculate();
186 return this->data_;
187}

◆ rates()

const std::vector< Rate > & rates

Definition at line 179 of file zeroinflationcurveobserverstatic.hpp.

179 {
180 calculate();
181 return this->data_;
182}

◆ nodes()

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

Definition at line 189 of file zeroinflationcurveobserverstatic.hpp.

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

◆ quotes()

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

Definition at line 63 of file zeroinflationcurveobserverstatic.hpp.

63{ return quotes_; };

◆ update()

void update

Definition at line 197 of file zeroinflationcurveobserverstatic.hpp.

197 {
198 LazyObject::update();
199 ZeroInflationTermStructure::update();
200}

◆ performCalculations()

void performCalculations
private

Definition at line 202 of file zeroinflationcurveobserverstatic.hpp.

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

◆ zeroRateImpl()

Rate zeroRateImpl ( Time  t) const
protected

Definition at line 168 of file zeroinflationcurveobserverstatic.hpp.

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

Member Data Documentation

◆ dates_

std::vector<Date> dates_
mutableprotected

Definition at line 82 of file zeroinflationcurveobserverstatic.hpp.

◆ quotes_

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

Definition at line 83 of file zeroinflationcurveobserverstatic.hpp.

◆ indexIsInterpolated_

bool indexIsInterpolated_
protected

Definition at line 84 of file zeroinflationcurveobserverstatic.hpp.