QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
piecewiseyoyinflationcurve.hpp
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
26#ifndef quantlib_piecewise_yoy_inflation_curve_hpp
27#define quantlib_piecewise_yoy_inflation_curve_hpp
28
29#include <ql/patterns/lazyobject.hpp>
30#include <ql/termstructures/inflation/inflationtraits.hpp>
31#include <ql/termstructures/iterativebootstrap.hpp>
32#include <utility>
33
34namespace QuantLib {
35
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;
51
53 const Date& referenceDate,
54 const Calendar& calendar,
56 const Period& lag,
59 Rate baseYoYRate,
60 std::vector<ext::shared_ptr<typename Traits::helper> > instruments,
61 Real accuracy = 1.0e-12,
62 const Interpolator& i = Interpolator())
66 baseYoYRate,
67 lag,
70 i),
71 instruments_(std::move(instruments)), accuracy_(accuracy) {
72 bootstrap_.setup(this);
73 }
75
77
78 Date baseDate() const override;
79 Date maxDate() const override;
80 //@
82
83 const std::vector<Time>& times() const;
84 const std::vector<Date>& dates() const;
85 const std::vector<Real>& data() const;
86 std::vector<std::pair<Date, Real> > nodes() const;
88
90 void update() override;
92 private:
93 // methods
94 void performCalculations() const override;
95 // data members
96 std::vector<ext::shared_ptr<typename Traits::helper> > instruments_;
98
99 friend class Bootstrap<this_curve>;
100 friend class BootstrapError<this_curve>;
102 };
103
104
105 // inline and template definitions
106
107 template <class I, template <class> class B, class T>
109 this->calculate();
110 return base_curve::baseDate();
111 }
112
113 template <class I, template <class> class B, class T>
115 this->calculate();
116 return base_curve::maxDate();
117 }
118
119 template <class I, template <class> class B, class T>
120 const std::vector<Time>& PiecewiseYoYInflationCurve<I,B,T>::times() const {
121 calculate();
122 return base_curve::times();
123 }
124
125 template <class I, template <class> class B, class T>
126 const std::vector<Date>& PiecewiseYoYInflationCurve<I,B,T>::dates() const {
127 calculate();
128 return base_curve::dates();
129 }
130
131 template <class I, template <class> class B, class T>
132 const std::vector<Real>& PiecewiseYoYInflationCurve<I,B,T>::data() const {
133 calculate();
134 return base_curve::data();
135 }
136
137 template <class I, template <class> class B, class T>
138 std::vector<std::pair<Date, Real> >
140 calculate();
141 return base_curve::nodes();
142 }
143
144 template <class I, template <class> class B, class T>
146 bootstrap_.calculate();
147 }
148
149 template <class I, template <class> class B, class T>
151 base_curve::update();
153 }
154
155}
156
157#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
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.
PiecewiseYoYInflationCurve(const Date &referenceDate, const Calendar &calendar, const DayCounter &dayCounter, const Period &lag, Frequency frequency, bool indexIsInterpolated, Rate baseYoYRate, std::vector< ext::shared_ptr< typename Traits::helper > > instruments, Real accuracy=1.0e-12, const Interpolator &i=Interpolator())
Date baseDate() const override
minimum (base) date
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< Interpolator, Bootstrap, Traits > this_curve
InterpolatedYoYInflationCurve< Interpolator > base_curve
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
Frequency
Frequency of events.
Definition: frequency.hpp:37
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.