32 ext::shared_ptr<Seasonality> seasonality,
35 frequency_(frequency), baseRate_(baseRate), baseDate_(baseDate) {
38 "Seasonality inconsistent with inflation term structure");
43 const Date& referenceDate,
47 ext::shared_ptr<Seasonality> seasonality,
50 frequency_(frequency), baseRate_(baseRate), baseDate_(baseDate) {
53 "Seasonality inconsistent with inflation term structure");
63 ext::shared_ptr<Seasonality> seasonality,
65 :
TermStructure(settlementDays, calendar, dayCounter), seasonality_(
std::move(seasonality)),
66 frequency_(frequency), baseRate_(baseRate), baseDate_(baseDate) {
69 "Seasonality inconsistent with inflation term structure");
80 const ext::shared_ptr<Seasonality>& seasonality) {
85 "Seasonality inconsistent with inflation term structure");
92 bool extrapolate)
const {
94 "date (" <<
d <<
") is before base date (" <<
baseDate() <<
")");
96 "date (" <<
d <<
") is past max curve date ("
101 bool extrapolate)
const {
103 "time (" <<
t <<
") is before base date");
105 "time (" <<
t <<
") is past max curve time ("
114 const ext::shared_ptr<Seasonality>& seasonality)
118 const Date& referenceDate,
122 const ext::shared_ptr<Seasonality>& seasonality)
131 const ext::shared_ptr<Seasonality>& seasonality)
135 bool forceLinearInterpolation,
136 bool extrapolate)
const {
138 Period useLag = instObsLag;
144 if (forceLinearInterpolation) {
147 Real dp = dd.second - dd.first;
148 Real dt =
d - dd.first;
171 bool extrapolate)
const {
184 const ext::shared_ptr<Seasonality> &seasonality)
188 const Date& referenceDate,
193 const ext::shared_ptr<Seasonality> &seasonality)
203 const ext::shared_ptr<Seasonality> &seasonality)
204 :
InflationTermStructure(settlementDays, calendar, baseDate, frequency, dayCounter, seasonality, baseYoYRate) {}
210 bool indexIsInterpolated,
212 const ext::shared_ptr<Seasonality> &seasonality)
218 const Date& referenceDate,
222 bool indexIsInterpolated,
224 const ext::shared_ptr<Seasonality> &seasonality)
226 frequency, dayCounter, seasonality) {
236 bool indexIsInterpolated,
238 const ext::shared_ptr<Seasonality> &seasonality)
240 frequency, dayCounter, seasonality) {
247 bool forceLinearInterpolation,
248 bool extrapolate)
const {
250 Period useLag = instObsLag;
256 if (forceLinearInterpolation) {
259 Real dp = dd.second - dd.first;
260 Real dt = (
d-useLag) - dd.first;
268 yoyRate = y1 + (y2-y1) * (dt/dp);
291 bool extrapolate)
const {
305 Month startMonth, endMonth;
321 if (month <=
March) {
324 }
else if (month <=
June) {
336 startMonth = endMonth = month;
339 QL_FAIL(
"Frequency not handled: " << frequency);
343 Date startDate =
Date(1, startMonth, year);
346 return std::make_pair(startDate,endDate);
355 if (indexIsInterpolated) {
static Date endOfMonth(const Date &d)
last day of the month to which the given date belongs
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Interface for inflation term structures.
bool hasSeasonality() const
ext::shared_ptr< Seasonality > seasonality_
void setSeasonality(const ext::shared_ptr< Seasonality > &seasonality)
ext::shared_ptr< Seasonality > seasonality() const
InflationTermStructure(Date baseDate, Frequency frequency, const DayCounter &dayCounter=DayCounter(), ext::shared_ptr< Seasonality > seasonality={}, Rate baseRate=Null< Rate >())
virtual Date baseDate() const
minimum (base) date
virtual Frequency frequency() const
void checkRange(const Date &, bool extrapolate) const
Basic term-structure functionality.
virtual Time maxTime() const
the latest time for which the curve can return values
virtual Date maxDate() const =0
the latest date for which the curve can return values
Time timeFromReference(const Date &date) const
date/time conversion
Base class for year-on-year inflation term structures.
YoYInflationTermStructure(Date baseDate, Rate baseYoYRate, Frequency frequency, const DayCounter &dayCounter, const ext::shared_ptr< Seasonality > &seasonality={})
virtual Rate yoyRateImpl(Time time) const =0
to be defined in derived classes
virtual bool indexIsInterpolated() const
bool indexIsInterpolated_
Rate yoyRate(const Date &d, const Period &instObsLag=Period(-1, Days), bool forceLinearInterpolation=false, bool extrapolate=false) const
year-on-year inflation rate.
ZeroInflationTermStructure(Date baseDate, Frequency frequency, const DayCounter &dayCounter, const ext::shared_ptr< Seasonality > &seasonality={})
virtual Rate zeroRateImpl(Time t) const =0
to be defined in derived classes
Rate zeroRate(const Date &d, const Period &instObsLag=Period(-1, Days), bool forceLinearInterpolation=false, bool extrapolate=false) const
zero-coupon inflation rate.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Frequency
Frequency of events.
@ Quarterly
every third month
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
base classes for inflation indexes
Base classes for inflation term structures.
std::pair< Date, Date > inflationPeriod(const Date &d, Frequency frequency)
utility function giving the inflation period for a given date
Time inflationYearFraction(Frequency f, bool indexIsInterpolated, const DayCounter &dayCounter, const Date &d1, const Date &d2)
#define QL_DEPRECATED_DISABLE_WARNING
#define QL_DEPRECATED_ENABLE_WARNING