/src/quantlib/ql/termstructures/inflation/inflationhelpers.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2007, 2009 Chris Kenyon |
5 | | Copyright (C) 2007 StatPro Italia srl |
6 | | |
7 | | This file is part of QuantLib, a free-software/open-source library |
8 | | for financial quantitative analysts and developers - http://quantlib.org/ |
9 | | |
10 | | QuantLib is free software: you can redistribute it and/or modify it |
11 | | under the terms of the QuantLib license. You should have received a |
12 | | copy of the license along with this program; if not, please email |
13 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
14 | | <https://www.quantlib.org/license.shtml>. |
15 | | |
16 | | This program is distributed in the hope that it will be useful, but WITHOUT |
17 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
18 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
19 | | */ |
20 | | |
21 | | /*! \file inflationhelpers.hpp |
22 | | \brief Bootstrap helpers for inflation term structures |
23 | | */ |
24 | | |
25 | | #ifndef quantlib_inflation_helpers_hpp |
26 | | #define quantlib_inflation_helpers_hpp |
27 | | |
28 | | #include <ql/instruments/yearonyearinflationswap.hpp> |
29 | | #include <ql/instruments/zerocouponinflationswap.hpp> |
30 | | #include <ql/termstructures/bootstraphelper.hpp> |
31 | | #include <ql/termstructures/inflationtermstructure.hpp> |
32 | | |
33 | | namespace QuantLib { |
34 | | |
35 | | //! Zero-coupon inflation-swap bootstrap helper |
36 | | class ZeroCouponInflationSwapHelper |
37 | | : public RelativeDateBootstrapHelper<ZeroInflationTermStructure> { |
38 | | public: |
39 | | ZeroCouponInflationSwapHelper( |
40 | | const Handle<Quote>& quote, |
41 | | const Period& swapObsLag, // lag on swap observation of index |
42 | | const Date& maturity, |
43 | | Calendar calendar, // index may have null calendar as valid on every day |
44 | | BusinessDayConvention paymentConvention, |
45 | | DayCounter dayCounter, |
46 | | const ext::shared_ptr<ZeroInflationIndex>& zii, |
47 | | CPI::InterpolationType observationInterpolation); |
48 | | |
49 | | ZeroCouponInflationSwapHelper( |
50 | | const Handle<Quote>& quote, |
51 | | const Period& swapObsLag, // lag on swap observation of index |
52 | | const Date& startDate, |
53 | | const Date& endDate, |
54 | | Calendar calendar, // index may have null calendar as valid on every day |
55 | | BusinessDayConvention paymentConvention, |
56 | | DayCounter dayCounter, |
57 | | const ext::shared_ptr<ZeroInflationIndex>& zii, |
58 | | CPI::InterpolationType observationInterpolation); |
59 | | |
60 | | /*! \deprecated Use the overload that does not take a nominal curve. |
61 | | Deprecated in version 1.39. |
62 | | */ |
63 | | [[deprecated("Use the overload that does not take a nominal curve.")]] |
64 | | ZeroCouponInflationSwapHelper( |
65 | | const Handle<Quote>& quote, |
66 | | const Period& swapObsLag, |
67 | | const Date& maturity, |
68 | | Calendar calendar, |
69 | | BusinessDayConvention paymentConvention, |
70 | | DayCounter dayCounter, |
71 | | const ext::shared_ptr<ZeroInflationIndex>& zii, |
72 | | CPI::InterpolationType observationInterpolation, |
73 | | Handle<YieldTermStructure> nominalTermStructure); |
74 | | |
75 | | void setTermStructure(ZeroInflationTermStructure*) override; |
76 | | Real impliedQuote() const override; |
77 | | //! \name inspectors |
78 | | //@{ |
79 | | // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
80 | 0 | ext::shared_ptr<ZeroCouponInflationSwap> swap() const { return zciis_; } |
81 | | //@} |
82 | | protected: |
83 | | void initializeDates() override; |
84 | | |
85 | | Period swapObsLag_; |
86 | | Date startDate_, maturity_; |
87 | | Calendar calendar_; |
88 | | BusinessDayConvention paymentConvention_; |
89 | | DayCounter dayCounter_; |
90 | | ext::shared_ptr<ZeroInflationIndex> zii_; |
91 | | CPI::InterpolationType observationInterpolation_; |
92 | | ext::shared_ptr<ZeroCouponInflationSwap> zciis_; |
93 | | Handle<YieldTermStructure> nominalTermStructure_; |
94 | | RelinkableHandle<ZeroInflationTermStructure> termStructureHandle_; |
95 | | private: |
96 | | ZeroCouponInflationSwapHelper( |
97 | | const Handle<Quote>& quote, |
98 | | const Period& swapObsLag, |
99 | | const Date& startDate, |
100 | | const Date& endDate, |
101 | | Calendar calendar, |
102 | | BusinessDayConvention paymentConvention, |
103 | | DayCounter dayCounter, |
104 | | const ext::shared_ptr<ZeroInflationIndex>& zii, |
105 | | CPI::InterpolationType observationInterpolation, |
106 | | Handle<YieldTermStructure> nominalTermStructure); |
107 | | }; |
108 | | |
109 | | |
110 | | //! Year-on-year inflation-swap bootstrap helper |
111 | | class YearOnYearInflationSwapHelper |
112 | | : public RelativeDateBootstrapHelper<YoYInflationTermStructure> { |
113 | | public: |
114 | | YearOnYearInflationSwapHelper(const Handle<Quote>& quote, |
115 | | const Period& swapObsLag, |
116 | | const Date& maturity, |
117 | | Calendar calendar, |
118 | | BusinessDayConvention paymentConvention, |
119 | | DayCounter dayCounter, |
120 | | const ext::shared_ptr<YoYInflationIndex>& yii, |
121 | | CPI::InterpolationType interpolation, |
122 | | Handle<YieldTermStructure> nominalTermStructure); |
123 | | |
124 | | YearOnYearInflationSwapHelper(const Handle<Quote>& quote, |
125 | | const Period& swapObsLag, |
126 | | const Date& startDate, |
127 | | const Date& endDate, |
128 | | Calendar calendar, |
129 | | BusinessDayConvention paymentConvention, |
130 | | DayCounter dayCounter, |
131 | | const ext::shared_ptr<YoYInflationIndex>& yii, |
132 | | CPI::InterpolationType interpolation, |
133 | | Handle<YieldTermStructure> nominalTermStructure); |
134 | | |
135 | | void setTermStructure(YoYInflationTermStructure*) override; |
136 | | Real impliedQuote() const override; |
137 | | //! \name inspectors |
138 | | //@{ |
139 | | // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
140 | 0 | ext::shared_ptr<YearOnYearInflationSwap> swap() const { return yyiis_; } |
141 | | //@} |
142 | | protected: |
143 | | void initializeDates() override; |
144 | | |
145 | | Period swapObsLag_; |
146 | | Date startDate_, maturity_; |
147 | | Calendar calendar_; |
148 | | BusinessDayConvention paymentConvention_; |
149 | | DayCounter dayCounter_; |
150 | | ext::shared_ptr<YoYInflationIndex> yii_; |
151 | | CPI::InterpolationType interpolation_; |
152 | | ext::shared_ptr<YearOnYearInflationSwap> yyiis_; |
153 | | Handle<YieldTermStructure> nominalTermStructure_; |
154 | | RelinkableHandle<YoYInflationTermStructure> termStructureHandle_; |
155 | | }; |
156 | | |
157 | | } |
158 | | |
159 | | |
160 | | #endif |