26#ifndef quantlib_interpolated_yoy_inflationcurve_hpp
27#define quantlib_interpolated_yoy_inflationcurve_hpp
29#include <ql/termstructures/inflationtermstructure.hpp>
30#include <ql/termstructures/interpolatedcurve.hpp>
31#include <ql/math/interpolations/linearinterpolation.hpp>
32#include <ql/math/comparison.hpp>
42 template<
class Interpolator>
53 std::vector<Date>
dates,
54 const std::vector<Rate>&
rates,
55 const Interpolator& interpolator = Interpolator());
65 const std::vector<Date>&
dates()
const;
66 const std::vector<Time>&
times()
const;
67 const std::vector<Real>&
data()
const;
68 const std::vector<Rate>&
rates()
const;
69 std::vector<std::pair<Date,Rate> >
nodes()
const;
90 const Interpolator& interpolator
100 template <
class Interpolator>
102 const Date& referenceDate,
107 bool indexIsInterpolated,
108 std::vector<Date> dates,
109 const std::vector<Rate>& rates,
110 const Interpolator& interpolator)
112 referenceDate, calendar, dayCounter, rates[0], lag, frequency, indexIsInterpolated),
114 dates_(
std::move(dates)) {
116 QL_REQUIRE(
dates_.size()>1,
"too few dates: " <<
dates_.size());
121 std::pair<Date,Date> lim =
123 QL_REQUIRE(lim.first <=
dates_[0] &&
dates_[0] <= lim.second,
124 "first data date is not in base period, date: " <<
dates_[0]
125 <<
" not within [" << lim.first <<
"," << lim.second <<
"]");
127 QL_REQUIRE(this->
data_.size() == dates_.size(),
128 "indices/dates count mismatch: "
129 << this->data_.size() <<
" vs " <<
dates_.size());
134 QL_REQUIRE(this->
data_[i] > -1.0,
135 "year-on-year inflation data < -100 %");
143 template <
class Interpolator>
151 bool indexIsInterpolated,
152 const Interpolator& interpolator)
154 lag, frequency, indexIsInterpolated),
160 return dates_.front();
165 return dates_.back();
171 return this->interpolation_(t,
true);
175 inline const std::vector<Time>&
181 inline const std::vector<Date>&
187 inline const std::vector<Rate>&
193 inline const std::vector<Real>&
199 inline std::vector<std::pair<Date,Rate> >
201 std::vector<std::pair<Date,Rate> >
results(dates_.size());
202 for (
Size i=0; i<dates_.size(); ++i)
203 results[i] = std::make_pair(dates_[i],this->data_[i]);
virtual Period observationLag() const
virtual Frequency frequency() const
Helper class to build interpolated term structures.
Interpolation interpolation_
void setupTimes(const std::vector< Date > &dates, Date referenceDate, const DayCounter &dayCounter)
void setupInterpolation()
std::vector< Real > data_
Inflation term structure based on interpolated year-on-year rates.
Rate yoyRateImpl(Time t) const override
to be defined in derived classes
const std::vector< Rate > & rates() const
std::vector< Date > dates_
Date baseDate() const override
minimum (base) date
const std::vector< Date > & dates() const
const std::vector< Real > & data() const
std::vector< std::pair< Date, Rate > > nodes() const
const std::vector< Time > & times() const
Date maxDate() const override
the latest date for which the curve can return values
InterpolatedYoYInflationCurve(const Date &referenceDate, const Calendar &calendar, const DayCounter &dayCounter, const Period &lag, Frequency frequency, bool indexIsInterpolated, std::vector< Date > dates, const std::vector< Rate > &rates, const Interpolator &interpolator=Interpolator())
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
Base class for year-on-year inflation term structures.
virtual bool indexIsInterpolated() const
Frequency
Frequency of events.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
std::pair< Date, Date > inflationPeriod(const Date &d, Frequency frequency)
utility function giving the inflation period for a given date
InterpolatedYoYInflationCurve< Linear > YoYInflationCurve