QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cmsspreadcoupon.hpp
1/*
2 Copyright (C) 2014 Peter Caspers
3
4 This file is part of QuantLib, a free-software/open-source library
5 for financial quantitative analysts and developers - http://quantlib.org/
6
7 QuantLib is free software: you can redistribute it and/or modify it
8 under the terms of the QuantLib license. You should have received a
9 copy of the license along with this program; if not, please email
10 <quantlib-dev@lists.sf.net>. The license is also available online at
11 <http://quantlib.org/license.shtml>.
12
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */
17
22#ifndef quantlib_cmsspread_coupon_hpp
23#define quantlib_cmsspread_coupon_hpp
24
25#include <ql/cashflows/capflooredcoupon.hpp>
26#include <ql/cashflows/couponpricer.hpp>
27#include <ql/cashflows/floatingratecoupon.hpp>
28#include <ql/experimental/coupons/swapspreadindex.hpp>
29#include <ql/time/schedule.hpp>
30#include <utility>
31
32namespace QuantLib {
33
34 class SwapIndex;
35
37
42 public:
43 CmsSpreadCoupon(const Date& paymentDate,
45 const Date& startDate,
46 const Date& endDate,
48 const ext::shared_ptr<SwapSpreadIndex>& index,
49 Real gearing = 1.0,
50 Spread spread = 0.0,
51 const Date& refPeriodStart = Date(),
52 const Date& refPeriodEnd = Date(),
54 bool isInArrears = false,
55 const Date& exCouponDate = Date());
57
58 const ext::shared_ptr<SwapSpreadIndex>& swapSpreadIndex() const {
59 return index_;
60 }
62
64 void accept(AcyclicVisitor&) override;
66 private:
67 ext::shared_ptr<SwapSpreadIndex> index_;
68 };
69
71 public:
73 const Date& paymentDate,
75 const Date& startDate,
76 const Date& endDate,
78 const ext::shared_ptr<SwapSpreadIndex>& index,
79 Real gearing = 1.0,
80 Spread spread= 0.0,
81 const Rate cap = Null<Rate>(),
82 const Rate floor = Null<Rate>(),
83 const Date& refPeriodStart = Date(),
84 const Date& refPeriodEnd = Date(),
86 bool isInArrears = false,
87 const Date& exCouponDate = Date())
88 : CappedFlooredCoupon(ext::shared_ptr<FloatingRateCoupon>(new
89 CmsSpreadCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
90 index, gearing, spread, refPeriodStart, refPeriodEnd,
92
93 void accept(AcyclicVisitor& v) override {
94 auto* v1 = dynamic_cast<Visitor<CappedFlooredCmsSpreadCoupon>*>(&v);
95 if (v1 != nullptr)
96 v1->visit(*this);
97 else
99 }
100 };
101
104 public:
105 CmsSpreadLeg(Schedule schedule, ext::shared_ptr<SwapSpreadIndex> swapSpreadIndex);
107 CmsSpreadLeg& withNotionals(const std::vector<Real>& notionals);
111 CmsSpreadLeg& withFixingDays(const std::vector<Natural>& fixingDays);
113 CmsSpreadLeg& withGearings(const std::vector<Real>& gearings);
115 CmsSpreadLeg& withSpreads(const std::vector<Spread>& spreads);
117 CmsSpreadLeg& withCaps(const std::vector<Rate>& caps);
119 CmsSpreadLeg& withFloors(const std::vector<Rate>& floors);
120 CmsSpreadLeg& inArrears(bool flag = true);
121 CmsSpreadLeg& withZeroPayments(bool flag = true);
122 operator Leg() const;
123 private:
125 ext::shared_ptr<SwapSpreadIndex> swapSpreadIndex_;
126 std::vector<Real> notionals_;
129 std::vector<Natural> fixingDays_;
130 std::vector<Real> gearings_;
131 std::vector<Spread> spreads_;
132 std::vector<Rate> caps_, floors_;
133 bool inArrears_ = false, zeroPayments_ = false;
134 };
135
136
139 public:
141 : correlation_(std::move(correlation)) {
143 }
144
146 return correlation_;
147 }
148
154 update();
155 }
156 private:
158 };
159
160}
161
162#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
CappedFlooredCmsSpreadCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< SwapSpreadIndex > &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 accept(AcyclicVisitor &) override
CMS spread coupon class.
const ext::shared_ptr< SwapSpreadIndex > & swapSpreadIndex() const
void accept(AcyclicVisitor &) override
ext::shared_ptr< SwapSpreadIndex > index_
base pricer for vanilla CMS spread coupons
CmsSpreadCouponPricer(Handle< Quote > correlation=Handle< Quote >())
Handle< Quote > correlation() const
void setCorrelation(const Handle< Quote > &correlation=Handle< Quote >())
helper class building a sequence of capped/floored cms-spread-rate coupons
CmsSpreadLeg & withPaymentAdjustment(BusinessDayConvention)
BusinessDayConvention paymentAdjustment_
std::vector< Rate > caps_
CmsSpreadLeg & withSpreads(Spread spread)
ext::shared_ptr< SwapSpreadIndex > swapSpreadIndex_
CmsSpreadLeg & withFloors(Rate floor)
CmsSpreadLeg & withGearings(Real gearing)
CmsSpreadLeg & withCaps(Rate cap)
std::vector< Real > notionals_
CmsSpreadLeg & inArrears(bool flag=true)
std::vector< Spread > spreads_
CmsSpreadLeg & withFixingDays(Natural fixingDays)
CmsSpreadLeg & withPaymentDayCounter(const DayCounter &)
std::vector< Natural > fixingDays_
CmsSpreadLeg & withZeroPayments(bool flag=true)
std::vector< Rate > floors_
std::vector< Real > gearings_
CmsSpreadLeg & withNotionals(Real notional)
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
Spread spread() const
spread paid over the fixing of the underlying index
bool isInArrears() const
whether or not the coupon fixes in arrears
generic pricer for floating-rate coupons
Shared handle to an observable.
Definition: handle.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:76
Size unregisterWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:245
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Payment schedule.
Definition: schedule.hpp:40
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
BusinessDayConvention
Business Day conventions.
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
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
STL namespace.