Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cmbcoupon.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd.
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17 */
18
19/*! \file qle/cashflows/cmbcoupon.hpp
20 \brief Constant Maturity Bond yield coupon
21*/
22
23#ifndef quantext_cmb_coupon_hpp
24#define quantext_cmb_coupon_hpp
25
26#include <ql/cashflows/floatingratecoupon.hpp>
27#include <ql/time/schedule.hpp>
29
30namespace QuantExt {
31
32//! CMB coupon class
34public:
35 CmbCoupon(const Date& paymentDate,
36 Real nominal,
37 const Date& startDate,
38 const Date& endDate,
39 Natural fixingDays,
40 const ext::shared_ptr<ConstantMaturityBondIndex>& index,
41 Real gearing = 1.0,
42 Spread spread = 0.0,
43 const Date& refPeriodStart = Date(),
44 const Date& refPeriodEnd = Date(),
45 const DayCounter& dayCounter = DayCounter(),
46 bool isInArrears = false,
47 const Date& exCouponDate = Date());
48 //! \name Visitability
49 //@{
50 void accept(AcyclicVisitor&) override;
51 //@}
52
53 //! \name Inspectors
54 //@{
55 const ext::shared_ptr<ConstantMaturityBondIndex>& bondIndex() const { return bondIndex_; }
56 //@}
57
58 void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& pricer) override;
59
60private:
61 ext::shared_ptr<ConstantMaturityBondIndex> bondIndex_;
62};
63
64//! Base pricer for vanilla CMB coupons
65/*!
66 \todo: caching of coupon data, timing and convexity adjustment
67 */
68class CmbCouponPricer : public FloatingRateCouponPricer {
69public:
70 explicit CmbCouponPricer() {}
71 void initialize(const FloatingRateCoupon& coupon) override;
72 Real swapletPrice() const override;
73 Rate swapletRate() const override;
74 Real capletPrice(Rate effectiveCap) const override;
75 Rate capletRate(Rate effectiveCap) const override;
76 Real floorletPrice(Rate effectiveFloor) const override;
77 Rate floorletRate(Rate effectiveFloor) const override;
78private:
80 ext::shared_ptr<ConstantMaturityBondIndex> index_;
82 Real spread_;
84};
85
86//! helper class building a sequence of capped/floored cmb coupons
87class CmbLeg {
88public:
89 CmbLeg(Schedule schedule, std::vector<ext::shared_ptr<ConstantMaturityBondIndex>> bondIndices);
90 CmbLeg& withNotionals(Real notional);
91 CmbLeg& withNotionals(const std::vector<Real>& notionals);
92 CmbLeg& withPaymentDayCounter(const DayCounter&);
93 CmbLeg& withPaymentCalendar(const Calendar& cal);
94 CmbLeg& withPaymentAdjustment(BusinessDayConvention);
95 CmbLeg& withFixingDays(Natural fixingDays);
96 CmbLeg& withFixingDays(const std::vector<Natural>& fixingDays);
97 CmbLeg& withGearings(Real gearing);
98 CmbLeg& withGearings(const std::vector<Real>& gearings);
99 CmbLeg& withSpreads(Spread spread);
100 CmbLeg& withSpreads(const std::vector<Spread>& spreads);
101 CmbLeg& withCaps(Rate cap);
102 CmbLeg& withCaps(const std::vector<Rate>& caps);
103 CmbLeg& withFloors(Rate floor);
104 CmbLeg& withFloors(const std::vector<Rate>& floors);
105 CmbLeg& inArrears(bool flag = true);
106 CmbLeg& withZeroPayments(bool flag = true);
107 CmbLeg& withExCouponPeriod(const Period&,
108 const Calendar&,
109 BusinessDayConvention,
110 bool endOfMonth);
111 operator Leg() const;
112private:
113 Schedule schedule_;
114 std::vector<ext::shared_ptr<ConstantMaturityBondIndex>> bondIndices_;
115 std::vector<Real> notionals_;
117 BusinessDayConvention paymentAdjustment_;
119 std::vector<Natural> fixingDays_;
120 std::vector<Real> gearings_;
121 std::vector<Spread> spreads_;
122 std::vector<Rate> caps_, floors_;
126 BusinessDayConvention exCouponAdjustment_;
128};
129
130}
131
132#endif
bond index class representing historical and forward bond prices
CMB coupon class.
Definition: cmbcoupon.hpp:33
const ext::shared_ptr< ConstantMaturityBondIndex > & bondIndex() const
Definition: cmbcoupon.hpp:55
void accept(AcyclicVisitor &) override
Definition: cmbcoupon.cpp:47
ext::shared_ptr< ConstantMaturityBondIndex > bondIndex_
Definition: cmbcoupon.hpp:61
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &pricer) override
Definition: cmbcoupon.cpp:88
Base pricer for vanilla CMB coupons.
Definition: cmbcoupon.hpp:68
Real capletPrice(Rate effectiveCap) const override
Definition: cmbcoupon.cpp:72
Rate floorletRate(Rate effectiveFloor) const override
Definition: cmbcoupon.cpp:84
ext::shared_ptr< ConstantMaturityBondIndex > index_
Definition: cmbcoupon.hpp:80
void initialize(const FloatingRateCoupon &coupon) override
Definition: cmbcoupon.cpp:55
const CmbCoupon * coupon_
Definition: cmbcoupon.hpp:79
Rate swapletRate() const override
Definition: cmbcoupon.cpp:68
Real floorletPrice(Rate effectiveFloor) const override
Definition: cmbcoupon.cpp:80
Real swapletPrice() const override
Definition: cmbcoupon.cpp:64
Rate capletRate(Rate effectiveCap) const override
Definition: cmbcoupon.cpp:76
helper class building a sequence of capped/floored cmb coupons
Definition: cmbcoupon.hpp:87
Schedule schedule_
Definition: cmbcoupon.hpp:113
BusinessDayConvention paymentAdjustment_
Definition: cmbcoupon.hpp:117
std::vector< Rate > caps_
Definition: cmbcoupon.hpp:122
std::vector< ext::shared_ptr< ConstantMaturityBondIndex > > bondIndices_
Definition: cmbcoupon.hpp:114
BusinessDayConvention exCouponAdjustment_
Definition: cmbcoupon.hpp:126
CmbLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth)
Definition: cmbcoupon.cpp:185
Calendar paymentCalendar_
Definition: cmbcoupon.hpp:118
CmbLeg & withNotionals(Real notional)
Definition: cmbcoupon.cpp:100
CmbLeg & withGearings(Real gearing)
Definition: cmbcoupon.cpp:130
CmbLeg & withFixingDays(Natural fixingDays)
Definition: cmbcoupon.cpp:120
std::vector< Real > notionals_
Definition: cmbcoupon.hpp:115
std::vector< Spread > spreads_
Definition: cmbcoupon.hpp:121
CmbLeg & withFloors(Rate floor)
Definition: cmbcoupon.cpp:160
CmbLeg & withPaymentAdjustment(BusinessDayConvention)
Definition: cmbcoupon.cpp:115
bool exCouponEndOfMonth_
Definition: cmbcoupon.hpp:127
std::vector< Natural > fixingDays_
Definition: cmbcoupon.hpp:119
Period exCouponPeriod_
Definition: cmbcoupon.hpp:124
Calendar exCouponCalendar_
Definition: cmbcoupon.hpp:125
std::vector< Rate > floors_
Definition: cmbcoupon.hpp:122
CmbLeg & withZeroPayments(bool flag=true)
Definition: cmbcoupon.cpp:175
CmbLeg & withSpreads(Spread spread)
Definition: cmbcoupon.cpp:140
CmbLeg & withPaymentCalendar(const Calendar &cal)
Definition: cmbcoupon.cpp:180
CmbLeg & inArrears(bool flag=true)
Definition: cmbcoupon.cpp:170
CmbLeg & withPaymentDayCounter(const DayCounter &)
Definition: cmbcoupon.cpp:110
CmbLeg & withCaps(Rate cap)
Definition: cmbcoupon.cpp:150
std::vector< Real > gearings_
Definition: cmbcoupon.hpp:120
DayCounter paymentDayCounter_
Definition: cmbcoupon.hpp:116