QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cmscoupon.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 Giorgio Facchinetti
3 Copyright (C) 2006 Mario Pucci
4 Copyright (C) 2006, 2007 StatPro Italia srl
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
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */
19
20/*! \file cmscoupon.hpp
21 \brief CMS coupon
22*/
23
24#ifndef quantlib_cms_coupon_hpp
25#define quantlib_cms_coupon_hpp
26
28#include <ql/time/schedule.hpp>
29
30namespace QuantLib {
31
32 class SwapIndex;
33
34 //! CMS coupon class
35 /*! \warning This class does not perform any date adjustment,
36 i.e., the start and end date passed upon construction
37 should be already rolled to a business day.
38 */
40 public:
41 CmsCoupon(const Date& paymentDate,
43 const Date& startDate,
44 const Date& endDate,
46 const ext::shared_ptr<SwapIndex>& index,
47 Real gearing = 1.0,
48 Spread spread = 0.0,
49 const Date& refPeriodStart = Date(),
50 const Date& refPeriodEnd = Date(),
52 bool isInArrears = false,
53 const Date& exCouponDate = Date());
54 //! \name Inspectors
55 //@{
56 const ext::shared_ptr<SwapIndex>& swapIndex() const {
57 return swapIndex_;
58 }
59 //@}
60 //! \name Visitability
61 //@{
62 void accept(AcyclicVisitor&) override;
63 //@}
64 private:
65 ext::shared_ptr<SwapIndex> swapIndex_;
66 };
67
68
69 //! helper class building a sequence of capped/floored cms-rate coupons
70 class CmsLeg {
71 public:
72 CmsLeg(Schedule schedule, ext::shared_ptr<SwapIndex> swapIndex);
73 CmsLeg& withNotionals(Real notional);
74 CmsLeg& withNotionals(const std::vector<Real>& notionals);
77 CmsLeg& withFixingDays(Natural fixingDays);
78 CmsLeg& withFixingDays(const std::vector<Natural>& fixingDays);
79 CmsLeg& withGearings(Real gearing);
80 CmsLeg& withGearings(const std::vector<Real>& gearings);
81 CmsLeg& withSpreads(Spread spread);
82 CmsLeg& withSpreads(const std::vector<Spread>& spreads);
83 CmsLeg& withCaps(Rate cap);
84 CmsLeg& withCaps(const std::vector<Rate>& caps);
85 CmsLeg& withFloors(Rate floor);
86 CmsLeg& withFloors(const std::vector<Rate>& floors);
87 CmsLeg& inArrears(bool flag = true);
88 CmsLeg& withZeroPayments(bool flag = true);
90 const Calendar&,
92 bool endOfMonth);
93 operator Leg() const;
94 private:
96 ext::shared_ptr<SwapIndex> swapIndex_;
97 std::vector<Real> notionals_;
100 std::vector<Natural> fixingDays_;
101 std::vector<Real> gearings_;
102 std::vector<Spread> spreads_;
103 std::vector<Rate> caps_, floors_;
104 bool inArrears_ = false, zeroPayments_ = false;
109 };
110
111}
112
113#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
CMS coupon class.
Definition: cmscoupon.hpp:39
const ext::shared_ptr< SwapIndex > & swapIndex() const
Definition: cmscoupon.hpp:56
ext::shared_ptr< SwapIndex > swapIndex_
Definition: cmscoupon.hpp:65
void accept(AcyclicVisitor &) override
Definition: cmscoupon.cpp:48
helper class building a sequence of capped/floored cms-rate coupons
Definition: cmscoupon.hpp:70
Schedule schedule_
Definition: cmscoupon.hpp:95
BusinessDayConvention paymentAdjustment_
Definition: cmscoupon.hpp:99
std::vector< Rate > caps_
Definition: cmscoupon.hpp:103
BusinessDayConvention exCouponAdjustment_
Definition: cmscoupon.hpp:107
CmsLeg & withFloors(Rate floor)
Definition: cmscoupon.cpp:122
CmsLeg & withCaps(Rate cap)
Definition: cmscoupon.cpp:112
CmsLeg & withGearings(Real gearing)
Definition: cmscoupon.cpp:92
ext::shared_ptr< SwapIndex > swapIndex_
Definition: cmscoupon.hpp:96
std::vector< Real > notionals_
Definition: cmscoupon.hpp:97
std::vector< Spread > spreads_
Definition: cmscoupon.hpp:102
CmsLeg & withSpreads(Spread spread)
Definition: cmscoupon.cpp:102
CmsLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth)
Definition: cmscoupon.cpp:142
CmsLeg & withPaymentDayCounter(const DayCounter &)
Definition: cmscoupon.cpp:72
CmsLeg & inArrears(bool flag=true)
Definition: cmscoupon.cpp:132
bool exCouponEndOfMonth_
Definition: cmscoupon.hpp:108
CmsLeg & withZeroPayments(bool flag=true)
Definition: cmscoupon.cpp:137
std::vector< Natural > fixingDays_
Definition: cmscoupon.hpp:100
CmsLeg & withNotionals(Real notional)
Definition: cmscoupon.cpp:62
Period exCouponPeriod_
Definition: cmscoupon.hpp:105
Calendar exCouponCalendar_
Definition: cmscoupon.hpp:106
std::vector< Rate > floors_
Definition: cmscoupon.hpp:103
CmsLeg & withPaymentAdjustment(BusinessDayConvention)
Definition: cmscoupon.cpp:77
CmsLeg & withFixingDays(Natural fixingDays)
Definition: cmscoupon.cpp:82
std::vector< Real > gearings_
Definition: cmscoupon.hpp:101
DayCounter paymentDayCounter_
Definition: cmscoupon.hpp:98
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
Payment schedule.
Definition: schedule.hpp:40
Coupon paying a variable index-based rate.
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
date schedule