/src/quantlib/ql/cashflows/zeroinflationcashflow.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2021 Ralf Konrad Eckel |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <https://www.quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | /*! \file zeroinflationcashflow.hpp |
21 | | \brief Cash flow dependent on an inflation index ratio (NOT a coupon, i.e. no accruals). |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_inflation_cash_flow_hpp |
25 | | #define quantlib_inflation_cash_flow_hpp |
26 | | |
27 | | #include <ql/cashflows/indexedcashflow.hpp> |
28 | | #include <ql/indexes/inflationindex.hpp> |
29 | | |
30 | | namespace QuantLib { |
31 | | |
32 | | //! Cash flow dependent on a zero inflation index ratio. |
33 | | /*! The ratio is taken between fixings observed at the start date |
34 | | and the end date minus the observation lag; that is, if the start |
35 | | and end dates are, e.g., in June and the observation lag is three |
36 | | months, the ratio will be taken between March fixings. |
37 | | */ |
38 | | class ZeroInflationCashFlow : public IndexedCashFlow { |
39 | | public: |
40 | | /*! The fixings dates for the index are `startDate - observationLag` and |
41 | | `endDate - observationLag`. |
42 | | */ |
43 | | ZeroInflationCashFlow(Real notional, |
44 | | const ext::shared_ptr<ZeroInflationIndex>& index, |
45 | | CPI::InterpolationType observationInterpolation, |
46 | | const Date& startDate, |
47 | | const Date& endDate, |
48 | | const Period& observationLag, |
49 | | const Date& paymentDate, |
50 | | bool growthOnly = false); |
51 | | |
52 | | //! \name ZeroInflationCashFlow interface |
53 | | //@{ |
54 | 0 | ext::shared_ptr<ZeroInflationIndex> zeroInflationIndex() const { |
55 | 0 | return zeroInflationIndex_; |
56 | 0 | } |
57 | 0 | CPI::InterpolationType observationInterpolation() const { |
58 | 0 | return interpolation_; |
59 | 0 | } |
60 | | //@} |
61 | | |
62 | | //! \name ZeroInflationCashFlow interface |
63 | | //@{ |
64 | | Real baseFixing() const override; |
65 | | Real indexFixing() const override; |
66 | | //@} |
67 | | |
68 | | //! \name Visitability |
69 | | //@{ |
70 | | void accept(AcyclicVisitor&) override; |
71 | | //@} |
72 | | |
73 | | private: |
74 | | ext::shared_ptr<ZeroInflationIndex> zeroInflationIndex_; |
75 | | CPI::InterpolationType interpolation_; |
76 | | Date startDate_, endDate_; |
77 | | Period observationLag_; |
78 | | }; |
79 | | |
80 | | } |
81 | | |
82 | | #endif |