34 const ext::shared_ptr<SwapIndex>& swapIndex,
35 const ext::shared_ptr<IborIndex>& iborIndex,
37 const Period& forwardStart)
38 : swapTenor_(swapTenor), swapIndex_(swapIndex), iborIndex_(iborIndex), iborSpread_(iborSpread),
39 useAtmSpread_(false), forwardStart_(forwardStart),
41 cmsSpread_(0.0), cmsGearing_(1.0), cmsCap_(
Null<
Real>()), cmsFloor_(
Null<
Real>()),
44 cmsCalendar_(swapIndex->fixingCalendar()), floatCalendar_(iborIndex->fixingCalendar()),
45 payCms_(true), nominal_(1.0), cmsTenor_(3 *
Months), floatTenor_(iborIndex->tenor()),
47 floatConvention_(iborIndex->businessDayConvention()),
48 floatTerminationDateConvention_(iborIndex->businessDayConvention()),
50 cmsEndOfMonth_(false), floatEndOfMonth_(false),
52 cmsDayCount_(
Actual360()), floatDayCount_(iborIndex->dayCounter()),
59 const ext::shared_ptr<SwapIndex>& swapIndex,
61 const Period& forwardStart)
62 : swapTenor_(swapTenor), swapIndex_(swapIndex), iborIndex_(swapIndex->iborIndex()),
63 iborSpread_(iborSpread), useAtmSpread_(false), forwardStart_(forwardStart),
65 cmsSpread_(0.0), cmsGearing_(1.0), cmsCap_(
Null<
Real>()), cmsFloor_(
Null<
Real>()),
68 cmsCalendar_(swapIndex->fixingCalendar()), floatCalendar_(iborIndex_->fixingCalendar()),
69 payCms_(true), nominal_(1.0), cmsTenor_(3 *
Months), floatTenor_(iborIndex_->tenor()),
71 floatConvention_(iborIndex_->businessDayConvention()),
72 floatTerminationDateConvention_(iborIndex_->businessDayConvention()),
74 cmsEndOfMonth_(false), floatEndOfMonth_(false),
76 cmsDayCount_(
Actual360()), floatDayCount_(iborIndex_->dayCounter()),
80 MakeCms::operator
Swap()
const {
81 ext::shared_ptr<Swap>
swap = *
this;
85 MakeCms::operator ext::shared_ptr<Swap>()
const {
88 if (effectiveDate_ !=
Date())
89 startDate = effectiveDate_;
91 Natural fixingDays = iborIndex_->fixingDays();
95 refDate = floatCalendar_.adjust(refDate);
98 startDate = spotDate+forwardStart_;
101 Date terminationDate = startDate+swapTenor_;
103 Schedule cmsSchedule(startDate, terminationDate,
104 cmsTenor_, cmsCalendar_,
106 cmsTerminationDateConvention_,
107 cmsRule_, cmsEndOfMonth_,
108 cmsFirstDate_, cmsNextToLastDate_);
110 Schedule floatSchedule(startDate, terminationDate,
111 floatTenor_, floatCalendar_,
113 floatTerminationDateConvention_,
114 floatRule_ , floatEndOfMonth_,
115 floatFirstDate_, floatNextToLastDate_);
117 Leg cmsLeg =
CmsLeg(cmsSchedule, swapIndex_)
126 if (couponPricer_ !=
nullptr)
129 Rate usedSpread = iborSpread_;
131 QL_REQUIRE(!iborIndex_->forwardingTermStructure().empty(),
132 "null term structure set to this instance of " <<
134 QL_REQUIRE(!swapIndex_->forwardingTermStructure().empty(),
135 "null term structure set to this instance of " <<
138 "no CmsCouponPricer set (yet)");
139 Leg floatLeg =
IborLeg(floatSchedule, iborIndex_)
145 Swap temp(cmsLeg, floatLeg);
150 usedSpread = -npv/temp.
legBPS(1)*1e-4;
156 Leg floatLeg =
IborLeg(floatSchedule, iborIndex_)
163 ext::shared_ptr<Swap>
swap;
165 swap = ext::make_shared<Swap>(cmsLeg, floatLeg);
167 swap = ext::make_shared<Swap>(floatLeg, cmsLeg);
190 engine_ = ext::make_shared<DiscountingSwapEngine>(discountingTermStructure);
195 const ext::shared_ptr<CmsCouponPricer>& couponPricer) {
Cash-flow analysis functions.
ext::shared_ptr< PricingEngine > engine_
Actual/360 day count convention.
helper class building a sequence of capped/floored cms-rate coupons
CmsLeg & withFloors(Rate floor)
CmsLeg & withCaps(Rate cap)
CmsLeg & withGearings(Real gearing)
CmsLeg & withSpreads(Spread spread)
CmsLeg & withPaymentDayCounter(const DayCounter &)
CmsLeg & withNotionals(Real notional)
CmsLeg & withPaymentAdjustment(BusinessDayConvention)
CmsLeg & withFixingDays(Natural fixingDays)
static Date advance(const Date &d, Integer units, TimeUnit)
Discounting engine for swaps.
Shared handle to an observable.
helper class building a sequence of capped/floored ibor-rate coupons
IborLeg & withSpreads(Spread spread)
IborLeg & withPaymentAdjustment(BusinessDayConvention)
IborLeg & withPaymentDayCounter(const DayCounter &)
IborLeg & withNotionals(Real notional)
IborLeg & withFixingDays(Natural fixingDays)
void setPricingEngine(const ext::shared_ptr< PricingEngine > &)
set the pricing engine to be used.
helper class for instantiating CMS
MakeCms & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountingTermStructure)
BusinessDayConvention cmsTerminationDateConvention_
MakeCms & withNominal(Real n)
MakeCms & withCmsLegEndOfMonth(bool flag=true)
ext::shared_ptr< CmsCouponPricer > couponPricer_
Date floatNextToLastDate_
MakeCms & withCmsLegNextToLastDate(const Date &d)
DateGeneration::Rule floatRule_
MakeCms & withFloatingLegDayCount(const DayCounter &dc)
DayCounter floatDayCount_
MakeCms & withCmsLegRule(DateGeneration::Rule r)
MakeCms & withFloatingLegConvention(BusinessDayConvention bdc)
MakeCms & withFloatingLegRule(DateGeneration::Rule r)
MakeCms & withCmsLegConvention(BusinessDayConvention bdc)
BusinessDayConvention floatTerminationDateConvention_
MakeCms & withCmsLegCalendar(const Calendar &cal)
MakeCms & withCmsLegDayCount(const DayCounter &dc)
MakeCms & withFloatingLegTenor(const Period &t)
MakeCms & withEffectiveDate(const Date &)
ext::shared_ptr< PricingEngine > engine_
MakeCms & receiveCms(bool flag=true)
MakeCms & withCmsLegTerminationDateConvention(BusinessDayConvention)
MakeCms(const Period &swapTenor, const ext::shared_ptr< SwapIndex > &swapIndex, const ext::shared_ptr< IborIndex > &iborIndex, Spread iborSpread=0.0, const Period &forwardStart=0 *Days)
MakeCms & withFloatingLegNextToLastDate(const Date &d)
MakeCms & withCmsLegFirstDate(const Date &d)
MakeCms & withFloatingLegFirstDate(const Date &d)
BusinessDayConvention floatConvention_
MakeCms & withCmsCouponPricer(const ext::shared_ptr< CmsCouponPricer > &couponPricer)
MakeCms & withAtmSpread(bool flag=true)
MakeCms & withFloatingLegTerminationDateConvention(BusinessDayConvention bdc)
MakeCms & withCmsLegTenor(const Period &t)
DateGeneration::Rule cmsRule_
BusinessDayConvention cmsConvention_
MakeCms & withFloatingLegEndOfMonth(bool flag=true)
MakeCms & withFloatingLegCalendar(const Calendar &cal)
template class providing a null value for a given type.
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
Real legBPS(Size j) const
Real legNPV(Size j) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
BusinessDayConvention
Business Day conventions.
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates
Coupon paying a Libor-type index.
base class for Inter-Bank-Offered-Rate indexes
Helper class to instantiate standard market CMS.
void swap(Array &v, Array &w) noexcept
void setCouponPricer(const Leg &leg, const ext::shared_ptr< FloatingRateCouponPricer > &pricer)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
ext::shared_ptr< YieldTermStructure > r