QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
piecewiseyoyinflationcurve.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Chris Kenyon
5 Copyright (C) 2007, 2008 StatPro Italia srl
6 Copyright (C) 2011 Ferdinando Ametrano
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file piecewiseyoyinflationcurve.hpp
23 \brief Piecewise year-on-year inflation term structure
24*/
25
26#ifndef quantlib_piecewise_yoy_inflation_curve_hpp
27#define quantlib_piecewise_yoy_inflation_curve_hpp
28
32#include <utility>
33
34namespace QuantLib {
35
36 //! Piecewise year-on-year inflation term structure
37 template <class Interpolator,
38 template <class> class Bootstrap = IterativeBootstrap,
39 class Traits = YoYInflationTraits>
41 public InterpolatedYoYInflationCurve<Interpolator>,
42 public LazyObject {
43 private:
47 public:
48 typedef Traits traits_type;
49 typedef Interpolator interpolator_type;
50
51 //! \name Constructors
52 //@{
53
55 const Date& referenceDate,
57 Rate baseYoYRate,
60 std::vector<ext::shared_ptr<typename Traits::helper> > instruments,
61 const ext::shared_ptr<Seasonality>& seasonality = {},
62 Real accuracy = 1.0e-12,
63 const Interpolator& i = Interpolator())
66 baseYoYRate,
70 i),
71 instruments_(std::move(instruments)), accuracy_(accuracy) {
72 bootstrap_.setup(this);
73 }
74
75 /*! \deprecated Use the overload without indexIsInterpolated.
76 Deprecated in version 1.37.
77 */
78 [[deprecated("Use the overload without indexIsInterpolated")]]
80 const Date& referenceDate,
82 Rate baseYoYRate,
86 std::vector<ext::shared_ptr<typename Traits::helper> > instruments,
87 const ext::shared_ptr<Seasonality>& seasonality = {},
88 Real accuracy = 1.0e-12,
89 const Interpolator& i = Interpolator())
91 dayCounter, instruments, seasonality, accuracy, i) {
95 }
96 //@}
97
98 //! \name Inflation interface
99 //@{
100 Date maxDate() const override;
101 //@
102 //! \name Inspectors
103 //@{
104 const std::vector<Time>& times() const;
105 const std::vector<Date>& dates() const;
106 const std::vector<Real>& data() const;
107 std::vector<std::pair<Date, Real> > nodes() const;
108 //@}
109 //! \name Observer interface
110 //@{
111 void update() override;
112 //@}
113 private:
114 // methods
115 void performCalculations() const override;
116 Rate yoyRateImpl(Time t) const override;
117 // data members
118 std::vector<ext::shared_ptr<typename Traits::helper> > instruments_;
120
121 friend class Bootstrap<this_curve>;
122 friend class BootstrapError<this_curve>;
124 };
125
126
127 // inline and template definitions
128
129 template <class I, template <class> class B, class T>
131 this->calculate();
132 return base_curve::maxDate();
133 }
134
135 template <class I, template <class> class B, class T>
136 const std::vector<Time>& PiecewiseYoYInflationCurve<I,B,T>::times() const {
137 calculate();
138 return base_curve::times();
139 }
140
141 template <class I, template <class> class B, class T>
142 const std::vector<Date>& PiecewiseYoYInflationCurve<I,B,T>::dates() const {
143 calculate();
144 return base_curve::dates();
145 }
146
147 template <class I, template <class> class B, class T>
148 const std::vector<Real>& PiecewiseYoYInflationCurve<I,B,T>::data() const {
149 calculate();
150 return base_curve::data();
151 }
152
153 template <class I, template <class> class B, class T>
154 std::vector<std::pair<Date, Real> >
156 calculate();
157 return base_curve::nodes();
158 }
159
160 template <class I, template <class> class B, class T>
162 bootstrap_.calculate();
163 }
164
165 template <class I, template <class> class B, class T>
167 calculate();
168 return base_curve::yoyRateImpl(t);
169 }
170
171 template <class I, template <class> class B, class T>
173 base_curve::update();
175 }
176
177}
178
179#endif
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
ext::shared_ptr< Seasonality > seasonality() const
virtual Date baseDate() const
minimum (base) date
Inflation term structure based on interpolated year-on-year rates.
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
void update() override
Definition: lazyobject.hpp:188
Piecewise year-on-year inflation term structure.
Rate yoyRateImpl(Time t) const override
to be defined in derived classes
const std::vector< Date > & dates() const
const std::vector< Real > & data() const
std::vector< std::pair< Date, Real > > nodes() const
const std::vector< Time > & times() const
std::vector< ext::shared_ptr< typename Traits::helper > > instruments_
Date maxDate() const override
the latest date for which the curve can return values
PiecewiseYoYInflationCurve(const Date &referenceDate, Date baseDate, Rate baseYoYRate, Frequency frequency, const DayCounter &dayCounter, std::vector< ext::shared_ptr< typename Traits::helper > > instruments, const ext::shared_ptr< Seasonality > &seasonality={}, Real accuracy=1.0e-12, const Interpolator &i=Interpolator())
PiecewiseYoYInflationCurve< Interpolator, Bootstrap, Traits > this_curve
InterpolatedYoYInflationCurve< Interpolator > base_curve
PiecewiseYoYInflationCurve(const Date &referenceDate, Date baseDate, Rate baseYoYRate, Frequency frequency, bool indexIsInterpolated, const DayCounter &dayCounter, std::vector< ext::shared_ptr< typename Traits::helper > > instruments, const ext::shared_ptr< Seasonality > &seasonality={}, Real accuracy=1.0e-12, const Interpolator &i=Interpolator())
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
const DefaultType & t
Frequency
Frequency of events.
Definition: frequency.hpp:37
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
inflation bootstrap traits
universal piecewise-term-structure boostrapper.
framework for calculation on demand and result caching
Definition: any.hpp:37
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217