Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | List of all members
CrossCcyBasisMtMResetSwap Class Reference

Cross currency basis MtM resettable swap. More...

#include <qle/instruments/crossccybasismtmresetswap.hpp>

+ Inheritance diagram for CrossCcyBasisMtMResetSwap:
+ Collaboration diagram for CrossCcyBasisMtMResetSwap:

Classes

class  arguments
 
class  results
 

Public Member Functions

Constructors
 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)
 
Inspectors
Real foreignNominal () const
 
const Currency & foreignCurrency () const
 
const Schedule & foreignSchedule () const
 
const QuantLib::ext::shared_ptr< IborIndex > & foreignIndex () const
 
Spread foreignSpread () const
 
const Currency & domesticCurrency () const
 
const Schedule & domesticSchedule () const
 
const QuantLib::ext::shared_ptr< IborIndex > & domesticIndex () const
 
Spread domesticSpread () const
 
Additional interface
Spread fairForeignSpread () const
 
Spread fairDomesticSpread () const
 
Spread fairSpread () const
 
- Public Member Functions inherited from CrossCcySwap
const Currency & legCurrency (Size j) const
 
Real inCcyLegBPS (Size j) const
 
Real inCcyLegNPV (Size j) const
 
DiscountFactor npvDateDiscounts (Size j) const
 
void setupArguments (PricingEngine::arguments *args) const override
 
void fetchResults (const PricingEngine::results *) const override
 
 CrossCcySwap (const Leg &firstLeg, const Currency &firstLegCcy, const Leg &secondLeg, const Currency &secondLegCcy)
 First leg is paid and the second is received. More...
 
 CrossCcySwap (const std::vector< Leg > &legs, const std::vector< bool > &payer, const std::vector< Currency > &currencies)
 

Instrument interface

Real foreignNominal_
 
Currency foreignCurrency_
 
Schedule foreignSchedule_
 
QuantLib::ext::shared_ptr< IborIndex > foreignIndex_
 
Spread foreignSpread_
 
Currency domesticCurrency_
 
Schedule domesticSchedule_
 
QuantLib::ext::shared_ptr< IborIndex > domesticIndex_
 
Spread domesticSpread_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
bool receiveDomestic_
 
Size foreignPaymentLag_
 
Size domesticPaymentLag_
 
boost::optional< boolforeignIncludeSpread_
 
boost::optional< QuantLib::Period > foreignLookback_
 
boost::optional< QuantLib::Size > foreignFixingDays_
 
boost::optional< Size > foreignRateCutoff_
 
boost::optional< boolforeignIsAveraged_
 
boost::optional< booldomesticIncludeSpread_
 
boost::optional< QuantLib::Period > domesticLookback_
 
boost::optional< QuantLib::Size > domesticFixingDays_
 
boost::optional< Size > domesticRateCutoff_
 
boost::optional< booldomesticIsAveraged_
 
bool telescopicValueDates_
 
bool fairSpreadLegIsForeign_
 
Spread fairForeignSpread_
 
Spread fairDomesticSpread_
 
void setupArguments (PricingEngine::arguments *args) const override
 
void fetchResults (const PricingEngine::results *) const override
 
void setupExpired () const override
 
void initialize ()
 

Additional Inherited Members

- Protected Member Functions inherited from CrossCcySwap
void setupExpired () const override
 
 CrossCcySwap (Size legs)
 
- Protected Attributes inherited from CrossCcySwap
std::vector< Currency > currencies_
 

Detailed Description

Cross currency basis MtM resettable swap.

The foreign leg holds the pay currency cashflows and domestic leg holds the receive currency cashflows. The notional resets are applied to the domestic leg.

    \ingroup instruments

Definition at line 42 of file crossccybasismtmresetswap.hpp.

Constructor & Destructor Documentation

◆ CrossCcyBasisMtMResetSwap()

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 
)

First leg holds the pay currency cashflows and the second leg holds the receive currency cashflows.

