19#include <ql/termstructures/inflationtermstructure.hpp>
20#include <ql/time/calendars/nullcalendar.hpp>
25QL_DEPRECATED_DISABLE_WARNING
27 : ZeroInflationIndex(source->familyName(), source->region(), source->revised(), source->frequency(), source->availabilityLag(), source->currency(),
28 source->zeroInflationTermStructure()),
29 source_(source), interpolation_(
QuantLib::CPI::InterpolationType::Flat) {}
32 const CPI::InterpolationType interpolation)
33 : ZeroInflationIndex(source->familyName(), source->region(), source->revised(), source->interpolated(),
34 source->frequency(), source->availabilityLag(), source->currency(),
35 source->zeroInflationTermStructure()),
36 source_(source), interpolation_(interpolation) {}
37QL_DEPRECATED_ENABLE_WARNING
44 QL_DEPRECATED_DISABLE_WARNING
46 return source_->fixing(fixingDate);
48 std::pair<Date, Date> dd = inflationPeriod(fixingDate, frequency());
49 Real indexStart =
source_->fixing(dd.first);
51 Real indexEnd =
source_->fixing(dd.second + Period(1, Days));
53 return indexStart + (indexEnd - indexStart) * (fixingDate - dd.first) /
54 ((dd.second + Period(1, Days)) -
61 QL_DEPRECATED_ENABLE_WARNING
65 const bool interpolated,
const Handle<YoYInflationTermStructure>& ts)
66 : YoYInflationIndex(zeroIndex, interpolated, ts),
67 zeroIndex_(zeroIndex) {
75 if (needsForecast(fixingDate)) {
79 return YoYInflationIndex::fixing(fixingDate);
83 if (!yoyInflationTermStructure().empty())
84 return YoYInflationIndex::fixing(fixingDate);
85 auto interpolation = YoYInflationIndex::interpolated() ? CPI::Linear : CPI::Flat;
86 Real f1 = CPI::laggedFixing(
zeroIndex_, fixingDate, 0 * Days, interpolation);
87 Real f0 = CPI::laggedFixing(
zeroIndex_, fixingDate - 1 * Years, 0 * Days, interpolation);
88 return (f1 - f0) / f0;
const QuantLib::ext::shared_ptr< ZeroInflationIndex > zeroIndex_
Rate forecastFixing(const Date &fixingDate) const
Rate fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
YoYInflationIndexWrapper(const QuantLib::ext::shared_ptr< ZeroInflationIndex > zeroIndex, const bool interpolated, const Handle< YoYInflationTermStructure > &ts=Handle< YoYInflationTermStructure >())
ZeroInflationIndexWrapper(const QuantLib::ext::shared_ptr< ZeroInflationIndex > source)
const QuantLib::ext::shared_ptr< ZeroInflationIndex > source_
QL_DEPRECATED const CPI::InterpolationType interpolation_
Rate fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
wrapper classes for inflation yoy and interpolation