QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
inflationtermstructure.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007, 2009 Chris Kenyon
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_inflation_termstructure_hpp
25#define quantlib_inflation_termstructure_hpp
26
27#include <ql/termstructures/yieldtermstructure.hpp>
28#include <ql/termstructures/inflation/seasonality.hpp>
29
30namespace QuantLib {
31
32 class InflationIndex;
33
35
37 public:
39
44 ext::shared_ptr<Seasonality> seasonality = {});
49 const Calendar& calendar = Calendar(),
51 ext::shared_ptr<Seasonality> seasonality = {});
53 const Calendar& calendar,
58 ext::shared_ptr<Seasonality> seasonality = {});
60
62
63
66 virtual Period observationLag() const;
67 virtual Frequency frequency() const;
68 virtual Rate baseRate() const;
69
71
80 virtual Date baseDate() const = 0;
82
84
87 void setSeasonality(const ext::shared_ptr<Seasonality>& seasonality = {});
88 ext::shared_ptr<Seasonality> seasonality() const;
89 bool hasSeasonality() const;
90
91 protected:
92
93 // This next part is required for piecewise- constructors
94 // because, for inflation, they need more than just the
95 // instruments to build the term structure, since the rate at
96 // time 0-lag is non-zero, since we deal (effectively) with
97 // "forwards".
98 virtual void setBaseRate(const Rate &r) { baseRate_ = r; }
99
100
101 // range-checking
102 void checkRange(const Date&,
103 bool extrapolate) const;
104 void checkRange(Time t,
105 bool extrapolate) const;
106
107 ext::shared_ptr<Seasonality> seasonality_;
111 };
112
114 // Child classes use templates but do not want that exposed to
115 // general users.
117 public:
119
121 Rate baseZeroRate,
122 const Period& lag,
124 const ext::shared_ptr<Seasonality> &seasonality = {});
125
127 const Calendar& calendar,
128 const DayCounter& dayCounter,
129 Rate baseZeroRate,
130 const Period& lag,
132 const ext::shared_ptr<Seasonality>& seasonality = {});
133
135 const Calendar& calendar,
136 const DayCounter& dayCounter,
137 Rate baseZeroRate,
138 const Period& lag,
140 const ext::shared_ptr<Seasonality> &seasonality = {});
142
144
145
155 Rate zeroRate(const Date &d, const Period& instObsLag = Period(-1,Days),
156 bool forceLinearInterpolation = false,
157 bool extrapolate = false) const;
159
166 bool extrapolate = false) const;
168 protected:
170 virtual Rate zeroRateImpl(Time t) const = 0;
171 };
172
173
176 public:
178
180 Rate baseYoYRate,
181 const Period& lag,
184 const ext::shared_ptr<Seasonality> &seasonality = {});
185
187 const Calendar& calendar,
188 const DayCounter& dayCounter,
189 Rate baseYoYRate,
190 const Period& lag,
193 const ext::shared_ptr<Seasonality> &seasonality = {});
194
196 const Calendar& calendar,
197 const DayCounter& dayCounter,
198 Rate baseYoYRate,
199 const Period& lag,
202 const ext::shared_ptr<Seasonality> &seasonality = {});
204
206
207
213 Rate yoyRate(const Date &d, const Period& instObsLag = Period(-1,Days),
214 bool forceLinearInterpolation = false,
215 bool extrapolate = false) const;
217
223 Rate yoyRate(Time t,
224 bool extrapolate = false) const;
226
227 virtual bool indexIsInterpolated() const;
228 protected:
230 virtual Rate yoyRateImpl(Time time) const = 0;
231 private:
233 };
234
235
237 std::pair<Date,Date> inflationPeriod(const Date &,
238 Frequency);
239
243 bool indexIsInterpolated,
244 const DayCounter &,
245 const Date &, const Date &);
246
247
248 // inline
249
251 return observationLag_;
252 }
253
255 return frequency_;
256 }
257
259 return baseRate_;
260 }
261
262 inline ext::shared_ptr<Seasonality> InflationTermStructure::seasonality() const {
263 return seasonality_;
264 }
265
267 return static_cast<bool>(seasonality_);
268 }
269
272 }
273
274}
275
276#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Interface for inflation term structures.
ext::shared_ptr< Seasonality > seasonality_
ext::shared_ptr< Seasonality > seasonality() const
void setSeasonality(const ext::shared_ptr< Seasonality > &seasonality={})
Functions to set and get seasonality.
virtual void setBaseRate(const Rate &r)
void checkRange(const Date &, bool extrapolate) const
virtual Date baseDate() const =0
minimum (base) date
Basic term-structure functionality.
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
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 Rate yoyRateImpl(Time time) const =0
to be defined in derived classes
Rate yoyRate(const Date &d, const Period &instObsLag=Period(-1, Days), bool forceLinearInterpolation=false, bool extrapolate=false) const
year-on-year inflation rate.
Interface for zero inflation term structures.
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.
Frequency
Frequency of events.
Definition: frequency.hpp:37
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
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)