Definition at line 32 of file crossccybasismtmresetswap.cpp.

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) {
54 registerWith(foreignIndex_);
55 registerWith(domesticIndex_);
56 registerWith(fxIndex_);
57 initialize();
58}
boost::optional< QuantLib::Period > foreignLookback_
const QuantLib::ext::shared_ptr< IborIndex > & foreignIndex() const
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
const QuantLib::ext::shared_ptr< IborIndex > & domesticIndex() const
boost::optional< QuantLib::Period > domesticLookback_
QuantLib::ext::shared_ptr< IborIndex > foreignIndex_
boost::optional< QuantLib::Size > domesticFixingDays_
boost::optional< QuantLib::Size > foreignFixingDays_
QuantLib::ext::shared_ptr< IborIndex > domesticIndex_
CrossCcySwap(const Leg &firstLeg, const Currency &firstLegCcy, const Leg &secondLeg, const Currency &secondLegCcy)
First leg is paid and the second is received.
+ Here is the call graph for this function:

Member Function Documentation

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 171 of file crossccybasismtmresetswap.cpp.

171 {
172
174
175 CrossCcyBasisMtMResetSwap::arguments* arguments = dynamic_cast<CrossCcyBasisMtMResetSwap::arguments*>(args);
176
177 /* Returns here if e.g. args is CrossCcySwap::arguments which
178 is the case if PricingEngine is a CrossCcySwap::engine. */
179 if (!arguments)
180 return;
181
182 arguments->domesticSpread = domesticSpread_;
183 arguments->foreignSpread = foreignSpread_;
184}
void setupArguments(PricingEngine::arguments *args) const override
+ Here is the call graph for this function:

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
override

Definition at line 186 of file crossccybasismtmresetswap.cpp.

186 {
187
189
190 const CrossCcyBasisMtMResetSwap::results* results = dynamic_cast<const CrossCcyBasisMtMResetSwap::results*>(r);
191 if (results) {
192 /* If PricingEngine::results are of type
193 CrossCcyBasisSwap::results */
194 fairForeignSpread_ = results->fairForeignSpread;
195 fairDomesticSpread_ = results->fairDomesticSpread;
196 } else {
197 /* If not, e.g. if the engine is a CrossCcySwap::engine */
198 fairForeignSpread_ = Null<Spread>();
199 fairDomesticSpread_ = Null<Spread>();
200 }
201
202 /* Calculate the fair pay and receive spreads if they are null */
203 static Spread basisPoint = 1.0e-4;
204 if (fairForeignSpread_ == Null<Spread>()) {
205 if (legBPS_[0] != Null<Real>())
206 fairForeignSpread_ = foreignSpread_ - NPV_ / (legBPS_[0] / basisPoint);
207 }
208 if (fairDomesticSpread_ == Null<Spread>()) {
209 if (legBPS_[1] != Null<Real>())
210 fairDomesticSpread_ = domesticSpread_ - NPV_ / (legBPS_[1] / basisPoint);
211 }
212}
void fetchResults(const PricingEngine::results *) const override
+ Here is the call graph for this function:

◆ foreignNominal()

Real foreignNominal ( ) const

Definition at line 72 of file crossccybasismtmresetswap.hpp.

72{ return foreignNominal_; }

◆ foreignCurrency()

const Currency & foreignCurrency ( ) const

Definition at line 73 of file crossccybasismtmresetswap.hpp.

73{ return foreignCurrency_; }

◆ foreignSchedule()

const Schedule & foreignSchedule ( ) const

Definition at line 74 of file crossccybasismtmresetswap.hpp.

74{ return foreignSchedule_; }

◆ foreignIndex()

const QuantLib::ext::shared_ptr< IborIndex > & foreignIndex ( ) const

Definition at line 75 of file crossccybasismtmresetswap.hpp.

75{ return foreignIndex_; }

◆ foreignSpread()

Spread foreignSpread ( ) const

Definition at line 76 of file crossccybasismtmresetswap.hpp.

76{ return foreignSpread_; }

◆ domesticCurrency()

const Currency & domesticCurrency ( ) const

Definition at line 78 of file crossccybasismtmresetswap.hpp.

78{ return domesticCurrency_; }

◆ domesticSchedule()

const Schedule & domesticSchedule ( ) const

Definition at line 79 of file crossccybasismtmresetswap.hpp.

79{ return domesticSchedule_; }

◆ domesticIndex()

const QuantLib::ext::shared_ptr< IborIndex > & domesticIndex ( ) const

Definition at line 80 of file crossccybasismtmresetswap.hpp.

