Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
nonstandardyoyinflationcoupon.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3
4 This file is part of ORE, a free-software/open-source library
5 for transparent pricing and risk analysis - http://opensourcerisk.org
6
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11
12 This program is distributed on the basis that it will form a useful
13 contribution to risk analytics and model standardisation, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18/*
19 Copyright (C) 2009 Chris Kenyon
20
21 This file is part of QuantLib, a free-software/open-source library
22 for financial quantitative analysts and developers - http://quantlib.org/
23
24 QuantLib is free software: you can redistribute it and/or modify it
25 under the terms of the QuantLib license. You should have received a
26 copy of the license along with this program; if not, please email
27 <quantlib-dev@lists.sf.net>. The license is also available online at
28 <http://quantlib.org/license.shtml>.
29
30 This program is distributed in the hope that it will be useful, but WITHOUT
31 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
32 FOR A PARTICULAR PURPOSE. See the license for more details.
33 */
34
35#include <ql/cashflows/capflooredinflationcoupon.hpp>
36#include <ql/cashflows/cashflowvectors.hpp>
37#include <ql/cashflows/inflationcoupon.hpp>
38#include <ql/cashflows/inflationcouponpricer.hpp>
41
42namespace QuantExt {
43
44void NonStandardYoYInflationCoupon::setFixingDates(const Date& denumatorDate, const Date& numeratorDate,
45 const Period& observationLag) {
46
47 fixingDateDenumerator_ = index_->fixingCalendar().advance(
48 denumatorDate - observationLag_, -static_cast<Integer>(fixingDays_), Days, ModifiedPreceding);
49
50 fixingDateNumerator_ = index_->fixingCalendar().advance(
51 numeratorDate - observationLag_, -static_cast<Integer>(fixingDays_), Days, ModifiedPreceding);
52}
53
55 const Date& paymentDate, Real nominal, const Date& startDate, const Date& endDate, Natural fixingDays,
56 const ext::shared_ptr<ZeroInflationIndex>& index, const Period& observationLag, const DayCounter& dayCounter,
57 Real gearing, Spread spread, const Date& refPeriodStart, const Date& refPeriodEnd, bool addInflationNotional, QuantLib::CPI::InterpolationType interpolation)
58 : QuantLib::InflationCoupon(paymentDate, nominal, startDate, endDate, fixingDays, index, observationLag, dayCounter,
59 refPeriodStart, refPeriodEnd),
60 gearing_(gearing), spread_(spread), addInflationNotional_(addInflationNotional),
61 interpolationType_(interpolation) {
62 setFixingDates(refPeriodStart, refPeriodEnd, observationLag);
63}
64
66 Visitor<NonStandardYoYInflationCoupon>* v1 = dynamic_cast<Visitor<NonStandardYoYInflationCoupon>*>(&v);
67 if (v1 != 0)
68 v1->visit(*this);
69 else
70 InflationCoupon::accept(v);
71}
72
73bool NonStandardYoYInflationCoupon::checkPricerImpl(const ext::shared_ptr<InflationCouponPricer>& pricer) const {
74 return static_cast<bool>(ext::dynamic_pointer_cast<NonStandardYoYInflationCouponPricer>(pricer));
75}
76
79
81 auto zii = QuantLib::ext::dynamic_pointer_cast<QuantLib::ZeroInflationIndex>(index_);
82 Real I_t = CPI::laggedFixing(zii, fixingDateNumerator() + observationLag_, observationLag_, interpolationType_);
83 Real I_s = CPI::laggedFixing(zii, fixingDateDenumerator() + observationLag_, observationLag_, interpolationType_);
84 return I_t / I_s - 1.0;
85}
86
88
90
92 Rate r = InflationCoupon::rate();
94 r = gearing() * ((r - spread()) / gearing() + 1) + spread();
95 }
96 return r;
97}
98
100
101ext::shared_ptr<ZeroInflationIndex> NonStandardYoYInflationCoupon::cpiIndex() const {
102 return ext::dynamic_pointer_cast<ZeroInflationIndex>(index_);
103}
104
105} // namespace QuantExt
bool checkPricerImpl(const ext::shared_ptr< InflationCouponPricer > &) const override
virtual ext::shared_ptr< ZeroInflationIndex > cpiIndex() const
void setFixingDates(const Date &denumatorDate, const Date &numeratorDate, const Period &observationLag)
virtual void accept(AcyclicVisitor &) override
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
NonStandardYoYInflationCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< ZeroInflationIndex > &index, const Period &observationLag, const DayCounter &dayCounter, Real gearing=1.0, Spread spread=0.0, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), bool addInflationNotional=false, QuantLib::CPI::InterpolationType interpolation=QuantLib::CPI::InterpolationType::Flat)
Spread spread() const
spread paid over the fixing of the underlying index
SimpleQuote & spread_
pricer for the generalized (nonstandard) yoy coupon the payoff of the coupon is: N * (alpha * I_t/I_s...
capped floored coupon which generalize the yoy inflation coupon it pays: N * (alpha * I_t/I_s + beta)...