QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
capflooredcoupon.hpp
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
25#ifndef quantlib_capped_floored_coupon_hpp
26#define quantlib_capped_floored_coupon_hpp
27
28#include <ql/cashflows/iborcoupon.hpp>
29#include <ql/cashflows/cmscoupon.hpp>
30#include <ql/utilities/null.hpp>
31
32namespace QuantLib {
33 class Date;
35
58 public:
60 const ext::shared_ptr<FloatingRateCoupon>& underlying,
64
65 void deepUpdate() override;
67
69 void performCalculations() const override;
71
73 Rate rate() const override;
74 Rate convexityAdjustment() const override;
76
77 Rate cap() const;
79 Rate floor() const;
81 Rate effectiveCap() const;
83 Rate effectiveFloor() const;
85
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
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