29#include <ql/experimental/coupons/strippedcapflooredcoupon.hpp>
39 const QuantLib::Date& openEndDateReplacement,
40 const bool useXbsCurves)
const {
42 auto cmsData = QuantLib::ext::dynamic_pointer_cast<DurationAdjustedCmsLegData>(
data.concreteLegData());
43 QL_REQUIRE(cmsData,
"Wrong LegType, expected CMS");
45 string indexName = cmsData->swapIndex();
46 auto index = *engineFactory->market()->swapIndex(indexName, configuration);
51 vector<double> spreads =
53 vector<double> gearings =
56 Size fixingDays = cmsData->fixingDays() == Null<Size>() ? index->fixingDays() : cmsData->fixingDays();
71 if (!
data.paymentCalendar().empty())
74 if (cmsData->caps().size() > 0)
77 if (cmsData->floors().size() > 0)
81 auto builder = QuantLib::ext::dynamic_pointer_cast<DurationAdjustedCmsCouponPricerBuilder>(
82 engineFactory->builder(
"DurationAdjustedCMS"));
83 QL_REQUIRE(builder !=
nullptr,
"No builder found for DurationAdjustedCmsLeg");
84 auto couponPricer = builder->engine(IndexNameTranslator::instance().oreName(index->iborIndex()->name()));
88 for (
auto& c : result) {
89 auto f = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c);
90 QL_REQUIRE(f !=
nullptr,
91 "DurationAdjustedCmsLegBuilder::buildLeg(): internal error, expected FloatingRateCoupon");
92 f->setPricer(couponPricer);
96 if (cmsData->nakedOption()) {
97 result = StrippedCappedFlooredCouponLeg(result);
100 applyIndexing(result,
data, engineFactory, requiredFixings, openEndDateReplacement, useXbsCurves);
DurationAdjustedCmsLeg & withPaymentCalendar(const Calendar &)
DurationAdjustedCmsLeg & withPaymentAdjustment(BusinessDayConvention)
DurationAdjustedCmsLeg & withSpreads(Spread spread)
DurationAdjustedCmsLeg & withFixingDays(Natural fixingDays)
DurationAdjustedCmsLeg & withPaymentLag(Natural lag)
DurationAdjustedCmsLeg & withFloors(Rate floor)
DurationAdjustedCmsLeg & withNotionals(Real notional)
DurationAdjustedCmsLeg & withGearings(Real gearing)
DurationAdjustedCmsLeg & withPaymentDayCounter(const DayCounter &)
DurationAdjustedCmsLeg & inArrears(bool flag=true)
DurationAdjustedCmsLeg & withCaps(Rate cap)
QuantLib::Leg buildLeg(const ore::data::LegData &data, const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, ore::data::RequiredFixings &requiredFixings, const std::string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const override
Serializable object holding leg data.
coupon pricer builder for duration adjusted cms coupons
leg builder for duration adjusted cms coupon legs
leg data for duration adjusted cms
Logic for calculating required fixing dates on legs.
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
PaymentLag parsePaymentLag(const string &s)
Convert text to PaymentLag.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
translates between QuantLib::Index::name() and ORE names
leg data model and serialization
vector< T > buildScheduledVectorNormalised(const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const T &defaultValue, const bool checkAllValuesAppearInResult=false)
void applyAmortization(std::vector< Real > ¬ionals, const LegData &data, const Schedule &schedule, const bool annuityAllowed, const std::vector< Real > &rates)
void applyIndexing(Leg &leg, const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const QuantLib::Date &openEndDateReplacement, const bool useXbsCurves)
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
vector< T > buildScheduledVector(const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const bool checkAllValuesAppearInResult=false)
boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
Schedule makeSchedule(const ScheduleDates &data)
Serializable Credit Default Swap.