80{ return domesticIndex_; }

◆ domesticSpread()

Spread domesticSpread ( ) const

Definition at line 81 of file crossccybasismtmresetswap.hpp.

81{ return domesticSpread_; }

◆ fairForeignSpread()

Spread fairForeignSpread ( ) const

Definition at line 86 of file crossccybasismtmresetswap.hpp.

86 {
87 calculate();
88 QL_REQUIRE(fairForeignSpread_ != Null<Real>(), "Fair foreign spread is not available");
89 return fairForeignSpread_;
90 }
+ Here is the caller graph for this function:

◆ fairDomesticSpread()

Spread fairDomesticSpread ( ) const

Definition at line 91 of file crossccybasismtmresetswap.hpp.

91 {
92 calculate();
93 QL_REQUIRE(fairDomesticSpread_ != Null<Real>(), "Fair domestic spread is not available");
95 }
+ Here is the caller graph for this function:

◆ fairSpread()

Spread fairSpread ( ) const

Definition at line 96 of file crossccybasismtmresetswap.hpp.

+ Here is the call graph for this function:

◆ setupExpired()

void setupExpired ( ) const
overrideprotected

Definition at line 214 of file crossccybasismtmresetswap.cpp.

214 {
216 fairForeignSpread_ = Null<Spread>();
217 fairDomesticSpread_ = Null<Spread>();
218}
void setupExpired() const override
+ Here is the call graph for this function:

◆ initialize()

void initialize ( )
private

Definition at line 60 of file crossccybasismtmresetswap.cpp.

60 {
61 // Pay (foreign) leg
62 if (auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(foreignIndex_)) {
63 // ON leg
73 } else {
83 }
84 } else {
85 // Ibor leg
86 legs_[0] = IborLeg(foreignSchedule_, foreignIndex_)
90 }
91 receiveDomestic_ ? payer_[0] = -1.0 : payer_[0] = +1.0;
92
94 // Pay leg notional exchange at start.
95 Date initialPayDate = foreignSchedule_.dates().front();
96 QuantLib::ext::shared_ptr<CashFlow> initialPayCF(new SimpleCashFlow(-foreignNominal_, initialPayDate));
97 legs_[0].insert(legs_[0].begin(), initialPayCF);
98 // Pay leg notional exchange at end.
99 Date finalPayDate = foreignSchedule_.dates().back();
100 QuantLib::ext::shared_ptr<CashFlow> finalPayCF(new SimpleCashFlow(foreignNominal_, finalPayDate));
101 legs_[0].push_back(finalPayCF);
102
103 // Receive (domestic/resettable) leg
104 // start by creating a dummy vanilla floating leg
105 if (auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(domesticIndex_)) {
106 // ON leg
109 .withNotional(0.0)
116 } else {
118 .withNotionals(0.0)
126 }
127 } else {
128 // Ibor leg
129 legs_[1] = IborLeg(domesticSchedule_, domesticIndex_)
130 .withNotionals(0.0)
133 }
134 receiveDomestic_ ? payer_[1] = +1.0 : payer_[1] = -1.0;
136 // replace the coupons with a FloatingRateFXLinkedNotionalCoupon
137 // (skip the first coupon as it has a fixed notional)
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(
143 new FloatingRateFXLinkedNotionalCoupon(fixingDate, foreignNominal_, fxIndex_, coupon));
144 legs_[1][j] = fxLinkedCoupon;
145 }
146 // now build a separate leg to store the domestic (resetting) notionals
147 receiveDomestic_ ? payer_[2] = +1.0 : payer_[2] = -1.0;
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"); // TODO: fixed fx resettable?
152 // build a pair of notional flows, one at the start and one at the end of
153 // the accrual period. Both with the same FX fixing date
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>(
157 new FXLinkedCashFlow(c->accrualStartDate(), fixingDate, -foreignNominal_, fxIndex_)));
158 legs_[2].push_back(QuantLib::ext::shared_ptr<CashFlow>(
159 new FXLinkedCashFlow(c->accrualEndDate(), fixingDate, foreignNominal_, fxIndex_)));
160 }
161
162 // Register the instrument with all cashflows on each leg.
163 for (Size legNo = 0; legNo < legs_.size(); legNo++) {
164 Leg::iterator it;
165 for (it = legs_[legNo].begin(); it != legs_[legNo].end(); ++it) {
166 registerWith(*it);
167 }
168 }
169}
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)
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)
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
Definition: inflation.cpp:183
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ foreignNominal_

