Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
nonstandardcapflooredyoyinflationcoupon.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2021 Quaternion Risk Management Ltd
5 All rights reserved.
6
7 This file is part of ORE, a free-software/open-source library
8 for transparent pricing and risk analysis - http://opensourcerisk.org
9
10 ORE is free software: you can redistribute it and/or modify it
11 under the terms of the Modified BSD License. You should have received a
12 copy of the license along with this program.
13 The license is also available online at <http://opensourcerisk.org>
14
15 This program is distributed on the basis that it will form a useful
16 contribution to risk analytics and model standardisation, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file qle/cashflows/nonstandardyoyinflationcoupon.hpp
22 \brief capped floored coupon which generalize the yoy inflation coupon
23 it pays:
24 N * (alpha * I_t/I_s + beta)
25 N * (alpha * (I_t/I_s - 1) + beta)
26 with an arbitrary time s<t, instead of a fixed 1y offset
27 \ingroup cashflows
28*/
29
30#ifndef quantext_nonstandardcappedlfooredyoycoupon_hpp
31#define quantext_nonstandardcappedlfooredyoycoupon_hpp
32
36
37namespace QuantExt {
38using namespace QuantLib;
39//! Capped or floored inflation coupon.
40/*! Essentially a copy of the nominal version but taking a
41 different index and a set of pricers (not just one).
42
43 The payoff \f$ P \f$ of a capped inflation-rate coupon
44 with paysWithin = true is:
45
46 \f[ P = N \times T \times \min(a L + b, C). \f]
47
48 where \f$ N \f$ is the notional, \f$ T \f$ is the accrual
49 time, \f$ L \f$ is the inflation rate, \f$ a \f$ is its
50 gearing, \f$ b \f$ is the spread, and \f$ C \f$ and \f$ F \f$
51 the strikes.
52
53 The payoff of a floored inflation-rate coupon is:
54
55 \f[ P = N \times T \times \max(a L + b, F). \f]
56
57 The payoff of a collared inflation-rate coupon is:
58
59 \f[ P = N \times T \times \min(\max(a L + b, F), C). \f]
60
61 If paysWithin = false then the inverse is returned
62 (this provides for instrument cap and caplet prices).
63
64 They can be decomposed in the following manner. Decomposition
65 of a capped floating rate coupon when paysWithin = true:
66 \f[
67 R = \min(a L + b, C) = (a L + b) + \min(C - b - \xi |a| L, 0)
68 \f]
69 where \f$ \xi = sgn(a) \f$. Then:
70 \f[
71 R = (a L + b) + |a| \min(\frac{C - b}{|a|} - \xi L, 0)
72 \f]
73 */
75public:
76 // we may watch an underlying coupon ...
77 NonStandardCappedFlooredYoYInflationCoupon(const ext::shared_ptr<NonStandardYoYInflationCoupon>& underlying,
78 Rate cap = Null<Rate>(), Rate floor = Null<Rate>());
79
80 // ... or not
81 NonStandardCappedFlooredYoYInflationCoupon(const Date& paymentDate, Real nominal, const Date& startDate,
82 const Date& endDate, Natural fixingDays,
83 const ext::shared_ptr<ZeroInflationIndex>& index,
84 const Period& observationLag, const DayCounter& dayCounter,
85 Real gearing = 1.0, Spread spread = 0.0, const Rate cap = Null<Rate>(),
86 const Rate floor = Null<Rate>(), const Date& refPeriodStart = Date(),
87 const Date& refPeriodEnd = Date(), bool addInflationNotional = false,
88 QuantLib::CPI::InterpolationType interpolation = QuantLib::CPI::InterpolationType::Flat);
89
90 //! \name augmented Coupon interface
91 //@{
92 //! swap(let) rate
93 Rate rate() const override;
94 //! cap
95 Rate cap() const;
96 //! floor
97 Rate floor() const;
98 //! effective cap of fixing
99 Rate effectiveCap() const;
100 //! effective floor of fixing
101 Rate effectiveFloor() const;
102 //@}
103
104 //! \name Observer interface
105 //@{
106 void update() override;
107 //@}
108
109 //! \name Visitability
110 //@{
111 virtual void accept(AcyclicVisitor& v) override;
112 //@}
113
114 bool isCapped() const { return isCapped_; }
115 bool isFloored() const { return isFloored_; }
116
117 void setPricer(const ext::shared_ptr<NonStandardYoYInflationCouponPricer>&);
118
119protected:
120 virtual void setCommon(Rate cap, Rate floor);
121
122 // data, we only use underlying_ if it was constructed that way,
123 // generally we use the shared_ptr conversion to boolean to test
124 ext::shared_ptr<NonStandardYoYInflationCoupon> underlying_;
127};
128
130public:
131 NonStandardYoYInflationLeg(const Schedule& schedule, const Calendar& cal,
132 const ext::shared_ptr<ZeroInflationIndex>& index, const Period& observationLag);
134 NonStandardYoYInflationLeg& withNotionals(const std::vector<Real>& notionals);
137 NonStandardYoYInflationLeg& withFixingDays(Natural fixingDays);
138 NonStandardYoYInflationLeg& withFixingDays(const std::vector<Natural>& fixingDays);
140 NonStandardYoYInflationLeg& withGearings(const std::vector<Real>& gearings);
142 NonStandardYoYInflationLeg& withSpreads(const std::vector<Spread>& spreads);
144 NonStandardYoYInflationLeg& withCaps(const std::vector<Rate>& caps);
146 NonStandardYoYInflationLeg& withFloors(const std::vector<Rate>& floors);
147 NonStandardYoYInflationLeg& withRateCurve(const Handle<YieldTermStructure>& rateCurve);
149 NonStandardYoYInflationLeg& withObservationInterpolation(QuantLib::CPI::InterpolationType interpolation);
150 operator Leg() const;
151
152private:
153 Schedule schedule_;
154 ext::shared_ptr<ZeroInflationIndex> index_;
156 std::vector<Real> notionals_;
158 BusinessDayConvention paymentAdjustment_;
160 std::vector<Natural> fixingDays_;
161 std::vector<Real> gearings_;
162 std::vector<Spread> spreads_;
163 std::vector<Rate> caps_, floors_;
164 Handle<YieldTermStructure> rateCurve_;
166 QuantLib::CPI::InterpolationType interpolation_;
167};
168
169} // namespace QuantExt
170
171#endif
void setPricer(const ext::shared_ptr< NonStandardYoYInflationCouponPricer > &)
Coupon paying a YoY-inflation type index
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
Spread spread() const
spread paid over the fixing of the underlying index
NonStandardYoYInflationLeg & withPaymentAdjustment(BusinessDayConvention)
NonStandardYoYInflationLeg & withFixingDays(Natural fixingDays)
NonStandardYoYInflationLeg & withRateCurve(const Handle< YieldTermStructure > &rateCurve)
NonStandardYoYInflationLeg & withSpreads(Spread spread)
NonStandardYoYInflationLeg & withPaymentDayCounter(const DayCounter &)
NonStandardYoYInflationLeg & withGearings(Real gearing)
NonStandardYoYInflationLeg & withNotionals(Real notional)
NonStandardYoYInflationLeg & withObservationInterpolation(QuantLib::CPI::InterpolationType interpolation)
NonStandardYoYInflationLeg & withInflationNotional(bool addInflationNotional_)
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)...