19#include <ql/cashflows/capflooredcoupon.hpp>
20#include <ql/cashflows/cashflowvectors.hpp>
28 const Date& startDate,
31 const ext::shared_ptr<ConstantMaturityBondIndex>& bondIndex,
34 const Date& refPeriodStart,
35 const Date& refPeriodEnd,
36 const DayCounter& dayCounter,
38 const Date& exCouponDate)
40 fixingDays, bondIndex, gearing, spread,
41 refPeriodStart, refPeriodEnd,
42 dayCounter, isInArrears, exCouponDate),
43 bondIndex_(bondIndex) {
48 auto* v1 =
dynamic_cast<Visitor<CmbCoupon>*
>(&v);
52 FloatingRateCoupon::accept(v);
57 QL_REQUIRE(
coupon_,
"CmbCouponPricer: expected CmbCoupon");
89 FloatingRateCoupon::setPricer(pricer);
92CmbLeg::CmbLeg(Schedule schedule, std::vector<ext::shared_ptr<ConstantMaturityBondIndex>> bondIndices)
93 : schedule_(std::move(schedule)), bondIndices_(bondIndices),
94 paymentAdjustment_(Following), inArrears_(false), zeroPayments_(false) {
96 <<
schedule_.size() <<
") and bond indices ("
131 gearings_ = std::vector<Real>(1, gearing);
141 spreads_ = std::vector<Spread>(1, spread);
151 caps_ = std::vector<Rate>(1, cap);
161 floors_ = std::vector<Rate>(1, floor);
187 BusinessDayConvention convention,
196CmbLeg::operator Leg()
const {
198 for (Size i = 0; i < schedule_.size() - 1; i++) {
199 Date paymentDate = paymentCalendar_.adjust(schedule_[i + 1], paymentAdjustment_);
200 QuantLib::ext::shared_ptr<CmbCoupon> coupon
201 = QuantLib::ext::make_shared<CmbCoupon>(paymentDate, notionals_[i], schedule_[i], schedule_[i + 1],
202 fixingDays_[i], bondIndices_[i], gearings_[i], spreads_[i], Date(), Date(),
203 paymentDayCounter_, inArrears_);
204 auto pricer = QuantLib::ext::make_shared<CmbCouponPricer>();
205 coupon->setPricer(pricer);
206 leg.push_back(coupon);
const ext::shared_ptr< ConstantMaturityBondIndex > & bondIndex() const
CmbCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< ConstantMaturityBondIndex > &index, Real gearing=1.0, Spread spread=0.0, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const DayCounter &dayCounter=DayCounter(), bool isInArrears=false, const Date &exCouponDate=Date())
void accept(AcyclicVisitor &) override
ext::shared_ptr< ConstantMaturityBondIndex > bondIndex_
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &pricer) override
Real capletPrice(Rate effectiveCap) const override
Rate floorletRate(Rate effectiveFloor) const override
ext::shared_ptr< ConstantMaturityBondIndex > index_
void initialize(const FloatingRateCoupon &coupon) override
const CmbCoupon * coupon_
Rate swapletRate() const override
Real floorletPrice(Rate effectiveFloor) const override
Real swapletPrice() const override
Rate capletRate(Rate effectiveCap) const override
helper class building a sequence of capped/floored cmb coupons
BusinessDayConvention paymentAdjustment_
std::vector< Rate > caps_
std::vector< ext::shared_ptr< ConstantMaturityBondIndex > > bondIndices_
BusinessDayConvention exCouponAdjustment_
CmbLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth)
Calendar paymentCalendar_
CmbLeg & withNotionals(Real notional)
CmbLeg & withGearings(Real gearing)
CmbLeg(Schedule schedule, std::vector< ext::shared_ptr< ConstantMaturityBondIndex > > bondIndices)
CmbLeg & withFixingDays(Natural fixingDays)
std::vector< Real > notionals_
std::vector< Spread > spreads_
CmbLeg & withFloors(Rate floor)
CmbLeg & withPaymentAdjustment(BusinessDayConvention)
std::vector< Natural > fixingDays_
Calendar exCouponCalendar_
std::vector< Rate > floors_
CmbLeg & withZeroPayments(bool flag=true)
CmbLeg & withSpreads(Spread spread)
CmbLeg & withPaymentCalendar(const Calendar &cal)
CmbLeg & inArrears(bool flag=true)
CmbLeg & withPaymentDayCounter(const DayCounter &)
CmbLeg & withCaps(Rate cap)
std::vector< Real > gearings_
DayCounter paymentDayCounter_
Constant Maturity Bond yield coupon.