Real foreignNominal_
private

Definition at line 113 of file crossccybasismtmresetswap.hpp.

◆ foreignCurrency_

Currency foreignCurrency_
private

Definition at line 114 of file crossccybasismtmresetswap.hpp.

◆ foreignSchedule_

Schedule foreignSchedule_
private

Definition at line 115 of file crossccybasismtmresetswap.hpp.

◆ foreignIndex_

QuantLib::ext::shared_ptr<IborIndex> foreignIndex_
private

Definition at line 116 of file crossccybasismtmresetswap.hpp.

◆ foreignSpread_

Spread foreignSpread_
private

Definition at line 117 of file crossccybasismtmresetswap.hpp.

◆ domesticCurrency_

Currency domesticCurrency_
private

Definition at line 119 of file crossccybasismtmresetswap.hpp.

◆ domesticSchedule_

Schedule domesticSchedule_
private

Definition at line 120 of file crossccybasismtmresetswap.hpp.

◆ domesticIndex_

QuantLib::ext::shared_ptr<IborIndex> domesticIndex_
private

Definition at line 121 of file crossccybasismtmresetswap.hpp.

◆ domesticSpread_

Spread domesticSpread_
private

Definition at line 122 of file crossccybasismtmresetswap.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<FxIndex> fxIndex_
private

Definition at line 124 of file crossccybasismtmresetswap.hpp.

◆ receiveDomestic_

bool receiveDomestic_
private

Definition at line 125 of file crossccybasismtmresetswap.hpp.

◆ foreignPaymentLag_

Size foreignPaymentLag_
private

Definition at line 127 of file crossccybasismtmresetswap.hpp.

◆ domesticPaymentLag_

Size domesticPaymentLag_
private

Definition at line 128 of file crossccybasismtmresetswap.hpp.

◆ foreignIncludeSpread_

boost::optional<bool> foreignIncludeSpread_
private

Definition at line 130 of file crossccybasismtmresetswap.hpp.

◆ foreignLookback_

boost::optional<QuantLib::Period> foreignLookback_
private

Definition at line 131 of file crossccybasismtmresetswap.hpp.

◆ foreignFixingDays_

boost::optional<QuantLib::Size> foreignFixingDays_
private

Definition at line 132 of file crossccybasismtmresetswap.hpp.

◆ foreignRateCutoff_

boost::optional<Size> foreignRateCutoff_
private

Definition at line 133 of file crossccybasismtmresetswap.hpp.

◆ foreignIsAveraged_

boost::optional<bool> foreignIsAveraged_
private

Definition at line 134 of file crossccybasismtmresetswap.hpp.

◆ domesticIncludeSpread_

boost::optional<bool> domesticIncludeSpread_
private

Definition at line 135 of file crossccybasismtmresetswap.hpp.

◆ domesticLookback_

boost::optional<QuantLib::Period> domesticLookback_
private

Definition at line 136 of file crossccybasismtmresetswap.hpp.

◆ domesticFixingDays_

boost::optional<QuantLib::Size> domesticFixingDays_
private

Definition at line 137 of file crossccybasismtmresetswap.hpp.

◆ domesticRateCutoff_

boost::optional<Size> domesticRateCutoff_
private

Definition at line 138 of file crossccybasismtmresetswap.hpp.

◆ domesticIsAveraged_

boost::optional<bool> domesticIsAveraged_
private

Definition at line 139 of file crossccybasismtmresetswap.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_
private

Definition at line 140 of file crossccybasismtmresetswap.hpp.

◆ fairSpreadLegIsForeign_

bool fairSpreadLegIsForeign_
private

Definition at line 141 of file crossccybasismtmresetswap.hpp.

◆ fairForeignSpread_

Spread fairForeignSpread_
mutableprivate

Definition at line 143 of file crossccybasismtmresetswap.hpp.

◆ fairDomesticSpread_

Spread fairDomesticSpread_
mutableprivate

Definition at line 144 of file crossccybasismtmresetswap.hpp.