26#ifndef quantlib_interpolated_yoy_inflationcurve_hpp
27#define quantlib_interpolated_yoy_inflationcurve_hpp
42 template<
class Interpolator>
48 std::vector<Date>
dates,
49 const std::vector<Rate>&
rates,
53 const ext::shared_ptr<Seasonality>&
seasonality = {},
54 const Interpolator& interpolator = Interpolator());
67 std::vector<Date>
dates,
68 const std::vector<Rate>&
rates,
69 const Interpolator& interpolator = Interpolator());
79 const std::vector<Date>&
dates()
const;
80 const std::vector<Time>&
times()
const;
81 const std::vector<Real>&
data()
const;
82 const std::vector<Rate>&
rates()
const;
83 std::vector<std::pair<Date,Rate> >
nodes()
const;
103 const ext::shared_ptr<Seasonality>&
seasonality = {},
104 const Interpolator& interpolator = Interpolator());
118 const Interpolator& interpolator = Interpolator());
127 template <
class Interpolator>
129 const Date& referenceDate,
130 std::vector<Date> dates,
131 const std::vector<Rate>& rates,
133 bool indexIsInterpolated,
135 const ext::shared_ptr<Seasonality>& seasonality,
136 const Interpolator& interpolator)
138 indexIsInterpolated, dayCounter, seasonality),
140 dates_(
std::move(dates)) {
145 "indices/dates count mismatch: "
146 << this->data_.size() <<
" vs " <<
dates_.size());
152 "year-on-year inflation data < -100 %");
160 template <
class Interpolator>
166 bool indexIsInterpolated,
168 const ext::shared_ptr<Seasonality>& seasonality,
169 const Interpolator& interpolator)
171 indexIsInterpolated, dayCounter, seasonality),
177 template <
class Interpolator>
179 const Date& referenceDate,
184 bool indexIsInterpolated,
185 std::vector<Date> dates,
186 const std::vector<Rate>& rates,
187 const Interpolator& interpolator)
189 referenceDate, calendar, dayCounter, rates[0], lag, frequency, indexIsInterpolated),
191 dates_(
std::move(dates)) {
198 std::pair<Date,Date> lim =
201 "first data date is not in base period, date: " <<
dates_[0]
202 <<
" not within [" << lim.first <<
"," << lim.second <<
"]");
205 "indices/dates count mismatch: "
206 << this->data_.size() <<
" vs " <<
dates_.size());
212 "year-on-year inflation data < -100 %");
220 template <
class Interpolator>
228 bool indexIsInterpolated,
229 const Interpolator& interpolator)
231 lag, frequency, indexIsInterpolated),
239 if (hasExplicitBaseDate())
242 return dates_.front();
247 return dates_.back();
253 return this->interpolation_(
t,
true);
257 inline const std::vector<Time>&
263 inline const std::vector<Date>&
269 inline const std::vector<Rate>&
275 inline const std::vector<Real>&
281 inline std::vector<std::pair<Date,Rate> >
283 std::vector<std::pair<Date,Rate> >
results(dates_.size());
284 for (
Size i=0; i<dates_.size(); ++i)
285 results[i] = std::make_pair(dates_[i],this->data_[i]);
ext::shared_ptr< Seasonality > seasonality() const
virtual Period observationLag() const
virtual Date baseDate() const
minimum (base) date
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_
const std::vector< Date > & dates() const
const std::vector< Real > & data() const
std::vector< std::pair< Date, Rate > > nodes() const
InterpolatedYoYInflationCurve(const Date &referenceDate, std::vector< Date > dates, const std::vector< Rate > &rates, Frequency frequency, bool indexIsInterpolated, const DayCounter &dayCounter, const ext::shared_ptr< Seasonality > &seasonality={}, const Interpolator &interpolator=Interpolator())
const std::vector< Time > & times() const
Date maxDate() const override
the latest date for which the curve can return values
Date baseDate() const override
minimum (base) date
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
floating-point comparisons
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Frequency
Frequency of events.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Base classes for inflation term structures.
Helper class to build interpolated term structures.
linear interpolation between discrete points
std::pair< Date, Date > inflationPeriod(const Date &d, Frequency frequency)
utility function giving the inflation period for a given date
InterpolatedYoYInflationCurve< Linear > YoYInflationCurve
#define QL_DEPRECATED_DISABLE_WARNING
#define QL_DEPRECATED_ENABLE_WARNING