19#include <boost/assign/list_of.hpp>
20using boost::assign::list_of;
22#include <ql/cashflows/iborcoupon.hpp>
23#include <ql/cashflows/simplecashflow.hpp>
33 Real foreignNominal,
const Currency& foreignCurrency,
const Schedule& foreignSchedule,
34 const QuantLib::ext::shared_ptr<IborIndex>& foreignIndex, Spread foreignSpread,
const Currency& domesticCurrency,
35 const Schedule& domesticSchedule,
const QuantLib::ext::shared_ptr<IborIndex>& domesticIndex, Spread domesticSpread,
36 const QuantLib::ext::shared_ptr<FxIndex>& fxIdx,
bool receiveDomestic, Size foreignPaymentLag, Size domesticPaymentLag,
37 boost::optional<bool> foreignIncludeSpread, boost::optional<Period> foreignLookback,
38 boost::optional<Size> foreignFixingDays, boost::optional<Size> foreignRateCutoff,
39 boost::optional<bool> foreignIsAveraged, boost::optional<bool> domesticIncludeSpread,
40 boost::optional<Period> domesticLookback, boost::optional<Size> domesticFixingDays,
41 boost::optional<Size> domesticRateCutoff, boost::optional<bool> domesticIsAveraged,
const bool telescopicValueDates,
42 const bool fairSpreadLegIsForeign)
43 :
CrossCcySwap(3), foreignNominal_(foreignNominal), foreignCurrency_(foreignCurrency),
44 foreignSchedule_(foreignSchedule), foreignIndex_(foreignIndex), foreignSpread_(foreignSpread),
45 domesticCurrency_(domesticCurrency), domesticSchedule_(domesticSchedule), domesticIndex_(domesticIndex),
46 domesticSpread_(domesticSpread), fxIndex_(fxIdx), receiveDomestic_(receiveDomestic),
47 foreignPaymentLag_(foreignPaymentLag), domesticPaymentLag_(domesticPaymentLag),
48 foreignIncludeSpread_(foreignIncludeSpread), foreignLookback_(foreignLookback),
49 foreignFixingDays_(foreignFixingDays), foreignRateCutoff_(foreignRateCutoff),
50 foreignIsAveraged_(foreignIsAveraged), domesticIncludeSpread_(domesticIncludeSpread),
51 domesticLookback_(domesticLookback), domesticFixingDays_(domesticFixingDays),
52 domesticRateCutoff_(domesticRateCutoff), domesticIsAveraged_(domesticIsAveraged),
53 telescopicValueDates_(telescopicValueDates), fairSpreadLegIsForeign_(fairSpreadLegIsForeign) {
62 if (
auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(
foreignIndex_)) {
96 QuantLib::ext::shared_ptr<CashFlow> initialPayCF(
new SimpleCashFlow(-
foreignNominal_, initialPayDate));
97 legs_[0].insert(legs_[0].begin(), initialPayCF);
100 QuantLib::ext::shared_ptr<CashFlow> finalPayCF(
new SimpleCashFlow(
foreignNominal_, finalPayDate));
101 legs_[0].push_back(finalPayCF);
105 if (
auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(
domesticIndex_)) {
138 for (Size j = 0; j < legs_[1].size(); ++j) {
139 QuantLib::ext::shared_ptr<FloatingRateCoupon> coupon = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(legs_[1][j]);
140 Date fixingDate =
fxIndex_->fixingCalendar().advance(coupon->accrualStartDate(),
141 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
142 QuantLib::ext::shared_ptr<FloatingRateFXLinkedNotionalCoupon> fxLinkedCoupon(
144 legs_[1][j] = fxLinkedCoupon;
149 for (Size j = 0; j < legs_[1].size(); j++) {
150 QuantLib::ext::shared_ptr<Coupon> c = QuantLib::ext::dynamic_pointer_cast<Coupon>(legs_[1][j]);
151 QL_REQUIRE(c,
"Resetting XCCY - expected Coupon");
154 Date fixingDate =
fxIndex_->fixingCalendar().advance(c->accrualStartDate(),
155 -
static_cast<Integer
>(
fxIndex_->fixingDays()), Days);
156 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
158 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
163 for (Size legNo = 0; legNo < legs_.size(); legNo++) {
165 for (it = legs_[legNo].begin(); it != legs_[legNo].end(); ++it) {
203 static Spread basisPoint = 1.0e-4;
205 if (legBPS_[0] != Null<Real>())
209 if (legBPS_[1] != Null<Real>())
222 QL_REQUIRE(
foreignSpread != Null<Spread>(),
"Pay spread cannot be null");
223 QL_REQUIRE(
domesticSpread != Null<Spread>(),
"Rec spread cannot be null");
coupon paying the weighted average of the daily overnight rate
helper class building a sequence of overnight coupons
AverageONLeg & withSpread(Spread spread)
AverageONLeg & withPaymentLag(Natural lag)
AverageONLeg & withNotional(Real notional)
AverageONLeg & withLookback(const Period &lookback)
AverageONLeg & withRateCutoff(Natural rateCutoff)
AverageONLeg & withTelescopicValueDates(bool telescopicValueDates)
AverageONLeg & withFixingDays(const Size fixingDays)
void validate() const override
Spread fairDomesticSpread
boost::optional< QuantLib::Period > foreignLookback_
bool telescopicValueDates_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
Currency domesticCurrency_
Currency foreignCurrency_
boost::optional< QuantLib::Period > domesticLookback_
QuantLib::ext::shared_ptr< IborIndex > foreignIndex_
boost::optional< bool > foreignIsAveraged_
boost::optional< bool > domesticIncludeSpread_
Spread fairForeignSpread() const
Spread fairForeignSpread_
boost::optional< QuantLib::Size > domesticFixingDays_
Spread fairDomesticSpread() const
void setupArguments(PricingEngine::arguments *args) const override
Spread fairDomesticSpread_
boost::optional< bool > foreignIncludeSpread_
void setupExpired() const override
CrossCcyBasisMtMResetSwap(Real foreignNominal, const Currency &foreignCurrency, const Schedule &foreignSchedule, const QuantLib::ext::shared_ptr< IborIndex > &foreignIndex, Spread foreignSpread, const Currency &domesticCurrency, const Schedule &domesticSchedule, const QuantLib::ext::shared_ptr< IborIndex > &domesticIndex, Spread domesticSpread, const QuantLib::ext::shared_ptr< FxIndex > &fxIdx, bool receiveDomestic=true, Size foreignPaymentLag=0, Size recPaymentLag=0, boost::optional< bool > foreignIncludeSpread=boost::none, boost::optional< Period > foreignLookback=boost::none, boost::optional< Size > foreignFixingDays=boost::none, boost::optional< Size > foreignRateCutoff=boost::none, boost::optional< bool > foreignIsAveraged=boost::none, boost::optional< bool > domesticIncludeSpread=boost::none, boost::optional< Period > domesticLookback=boost::none, boost::optional< Size > domesticFixingDays=boost::none, boost::optional< Size > domesticRateCutoff=boost::none, boost::optional< bool > domesticIsAveraged=boost::none, const bool telescopicValueDates=false, bool fairSpreadLegIsForeign=true)
Schedule foreignSchedule_
void fetchResults(const PricingEngine::results *) const override
boost::optional< bool > domesticIsAveraged_
boost::optional< QuantLib::Size > foreignFixingDays_
boost::optional< Size > foreignRateCutoff_
QuantLib::ext::shared_ptr< IborIndex > domesticIndex_
Schedule domesticSchedule_
boost::optional< Size > domesticRateCutoff_
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_
helper class building a sequence of overnight coupons
OvernightLeg & withLookback(const Period &lookback)
OvernightLeg & withTelescopicValueDates(bool telescopicValueDates)
OvernightLeg & withFixingDays(const Natural fixingDays)
OvernightLeg & withNotionals(Real notional)
OvernightLeg & withRateCutoff(const Natural rateCutoff)
OvernightLeg & withSpreads(Spread spread)
OvernightLeg & includeSpread(bool includeSpread)
OvernightLeg & withPaymentLag(Natural lag)
Cross currency basis swap instrument with MTM reset.
Coupon paying a Libor-type index but with an FX linked notional.
coupon paying the compounded daily overnight rate, copy of QL class, added includeSpread flag