19#include <ql/cashflows/floatingratecoupon.hpp>
20#include <ql/cashflows/iborcoupon.hpp>
21#include <ql/instruments/makevanillaswap.hpp>
22#include <ql/utilities/null_deleter.hpp>
29 Frequency longFixedFrequency, BusinessDayConvention longFixedConvention,
30 const DayCounter& longFixedDayCount,
31 const QuantLib::ext::shared_ptr<IborIndex>& longIndex,
33 Frequency shortFixedFrequency, BusinessDayConvention shortFixedConvention,
34 const DayCounter& shortFixedDayCount,
35 const QuantLib::ext::shared_ptr<IborIndex>& shortIndex,
bool longMinusShort,
37 const Handle<YieldTermStructure>& discountingCurve)
39 longFixedFrequency_(longFixedFrequency), longFixedConvention_(longFixedConvention),
40 longFixedDayCount_(longFixedDayCount), longIndex_(longIndex), shortFixedFrequency_(shortFixedFrequency),
41 shortFixedConvention_(shortFixedConvention), shortFixedDayCount_(shortFixedDayCount), shortIndex_(shortIndex),
42 longMinusShort_(longMinusShort), discountHandle_(discountingCurve) {
45 "Tenor of longIndex should be at least tenor of shortIndex.");
47 bool longIndexHasCurve = !
longIndex_->forwardingTermStructure().empty();
48 bool shortIndexHasCurve = !
shortIndex_->forwardingTermStructure().empty();
50 QL_REQUIRE(!(longIndexHasCurve && shortIndexHasCurve && haveDiscountCurve),
51 "Have all curves nothing to solve for.");
53 if (longIndexHasCurve && !shortIndexHasCurve) {
56 }
else if (!longIndexHasCurve && shortIndexHasCurve) {
59 }
else if (!longIndexHasCurve && !shortIndexHasCurve) {
60 QL_FAIL(
"Need at least one of the indices to have a valid curve.");
98 if (!IborCoupon::Settings::instance().usingAtParCoupons()) {
100 QuantLib::ext::shared_ptr<FloatingRateCoupon> lastFloating =
101 QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(
shortSwap_->floatingLeg().back());
102 Date fixingValueDate =
shortIndex_->valueDate(lastFloating->fixingDate());
103 Date endValueDate =
shortIndex_->maturityDate(fixingValueDate);
104 latestDate_ = std::max(latestDate_, endValueDate);
107 QuantLib::ext::shared_ptr<FloatingRateCoupon> lastFloating =
108 QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(
longSwap_->floatingLeg().back());
109 Date fixingValueDate =
longIndex_->valueDate(lastFloating->fixingDate());
110 Date endValueDate =
longIndex_->maturityDate(fixingValueDate);
111 latestDate_ = std::max(latestDate_, endValueDate);
118 bool observer =
false;
120 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
128 RelativeDateRateHelper::setTermStructure(t);
132 QL_REQUIRE(termStructure_ != 0,
"Termstructure not set");
142 Visitor<BasisTwoSwapHelper>* v1 =
dynamic_cast<Visitor<BasisTwoSwapHelper>*
>(&v);
146 RateHelper::accept(v);
Libor basis swap helper as two swaps.
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
void setTermStructure(YieldTermStructure *) override
BasisTwoSwapHelper(const Handle< Quote > &spread, const Period &swapTenor, const Calendar &calendar, Frequency longFixedFrequency, BusinessDayConvention longFixedConvention, const DayCounter &longFixedDayCount, const QuantLib::ext::shared_ptr< IborIndex > &longIndex, Frequency shortFixedFrequency, BusinessDayConvention shortFixedConvention, const DayCounter &shortFixedDayCount, const QuantLib::ext::shared_ptr< IborIndex > &shortIndex, bool longMinusShort=true, const Handle< YieldTermStructure > &discountingCurve=Handle< YieldTermStructure >())
RelinkableHandle< YieldTermStructure > termStructureHandle_
BusinessDayConvention longFixedConvention_
QuantLib::ext::shared_ptr< VanillaSwap > longSwap_
Handle< YieldTermStructure > discountHandle_
DayCounter longFixedDayCount_
void accept(AcyclicVisitor &) override
QuantLib::ext::shared_ptr< VanillaSwap > shortSwap_
BusinessDayConvention shortFixedConvention_
void initializeDates() override
Frequency shortFixedFrequency_
Real impliedQuote() const override
QuantLib::ext::shared_ptr< IborIndex > shortIndex_
DayCounter shortFixedDayCount_
QuantLib::ext::shared_ptr< IborIndex > longIndex_
Frequency longFixedFrequency_