Coverage Report

Created: 2026-09-28 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
            const DayCounter& dayCounter,
46
            const ext::shared_ptr<ZeroInflationIndex>& zii,
47
            CPI::InterpolationType observationInterpolation,
48
            Pillar::Choice pillar = Pillar::LastRelevantDate,
49
            Date customPillarDate = Date());
50
51
        ZeroCouponInflationSwapHelper(
52
            const Handle<Quote>& quote,
53
            const Period& swapObsLag, // lag on swap observation of index
54
            const Date& startDate,
55
            const Date& endDate,
56
            Calendar calendar, // index may have null calendar as valid on every day
57
            BusinessDayConvention paymentConvention,
58
            DayCounter  dayCounter,
59
            const ext::shared_ptr<ZeroInflationIndex>& zii,
60
            CPI::InterpolationType observationInterpolation,
61
            Pillar::Choice pillar = Pillar::LastRelevantDate,
62
            Date customPillarDate = Date());
63
64
        QL_DEPRECATED_DISABLE_WARNING
65
0
        ~ZeroCouponInflationSwapHelper() override = default;
66
        QL_DEPRECATED_ENABLE_WARNING
67
68
        void setTermStructure(ZeroInflationTermStructure*) override;
69
        Real impliedQuote() const override;
70
        //! \name inspectors
71
        //@{
72
        // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
73
0
        ext::shared_ptr<ZeroCouponInflationSwap> swap() const { return zciis_; }
74
        //@}
75
      protected:
76
        void initializeDates() override;
77
78
        Period swapObsLag_;
79
        Date startDate_, maturity_;
80
        Calendar calendar_;
81
        BusinessDayConvention paymentConvention_;
82
        DayCounter dayCounter_;
83
        ext::shared_ptr<ZeroInflationIndex> zii_;
84
        CPI::InterpolationType observationInterpolation_;
85
        Pillar::Choice pillarChoice_;
86
        ext::shared_ptr<ZeroCouponInflationSwap> zciis_;
87
88
        /*! \deprecated Do not use; not needed for calculation.
89
                        Deprecated in version 1.44.
90
        */
91
        [[deprecated("Do not use; not needed for calculation.")]]
92
        Handle<YieldTermStructure> nominalTermStructure_;
93
94
        RelinkableHandle<ZeroInflationTermStructure> termStructureHandle_;
95
    };
96
97
98
    //! Year-on-year inflation-swap bootstrap helper
99
    class YearOnYearInflationSwapHelper
100
        : public RelativeDateBootstrapHelper<YoYInflationTermStructure> {
101
      public:
102
        YearOnYearInflationSwapHelper(const Handle<Quote>& quote,
103
                                      const Period& swapObsLag,
104
                                      const Date& maturity,
105
                                      Calendar calendar,
106
                                      BusinessDayConvention paymentConvention,
107
                                      DayCounter dayCounter,
108
                                      const ext::shared_ptr<YoYInflationIndex>& yii,
109
                                      CPI::InterpolationType interpolation,
110
                                      Handle<YieldTermStructure> nominalTermStructure,
111
                                      Pillar::Choice pillar = Pillar::LastRelevantDate,
112
                                      Date customPillarDate = Date());
113
114
        YearOnYearInflationSwapHelper(const Handle<Quote>& quote,
115
                                      const Period& swapObsLag,
116
                                      const Date& startDate,
117
                                      const Date& endDate,
118
                                      Calendar calendar,
119
                                      BusinessDayConvention paymentConvention,
120
                                      DayCounter dayCounter,
121
                                      const ext::shared_ptr<YoYInflationIndex>& yii,
122
                                      CPI::InterpolationType interpolation,
123
                                      Handle<YieldTermStructure> nominalTermStructure,
124
                                      Pillar::Choice pillar = Pillar::LastRelevantDate,
125
                                      Date customPillarDate = Date());
126
127
        void setTermStructure(YoYInflationTermStructure*) override;
128
        Real impliedQuote() const override;
129
        //! \name inspectors
130
        //@{
131
        // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
132
0
        ext::shared_ptr<YearOnYearInflationSwap> swap() const { return yyiis_; }
133
        //@}
134
      protected:
135
        void initializeDates() override;
136
137
        Period swapObsLag_;
138
        Date startDate_, maturity_;
139
        Calendar calendar_;
140
        BusinessDayConvention paymentConvention_;
141
        DayCounter dayCounter_;
142
        ext::shared_ptr<YoYInflationIndex> yii_;
143
        CPI::InterpolationType interpolation_;
144
        Pillar::Choice pillarChoice_;
145
        ext::shared_ptr<YearOnYearInflationSwap> yyiis_;
146
        Handle<YieldTermStructure> nominalTermStructure_;
147
        RelinkableHandle<YoYInflationTermStructure> termStructureHandle_;
148
    };
149
150
}
151
152
153
#endif