QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
capflooredcoupon.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) 2006, 2007 StatPro Italia srl
5 Copyright (C) 2006 Cristina Duminuco
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file capflooredcoupon.hpp
22 \brief Floating rate coupon with additional cap/floor
23*/
24
25#ifndef quantlib_capped_floored_coupon_hpp
26#define quantlib_capped_floored_coupon_hpp
27
30#include <ql/utilities/null.hpp>
31
32namespace QuantLib {
33 class Date;
34 //! Capped and/or floored floating-rate coupon
35 /*! The payoff \f$ P \f$ of a capped floating-rate coupon is:
36 \f[ P = N \times T \times \min(a L + b, C). \f]
37 The payoff of a floored floating-rate coupon is:
38 \f[ P = N \times T \times \max(a L + b, F). \f]
39 The payoff of a collared floating-rate coupon is:
40 \f[ P = N \times T \times \min(\max(a L + b, F), C). \f]
41
42 where \f$ N \f$ is the notional, \f$ T \f$ is the accrual
43 time, \f$ L \f$ is the floating rate, \f$ a \f$ is its
44 gearing, \f$ b \f$ is the spread, and \f$ C \f$ and \f$ F \f$
45 the strikes.
46
47 They can be decomposed in the following manner.
48 Decomposition of a capped floating rate coupon:
49 \f[
50 R = \min(a L + b, C) = (a L + b) + \min(C - b - \xi |a| L, 0)
51 \f]
52 where \f$ \xi = sgn(a) \f$. Then:
53 \f[
54 R = (a L + b) + |a| \min(\frac{C - b}{|a|} - \xi L, 0)
55 \f]
56 */
58 public:
60 const ext::shared_ptr<FloatingRateCoupon>& underlying,
63 //! \name Observer interface
64 //@{
65 void deepUpdate() override;
66 //@}
67 //! \name LazyObject interface
68 //@{
69 void performCalculations() const override;
70 //@}
71 //! \name Coupon interface
72 //@{
73 Rate rate() const override;
74 Rate convexityAdjustment() const override;
75 //@}
76 //! cap
77 Rate cap() const;
78 //! floor
79 Rate floor() const;
80 //! effective cap of fixing
81 Rate effectiveCap() const;
82 //! effective floor of fixing
83 Rate effectiveFloor() const;
84 //@}
85 //! \name Visitability
86 //@{
87 void accept(AcyclicVisitor&) override;
88
89 bool isCapped() const {return isCapped_;}
90 bool isFloored() const {return isFloored_;}
91
92 void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& pricer) override;
93
94 ext::shared_ptr<FloatingRateCoupon> underlying() { return underlying_; }
95
96 protected:
97 // data
98 ext::shared_ptr<FloatingRateCoupon> underlying_;
99 bool isCapped_ = false, isFloored_ = false;
101 };
102
104 public:
106 const Date& paymentDate,
108 const Date& startDate,
109 const Date& endDate,
111 const ext::shared_ptr<IborIndex>& index,
112 Real gearing = 1.0,
113 Spread spread = 0.0,
114 Rate cap = Null<Rate>(),
116 const Date& refPeriodStart = Date(),
117 const Date& refPeriodEnd = Date(),
119 bool isInArrears = false,
120 const Date& exCouponDate = Date())
121 : CappedFlooredCoupon(ext::shared_ptr<FloatingRateCoupon>(new
122 IborCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
123 index, gearing, spread, refPeriodStart, refPeriodEnd,
125
126 void accept(AcyclicVisitor& v) override {
127 auto* v1 = dynamic_cast<Visitor<CappedFlooredIborCoupon>*>(&v);
128 if (v1 != nullptr)
129 v1->visit(*this);
130 else
132 }
133 };
134
136 public:
138 const Date& paymentDate,
140 const Date& startDate,
141 const Date& endDate,
143 const ext::shared_ptr<SwapIndex>& index,
144 Real gearing = 1.0,
145 Spread spread= 0.0,
146 const Rate cap = Null<Rate>(),
147 const Rate floor = Null<Rate>(),
148 const Date& refPeriodStart = Date(),
149 const Date& refPeriodEnd = Date(),
151 bool isInArrears = false,
152 const Date& exCouponDate = Date())
153 : CappedFlooredCoupon(ext::shared_ptr<FloatingRateCoupon>(new
154 CmsCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
155 index, gearing, spread, refPeriodStart, refPeriodEnd,
157
158 void accept(AcyclicVisitor& v) override {
159 auto* v1 = dynamic_cast<Visitor<CappedFlooredCmsCoupon>*>(&v);
160 if (v1 != nullptr)
161 v1->visit(*this);
162 else
164 }
165 };
166
167}
168
169#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
CappedFlooredCmsCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< SwapIndex > &index, 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(), const DayCounter &dayCounter=DayCounter(), bool isInArrears=false, const Date &exCouponDate=Date())
void accept(AcyclicVisitor &v) override
Capped and/or floored floating-rate coupon.
void performCalculations() const override
ext::shared_ptr< FloatingRateCoupon > underlying_
Rate rate() const override
accrued rate
void accept(AcyclicVisitor &) override
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &pricer) override
Rate effectiveCap() const
effective cap of fixing
Rate effectiveFloor() const
effective floor of fixing
ext::shared_ptr< FloatingRateCoupon > underlying()
Rate convexityAdjustment() const override
convexity adjustment
CappedFlooredIborCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< IborIndex > &index, Real gearing=1.0, Spread spread=0.0, Rate cap=Null< Rate >(), Rate floor=Null< Rate >(), const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const DayCounter &dayCounter=DayCounter(), bool isInArrears=false, const Date &exCouponDate=Date())
void accept(AcyclicVisitor &v) override
CMS coupon class.
Definition: cmscoupon.hpp:39
Date exCouponDate() const override
returns the date that the cash flow trades exCoupon
Definition: coupon.hpp:57
virtual Real nominal() const
Definition: coupon.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base floating-rate coupon class
Natural fixingDays() const
fixing days
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
DayCounter dayCounter() const override
day counter for accrual calculation
const ext::shared_ptr< InterestRateIndex > & index() const
floating index
ext::shared_ptr< FloatingRateCouponPricer > pricer() const
Spread spread() const
spread paid over the fixing of the underlying index
bool isInArrears() const
whether or not the coupon fixes in arrears
Coupon paying a Libor-type index
Definition: iborcoupon.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:76
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
CMS coupon.
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
Coupon paying a Libor-type index.
Definition: any.hpp:35
null values
ext::shared_ptr< BlackVolTermStructure > v