QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
piecewisezeroinflationcurve.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 piecewisezeroinflationcurve.hpp
23 \brief Piecewise zero-inflation term structure
24*/
25
26#ifndef quantlib_piecewise_zero_inflation_curve_hpp
27#define quantlib_piecewise_zero_inflation_curve_hpp
28
32#include <utility>
33
34namespace QuantLib {
35
36 //! Piecewise zero-inflation term structure
37 template <class Interpolator,
38 template <class> class Bootstrap = IterativeBootstrap,
39 class Traits = ZeroInflationTraits>
41 : public InterpolatedZeroInflationCurve<Interpolator>,
42 public LazyObject {
43 private:
47 public:
48 typedef Traits traits_type;
49 typedef Interpolator interpolator_type;
50
51 //! \name Constructors
52 //@{
54 const Date& referenceDate,
58 std::vector<ext::shared_ptr<typename Traits::helper> > instruments,
59 const ext::shared_ptr<Seasonality>& seasonality = {},
60 Real accuracy = 1.0e-14,
61 const Interpolator& i = Interpolator())
67 i),
68 instruments_(std::move(instruments)), accuracy_(accuracy) {
69 bootstrap_.setup(this);
70 }
71 //@}
72
73 //! \name Inflation interface
74 //@{
75 Date maxDate() const override;
76 //@
77 //! \name Inspectors
78 //@{
79 const std::vector<Time>& times() const;
80 const std::vector<Date>& dates() const;
81 const std::vector<Real>& data() const;
82 std::vector<std::pair<Date, Real> > nodes() const;
83 //@}
84 //! \name Observer interface
85 //@{
86 void update() override;
87 //@}
88 private:
89 // methods
90 void performCalculations() const override;
91 Rate zeroRateImpl(Time t) const override;
92 // data members
93 std::vector<ext::shared_ptr<typename Traits::helper> > instruments_;
95
96 friend class Bootstrap<this_curve>;
97 friend class BootstrapError<this_curve>;
99 };
100
101
102 // inline and template definitions
103
104 template <class I, template <class> class B, class T>
106 this->calculate();
107 return base_curve::maxDate();
108 }
109
110 template <class I, template <class> class B, class T>
111 const std::vector<Time>& PiecewiseZeroInflationCurve<I,B,T>::times() const {
112 calculate();
113 return base_curve::times();
114 }
115
116 template <class I, template <class> class B, class T>
117 const std::vector<Date>& PiecewiseZeroInflationCurve<I,B,T>::dates() const {
118 calculate();
119 return base_curve::dates();
120 }
121
122 template <class I, template <class> class B, class T>
123 const std::vector<Real>& PiecewiseZeroInflationCurve<I,B,T>::data() const {
124 calculate();
125 return base_curve::rates();
126 }
127
128 template <class I, template <class> class B, class T>
129 std::vector<std::pair<Date, Real> >
131 calculate();
132 return base_curve::nodes();
133 }
134
135 template <class I, template <class> class B, class T>
137 bootstrap_.calculate();
138 }
139
140 template <class I, template <class> class B, class T>
142 calculate();
143 return base_curve::zeroRateImpl(t);
144 }
145
146 template <class I, template<class> class B, class T>
148 base_curve::update();
150 }
151
152}
153
154#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 the interpolation of zero rates.
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
void update() override
Definition: lazyobject.hpp:188
Piecewise zero-inflation term structure.
Rate zeroRateImpl(Time t) const override
to be defined in derived classes
InterpolatedZeroInflationCurve< Interpolator > base_curve
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
PiecewiseZeroInflationCurve(const Date &referenceDate, Date baseDate, Frequency frequency, const DayCounter &dayCounter, std::vector< ext::shared_ptr< typename Traits::helper > > instruments, const ext::shared_ptr< Seasonality > &seasonality={}, Real accuracy=1.0e-14, const Interpolator &i=Interpolator())
PiecewiseZeroInflationCurve< Interpolator, Bootstrap, Traits > this_curve
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