24#ifndef quantext_zero_inflation_curve_observer_moving_hpp
25#define quantext_zero_inflation_curve_observer_moving_hpp
27#include <ql/math/comparison.hpp>
28#include <ql/math/interpolations/linearinterpolation.hpp>
29#include <ql/patterns/lazyobject.hpp>
30#include <ql/termstructures/inflationtermstructure.hpp>
31#include <ql/termstructures/interpolatedcurve.hpp>
38template <
class Interpolator>
40 protected InterpolatedCurve<Interpolator>,
44 Natural settlementDays,
const Calendar& calendar,
const DayCounter& dayCounter,
const Period& lag,
45 Frequency frequency,
bool indexIsInterpolated,
const std::vector<Time>&
times,
46 const std::vector<Handle<Quote>>&
rates,
47 const QuantLib::ext::shared_ptr<Seasonality>& seasonality = QuantLib::ext::shared_ptr<Seasonality>(),
48 const Interpolator& interpolator = Interpolator());
59 const std::vector<Time>&
times()
const;
60 const std::vector<Real>&
data()
const;
61 const std::vector<Rate>&
rates()
const;
89template <
class Interpolator>
91 Natural settlementDays,
const Calendar& calendar,
const DayCounter& dayCounter,
const Period& lag,
92 Frequency frequency,
bool indexIsInterpolated,
const std::vector<Time>& times,
93 const std::vector<Handle<Quote>>& rates,
const QuantLib::ext::shared_ptr<Seasonality>& seasonality,
94 const Interpolator& interpolator)
95 : ZeroInflationTermStructure(settlementDays, calendar, dayCounter, rates[0]->value(), lag, frequency, seasonality),
96 InterpolatedCurve<Interpolator>(std::vector<Time>(), std::vector<Real>(), interpolator), quotes_(rates), indexIsInterpolated_(indexIsInterpolated) {
98 QL_REQUIRE(
times.size() > 1,
"too few times: " <<
times.size());
99 this->times_.resize(
times.size());
100 this->times_[0] =
times[0];
101 for (Size i = 1; i <
times.size(); i++) {
102 QL_REQUIRE(
times[i] >
times[i - 1],
"times not sorted");
103 this->times_[i] =
times[i];
106 QL_REQUIRE(this->
quotes_.size() == this->times_.size(),
107 "quotes/times count mismatch: " << this->quotes_.size() <<
" vs " << this->times_.size());
110 this->data_.resize(this->times_.size());
111 for (Size i = 0; i < this->times_.size(); i++)
112 this->data_[0] = 0.0;
114 this->interpolation_ =
115 this->interpolator_.interpolate(this->times_.begin(), this->times_.end(), this->data_.begin());
116 this->interpolation_.update();
119 for (Size i = 0; i < this->
quotes_.size(); i++)
120 registerWith(this->
quotes_[i]);
135 return this->interpolation_(t,
true);
153 LazyObject::update();
154 ZeroInflationTermStructure::update();
159 Date d = Settings::instance().evaluationDate();
160 Date d0 = d - this->observationLag();
161 if (!indexIsInterpolated_) {
162 baseDate_ = inflationPeriod(d0, this->frequency_).first;
167 for (Size i = 0; i < this->times_.size(); ++i)
168 this->data_[i] = quotes_[i]->value();
169 this->interpolation_ =
170 this->interpolator_.interpolate(this->times_.begin(), this->times_.end(), this->data_.begin());
171 this->interpolation_.update();
Inflation term structure based on the interpolation of zero rates, with floating reference date.
void performCalculations() const override
const std::vector< Rate > & rates() const
Rate zeroRateImpl(Time t) const override
ZeroInflationCurveObserverMoving(Natural settlementDays, const Calendar &calendar, const DayCounter &dayCounter, const Period &lag, Frequency frequency, bool indexIsInterpolated, const std::vector< Time > ×, const std::vector< Handle< Quote > > &rates, const QuantLib::ext::shared_ptr< Seasonality > &seasonality=QuantLib::ext::shared_ptr< Seasonality >(), const Interpolator &interpolator=Interpolator())
Date baseDate() const override
bool indexIsInterpolated_
const std::vector< Real > & data() const
const std::vector< Time > & times() const
const std::vector< Handle< Quote > > & quotes() const
Date maxDate() const override
std::vector< Handle< Quote > > quotes_
Time maxTime() const override