QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
capflooredinflationcoupon.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) 2009 Chris Kenyon
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 <http://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 capflooredinflationcoupon.hpp
21 \brief caplet and floorlet pricing for YoY inflation coupons
22 */
23
24#ifndef quantlib_capfloored_inflation_coupon_hpp
25#define quantlib_capfloored_inflation_coupon_hpp
26
28
29namespace QuantLib {
30
31 //! Capped or floored inflation coupon.
32 /*! Essentially a copy of the nominal version but taking a
33 different index and a set of pricers (not just one).
34
35 The payoff \f$ P \f$ of a capped inflation-rate coupon
36 with paysWithin = true is:
37
38 \f[ P = N \times T \times \min(a L + b, C). \f]
39
40 where \f$ N \f$ is the notional, \f$ T \f$ is the accrual
41 time, \f$ L \f$ is the inflation rate, \f$ a \f$ is its
42 gearing, \f$ b \f$ is the spread, and \f$ C \f$ and \f$ F \f$
43 the strikes.
44
45 The payoff of a floored inflation-rate coupon is:
46
47 \f[ P = N \times T \times \max(a L + b, F). \f]
48
49 The payoff of a collared inflation-rate coupon is:
50
51 \f[ P = N \times T \times \min(\max(a L + b, F), C). \f]
52
53 If paysWithin = false then the inverse is returned
54 (this provides for instrument cap and caplet prices).
55
56 They can be decomposed in the following manner. Decomposition
57 of a capped floating rate coupon when paysWithin = true:
58 \f[
59 R = \min(a L + b, C) = (a L + b) + \min(C - b - \xi |a| L, 0)
60 \f]
61 where \f$ \xi = sgn(a) \f$. Then:
62 \f[
63 R = (a L + b) + |a| \min(\frac{C - b}{|a|} - \xi L, 0)
64 \f]
65 */
67 public:
68 // we may watch an underlying coupon ...
70 const ext::shared_ptr<YoYInflationCoupon>& underlying,
73
74 // ... or not
77 const Date& startDate,
78 const Date& endDate,
80 const ext::shared_ptr<YoYInflationIndex>& index,
83 Real gearing = 1.0,
84 Spread spread = 0.0,
85 const Rate cap = Null<Rate>(),
86 const Rate floor = Null<Rate>(),
87 const Date& refPeriodStart = Date(),
88 const Date& refPeriodEnd = Date())
89 : YoYInflationCoupon(paymentDate, nominal, startDate, endDate,
91 gearing, spread, refPeriodStart, refPeriodEnd),
92 isFloored_(false), isCapped_(false) {
94 }
95
96 //! \name augmented Coupon interface
97 //@{
98 //! swap(let) rate
99 Rate rate() const override;
100 //! cap
101 Rate cap() const;
102 //! floor
103 Rate floor() const;
104 //! effective cap of fixing
105 Rate effectiveCap() const;
106 //! effective floor of fixing
107 Rate effectiveFloor() const;
108 //@}
109
110 //! \name Observer interface
111 //@{
112 void update() override;
113 //@}
114
115 //! \name Visitability
116 //@{
117 void accept(AcyclicVisitor& v) override;
118 //@}
119
120 //! this returns the expected rate before cap and floor are applied
121 Rate underlyingRate() const;
122
123 bool isCapped() const { return isCapped_; }
124 bool isFloored() const { return isFloored_; }
125
126 void setPricer(const ext::shared_ptr<YoYInflationCouponPricer>&);
127
128 protected:
129 // data, we only use underlying_ if it was constructed that way,
130 // generally we use the shared_ptr conversion to boolean to test
131 ext::shared_ptr<YoYInflationCoupon> underlying_;
134 private:
135 void setCommon(Rate cap, Rate floor);
136 };
137
138}
139
140#endif
141
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
ext::shared_ptr< YoYInflationCoupon > underlying_
void setPricer(const ext::shared_ptr< YoYInflationCouponPricer > &)
Rate effectiveCap() const
effective cap of fixing
Rate underlyingRate() const
this returns the expected rate before cap and floor are applied
Rate effectiveFloor() const
effective floor of fixing
CappedFlooredYoYInflationCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< YoYInflationIndex > &index, const Period &observationLag, const DayCounter &dayCounter, Real gearing=1.0, Spread spread=0.0, const Rate cap=Null< Rate >(), const Rate floor=Null< Rate >(), const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date())
virtual Real nominal() const
Definition: coupon.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Natural fixingDays() const
fixing days
Period observationLag() const
how the coupon observes the index
DayCounter dayCounter() const override
day counter for accrual calculation
const ext::shared_ptr< InflationIndex > & index() const
yoy inflation index
template class providing a null value for a given type.
Definition: null.hpp:76
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
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v
Coupon paying a yoy inflation index.