23#include <boost/make_shared.hpp>
24#include <ql/cashflows/fixedratecoupon.hpp>
25#include <ql/cashflows/iborcoupon.hpp>
26#include <ql/cashflows/simplecashflow.hpp>
33 Real nominal,
const Currency& fixedCurrency,
const Schedule& fixedSchedule,
34 Rate fixedRate,
const DayCounter& fixedDayCount,
const BusinessDayConvention& fixedPaymentBdc,
35 Natural fixedPaymentLag,
const Calendar& fixedPaymentCalendar,
const Currency& floatCurrency,
36 const Schedule& floatSchedule,
const QuantLib::ext::shared_ptr<IborIndex>& floatIndex, Spread floatSpread,
37 const BusinessDayConvention& floatPaymentBdc, Natural floatPaymentLag,
const Calendar& floatPaymentCalendar,
38 const QuantLib::ext::shared_ptr<FxIndex>& fxIdx,
bool resetsOnFloatLeg,
bool receiveFixed)
39 :
CrossCcySwap(3), nominal_(nominal), fixedCurrency_(fixedCurrency),
40 fixedSchedule_(fixedSchedule), fixedRate_(fixedRate), fixedDayCount_(fixedDayCount),
41 fixedPaymentBdc_(fixedPaymentBdc), fixedPaymentLag_(fixedPaymentLag), fixedPaymentCalendar_(fixedPaymentCalendar),
42 floatCurrency_(floatCurrency), floatSchedule_(floatSchedule), floatIndex_(floatIndex),
43 floatSpread_(floatSpread), floatPaymentBdc_(floatPaymentBdc),
44 floatPaymentLag_(floatPaymentLag), floatPaymentCalendar_(floatPaymentCalendar),
45 fxIndex_(fxIdx), resetsOnFloatLeg_(resetsOnFloatLeg), receiveFixed_(receiveFixed) {
55 Real floatNotional, fixedNotional;
66 .withNotionals(floatNotional)
73 for (Leg::const_iterator it = floatLeg.begin(); it < floatLeg.end(); ++it)
78 .withNotionals(fixedNotional)
89 QuantLib::ext::shared_ptr<CashFlow> aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(-fixedNotional, aDate);
90 fixedLeg.insert(fixedLeg.begin(), aCashflow);
93 aDate = fixedLeg.back()->date();
94 aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(fixedNotional, aDate);
95 fixedLeg.push_back(aCashflow);
98 for (Size j = 0; j < floatLeg.size(); ++j) {
99 QuantLib::ext::shared_ptr<FloatingRateCoupon> coupon = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(floatLeg[j]);
100 Date fixingDate =
fxIndex_->fixingCalendar().advance(coupon->accrualStartDate(),
101 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
102 QuantLib::ext::shared_ptr<FloatingRateFXLinkedNotionalCoupon> fxLinkedCoupon =
103 QuantLib::ext::make_shared<FloatingRateFXLinkedNotionalCoupon>(fixingDate, fixedNotional,
fxIndex_, coupon);
104 floatLeg[j] = fxLinkedCoupon;
110 for (Size j = 0; j < floatLeg.size(); j++) {
111 QuantLib::ext::shared_ptr<Coupon> c = QuantLib::ext::dynamic_pointer_cast<Coupon>(floatLeg[j]);
112 QL_REQUIRE(c,
"Resetting XCCY - expected Coupon");
115 Date fixingDate =
fxIndex_->fixingCalendar().advance(c->accrualStartDate(),
116 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
117 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
119 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
127 QuantLib::ext::shared_ptr<CashFlow> aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(-floatNotional, aDate);
128 floatLeg.insert(floatLeg.begin(), aCashflow);
131 aDate = fixedLeg.back()->date();
132 aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(floatNotional, aDate);
133 floatLeg.push_back(aCashflow);
136 for (Size j = 0; j < fixedLeg.size(); ++j) {
137 QuantLib::ext::shared_ptr<FixedRateCoupon> coupon = QuantLib::ext::dynamic_pointer_cast<FixedRateCoupon>(fixedLeg[j]);
138 Date fixingDate =
fxIndex_->fixingCalendar().advance(coupon->accrualStartDate(),
139 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
140 QuantLib::ext::shared_ptr<FixedRateFXLinkedNotionalCoupon> fxLinkedCoupon =
141 QuantLib::ext::make_shared<FixedRateFXLinkedNotionalCoupon>(fixingDate, floatNotional,
fxIndex_, coupon);
142 floatLeg[j] = fxLinkedCoupon;
148 for (Size j = 0; j < fixedLeg.size(); j++) {
149 QuantLib::ext::shared_ptr<Coupon> c = QuantLib::ext::dynamic_pointer_cast<Coupon>(fixedLeg[j]);
150 QL_REQUIRE(c,
"Resetting XCCY - expected Coupon");
153 Date fixingDate =
fxIndex_->fixingCalendar().advance(c->accrualStartDate(),
154 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
155 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
157 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
180 for (Size legNo = 0; legNo < legs_.size(); legNo++) {
182 for (it = legs_[legNo].begin(); it != legs_[legNo].end(); ++it) {
214 static Spread basisPoint = 1.0e-4;
217 if (
fairFixedRate_ == Null<Rate>() && legBPS_[idxFixed] != Null<Real>())
221 if (
fairSpread_ == Null<Spread>() && legBPS_[idxFloat] != Null<Real>())
233 QL_REQUIRE(
fixedRate != Null<Rate>(),
"Fixed rate cannot be null");
234 QL_REQUIRE(
spread != Null<Spread>(),
"Spread cannot be null");
void validate() const override
Real nominal_
nominal of non resetting leg
QuantLib::DayCounter fixedDayCount_
QuantLib::ext::shared_ptr< QuantLib::IborIndex > floatIndex_
QuantLib::Spread floatSpread_
QuantLib::Schedule fixedSchedule_
QuantLib::Rate fairFixedRate_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
QuantLib::Currency fixedCurrency_
QuantLib::Spread fairSpread_
QuantLib::Rate fairFixedRate() const
QuantLib::Currency floatCurrency_
void setupArguments(PricingEngine::arguments *args) const override
CrossCcyFixFloatMtMResetSwap(QuantLib::Real nominal, const QuantLib::Currency &fixedCurrency, const QuantLib::Schedule &fixedSchedule, QuantLib::Rate fixedRate, const QuantLib::DayCounter &fixedDayCount, const QuantLib::BusinessDayConvention &fixedPaymentBdc, QuantLib::Natural fixedPaymentLag, const QuantLib::Calendar &fixedPaymentCalendar, const QuantLib::Currency &floatCurrency, const QuantLib::Schedule &floatSchedule, const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &floatIndex, QuantLib::Spread floatSpread, const QuantLib::BusinessDayConvention &floatPaymentBdc, QuantLib::Natural floatPaymentLag, const QuantLib::Calendar &floatPaymentCalendar, const QuantLib::ext::shared_ptr< FxIndex > &fxIdx, bool resetsOnFloatLeg=true, bool receiveFixed=true)
QuantLib::Calendar floatPaymentCalendar_
QuantLib::Schedule floatSchedule_
QuantLib::Rate fixedRate_
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
QuantLib::BusinessDayConvention floatPaymentBdc_
QuantLib::Natural floatPaymentLag_
QuantLib::Calendar fixedPaymentCalendar_
QuantLib::Natural fixedPaymentLag_
QuantLib::BusinessDayConvention fixedPaymentBdc_
QuantLib::Spread fairSpread() const
void validate() const override
void setupArguments(PricingEngine::arguments *args) const override
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
std::vector< Currency > currencies_
Cross currency fix float swap instrument with MTM reset.
Coupon paying a fixed rate but with an FX linked notional.
Coupon paying a Libor-type index but with an FX linked notional.