19#include <ql/cashflows/iborcoupon.hpp>
20#include <ql/pricingengines/swap/discountingswapengine.hpp>
21#include <ql/utilities/null_deleter.hpp>
27 const Calendar& fixedCalendar,
const DayCounter& fixedDayCount,
28 BusinessDayConvention fixedConvention,
const Period& floatPayTenor,
29 const QuantLib::ext::shared_ptr<IborIndex>& iborIndex,
30 const DayCounter& floatDayCount,
31 const Handle<YieldTermStructure>& discountingCurve,
34 fixedCalendar_(fixedCalendar), fixedDayCount_(fixedDayCount), fixedConvention_(fixedConvention),
35 floatPayTenor_(floatPayTenor), floatDayCount_(floatDayCount), type_(type), discountHandle_(discountingCurve) {
50 Date valuationDate = Settings::instance().evaluationDate();
51 Calendar spotCalendar =
iborIndex_->fixingCalendar();
54 valuationDate = spotCalendar.adjust(valuationDate);
55 Date effectiveDate = spotCalendar.advance(valuationDate, spotDays * Days);
62 swap_->setPricingEngine(engine);
65 earliestDate_ =
swap_->startDate();
66 latestDate_ =
swap_->maturityDate();
68 QuantLib::ext::shared_ptr<FloatingRateCoupon> lastFloating =
69 QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(
swap_->floatLeg().back());
70 if (IborCoupon::Settings::instance().usingAtParCoupons()) {
72 if (QuantLib::ext::dynamic_pointer_cast<QuantExt::SubPeriodsCoupon1>(lastFloating)) {
73 Date fixingValueDate =
iborIndex_->valueDate(lastFloating->fixingDate());
74 Date endValueDate =
iborIndex_->maturityDate(fixingValueDate);
75 latestDate_ = std::max(latestDate_, endValueDate);
80 Date fixingValueDate =
iborIndex_->valueDate(lastFloating->fixingDate());
81 Date endValueDate =
iborIndex_->maturityDate(fixingValueDate);
82 latestDate_ = std::max(latestDate_, endValueDate);
88 bool observer =
false;
90 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
98 RelativeDateRateHelper::setTermStructure(t);
102 QL_REQUIRE(termStructure_ != 0,
"Termstructure not set");
104 return swap_->fairRate();
108 Visitor<SubPeriodsSwapHelper>* v1 =
dynamic_cast<Visitor<SubPeriodsSwapHelper>*
>(&v);
112 RateHelper::accept(v);
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
void setTermStructure(YieldTermStructure *) override
BusinessDayConvention fixedConvention_
RelinkableHandle< YieldTermStructure > termStructureHandle_
DayCounter fixedDayCount_
SubPeriodsSwapHelper(Handle< Quote > spread, const Period &swapTenor, const Period &fixedTenor, const Calendar &fixedCalendar, const DayCounter &fixedDayCount, BusinessDayConvention fixedConvention, const Period &floatPayTenor, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex, const DayCounter &floatDayCount, const Handle< YieldTermStructure > &discountingCurve=Handle< YieldTermStructure >(), QuantExt::SubPeriodsCoupon1::Type type=QuantExt::SubPeriodsCoupon1::Compounding)
DayCounter floatDayCount_
Handle< YieldTermStructure > discountHandle_
void accept(AcyclicVisitor &) override
QuantLib::ext::shared_ptr< SubPeriodsSwap > swap_
void initializeDates() override
Real impliedQuote() const override
QuantExt::SubPeriodsCoupon1::Type type_
QuantLib::ext::shared_ptr< IborIndex > iborIndex_
Single currency sub periods swap.
Single currency sub periods swap helper.