/src/quantlib/ql/cashflows/zeroinflationcashflow.cpp
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 | | #include <ql/cashflows/zeroinflationcashflow.hpp> |
21 | | #include <ql/indexes/inflationindex.hpp> |
22 | | #include <ql/termstructures/inflationtermstructure.hpp> |
23 | | #include <ql/time/calendars/nullcalendar.hpp> |
24 | | |
25 | | namespace QuantLib { |
26 | | |
27 | | ZeroInflationCashFlow::ZeroInflationCashFlow(Real notional, |
28 | | const ext::shared_ptr<ZeroInflationIndex>& index, |
29 | | CPI::InterpolationType observationInterpolation, |
30 | | const Date& startDate, |
31 | | const Date& endDate, |
32 | | const Period& observationLag, |
33 | | const Date& paymentDate, |
34 | | bool growthOnly) |
35 | 0 | : IndexedCashFlow(notional, index, |
36 | 0 | startDate - observationLag, endDate - observationLag, |
37 | 0 | paymentDate, growthOnly), |
38 | 0 | zeroInflationIndex_(index), interpolation_(observationInterpolation), |
39 | 0 | startDate_(startDate), endDate_(endDate), observationLag_(observationLag) {}Unexecuted instantiation: QuantLib::ZeroInflationCashFlow::ZeroInflationCashFlow(double, boost::shared_ptr<QuantLib::ZeroInflationIndex> const&, QuantLib::CPI::InterpolationType, QuantLib::Date const&, QuantLib::Date const&, QuantLib::Period const&, QuantLib::Date const&, bool) Unexecuted instantiation: QuantLib::ZeroInflationCashFlow::ZeroInflationCashFlow(double, boost::shared_ptr<QuantLib::ZeroInflationIndex> const&, QuantLib::CPI::InterpolationType, QuantLib::Date const&, QuantLib::Date const&, QuantLib::Period const&, QuantLib::Date const&, bool) |
40 | | |
41 | 0 | Real ZeroInflationCashFlow::baseFixing() const { |
42 | 0 | return CPI::laggedFixing(zeroInflationIndex_, startDate_, observationLag_, interpolation_); |
43 | 0 | } |
44 | | |
45 | 0 | Real ZeroInflationCashFlow::indexFixing() const { |
46 | 0 | return CPI::laggedFixing(zeroInflationIndex_, endDate_, observationLag_, interpolation_); |
47 | 0 | } |
48 | | |
49 | 0 | void ZeroInflationCashFlow::accept(AcyclicVisitor& v) { |
50 | 0 | auto* v1 = dynamic_cast<Visitor<ZeroInflationCashFlow>*>(&v); |
51 | 0 | if (v1 != nullptr) |
52 | 0 | v1->visit(*this); |
53 | 0 | else |
54 | 0 | IndexedCashFlow::accept(v); |
55 | 0 | } |
56 | | |
57 | | } |