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

Cross currency basis swap. More...

#include <qle/instruments/crossccybasisswap.hpp>

+ Inheritance diagram for CrossCcyBasisSwap:
+ Collaboration diagram for CrossCcyBasisSwap:

Classes

class  arguments
 
class  results
 

Public Member Functions

Constructors
 CrossCcyBasisSwap (Real payNominal, const Currency &payCurrency, const Schedule &paySchedule, const QuantLib::ext::shared_ptr< IborIndex > &payIndex, Spread paySpread, Real payGearing, Real recNominal, const Currency &recCurrency, const Schedule &recSchedule, const QuantLib::ext::shared_ptr< IborIndex > &recIndex, Spread recSpread, Real recGearing, Size payPaymentLag=0, Size recPaymentLag=0, boost::optional< bool > payIncludeSpread=boost::none, boost::optional< Period > payLookback=boost::none, boost::optional< Size > payFixingDays=boost::none, boost::optional< Size > payRateCutoff=boost::none, boost::optional< bool > payIsAveraged=boost::none, boost::optional< bool > recIncludeSpread=boost::none, boost::optional< Period > recLookback=boost::none, boost::optional< Size > recFixingDays=boost::none, boost::optional< Size > recRateCutoff=boost::none, boost::optional< bool > recIsAveraged=boost::none, const bool telescopicValueDates=false)
 
Inspectors
Real payNominal () const
 
const Currency & payCurrency () const
 
const Schedule & paySchedule () const
 
const QuantLib::ext::shared_ptr< IborIndex > & payIndex () const
 
Spread paySpread () const
 
Real payGearing () const
 
Real recNominal () const
 
const Currency & recCurrency () const
 
const Schedule & recSchedule () const
 
const QuantLib::ext::shared_ptr< IborIndex > & recIndex () const
 
Spread recSpread () const
 
Real recGearing () const
 
Additional interface
Spread fairPaySpread () const
 
Spread fairRecSpread () 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 payNominal_
 
Currency payCurrency_
 
Schedule paySchedule_
 
QuantLib::ext::shared_ptr< IborIndex > payIndex_
 
Spread paySpread_
 
Real payGearing_
 
Real recNominal_
 
Currency recCurrency_
 
Schedule recSchedule_
 
QuantLib::ext::shared_ptr< IborIndex > recIndex_
 
Spread recSpread_
 
Real recGearing_
 
Size payPaymentLag_
 
Size recPaymentLag_
 
boost::optional< boolpayIncludeSpread_
 
boost::optional< QuantLib::Period > payLookback_
 
boost::optional< QuantLib::Size > payFixingDays_
 
boost::optional< Size > payRateCutoff_
 
boost::optional< boolpayIsAveraged_
 
boost::optional< boolrecIncludeSpread_
 
boost::optional< QuantLib::Period > recLookback_
 
boost::optional< QuantLib::Size > recFixingDays_
 
boost::optional< Size > recRateCutoff_
 
boost::optional< boolrecIsAveraged_
 
bool telescopicValueDates_
 
Spread fairPaySpread_
 
Spread fairRecSpread_
 
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 swap.

The first leg holds the pay currency cashflows and second leg holds the receive currency cashflows.

    \ingroup instruments

Definition at line 41 of file crossccybasisswap.hpp.

Constructor & Destructor Documentation

◆ CrossCcyBasisSwap()

CrossCcyBasisSwap ( Real  payNominal,
const Currency &  payCurrency,
const Schedule &  paySchedule,
const QuantLib::ext::shared_ptr< IborIndex > &  payIndex,
Spread  paySpread,
Real  payGearing,
Real  recNominal,
const Currency &  recCurrency,
const Schedule &  recSchedule,
const QuantLib::ext::shared_ptr< IborIndex > &  recIndex,
Spread  recSpread,
Real  recGearing,
Size  payPaymentLag = 0,
Size  recPaymentLag = 0,
boost::optional< bool payIncludeSpread = boost::none,
boost::optional< Period >  payLookback = boost::none,
boost::optional< Size >  payFixingDays = boost::none,
boost::optional< Size >  payRateCutoff = boost::none,
boost::optional< bool payIsAveraged = boost::none,
boost::optional< bool recIncludeSpread = boost::none,
boost::optional< Period >  recLookback = boost::none,
boost::optional< Size >  recFixingDays = boost::none,
boost::optional< Size >  recRateCutoff = boost::none,
boost::optional< bool recIsAveraged = boost::none,
const bool  telescopicValueDates = false 
)

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

Definition at line 32 of file crossccybasisswap.cpp.

45 recGearing_(recGearing), payPaymentLag_(payPaymentLag), recPaymentLag_(recPaymentLag),
46 payIncludeSpread_(payIncludeSpread), payLookback_(payLookback), payFixingDays_(payFixingDays),
47 payRateCutoff_(payRateCutoff), payIsAveraged_(payIsAveraged), recIncludeSpread_(recIncludeSpread),
48 recLookback_(recLookback), recFixingDays_(recFixingDays), recRateCutoff_(recRateCutoff),
49 recIsAveraged_(recIsAveraged), telescopicValueDates_(telescopicValueDates) {
50 registerWith(payIndex_);
51 registerWith(recIndex_);
52 initialize();
53}
boost::optional< QuantLib::Period > payLookback_
const Currency & recCurrency() const
QuantLib::ext::shared_ptr< IborIndex > payIndex_
const QuantLib::ext::shared_ptr< IborIndex > & recIndex() const
QuantLib::ext::shared_ptr< IborIndex > recIndex_
boost::optional< bool > payIsAveraged_
const Schedule & recSchedule() const
boost::optional< Size > recRateCutoff_
boost::optional< bool > payIncludeSpread_
boost::optional< bool > recIsAveraged_
boost::optional< QuantLib::Size > payFixingDays_
boost::optional< QuantLib::Size > recFixingDays_
const Currency & payCurrency() const
const Schedule & paySchedule() const
boost::optional< Size > payRateCutoff_
const QuantLib::ext::shared_ptr< IborIndex > & payIndex() const
boost::optional< QuantLib::Period > recLookback_
boost::optional< bool > recIncludeSpread_
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 153 of file crossccybasisswap.cpp.

153 {
154
156
157 CrossCcyBasisSwap::arguments* arguments = dynamic_cast<CrossCcyBasisSwap::arguments*>(args);
158
159 /* Returns here if e.g. args is CrossCcySwap::arguments which
160 is the case if PricingEngine is a CrossCcySwap::engine. */
161 if (!arguments)
162 return;
163
164 arguments->paySpread = paySpread_;
165 arguments->recSpread = recSpread_;
166}
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 168 of file crossccybasisswap.cpp.

168 {
169
171
172 const CrossCcyBasisSwap::results* results = dynamic_cast<const CrossCcyBasisSwap::results*>(r);
173 if (results) {
174 /* If PricingEngine::results are of type
175 CrossCcyBasisSwap::results */
176 fairPaySpread_ = results->fairPaySpread;
177 fairRecSpread_ = results->fairRecSpread;
178 } else {
179 /* If not, e.g. if the engine is a CrossCcySwap::engine */
180 fairPaySpread_ = Null<Spread>();
181 fairRecSpread_ = Null<Spread>();
182 }
183
184 /* Calculate the fair pay and receive spreads if they are null */
185 static Spread basisPoint = 1.0e-4;
186 if (fairPaySpread_ == Null<Spread>()) {
187 if (legBPS_[0] != Null<Real>())
188 fairPaySpread_ = paySpread_ - NPV_ / (legBPS_[0] / basisPoint);
189 }
190 if (fairRecSpread_ == Null<Spread>()) {
191 if (legBPS_[1] != Null<Real>())
192 fairRecSpread_ = recSpread_ - NPV_ / (legBPS_[1] / basisPoint);
193 }
194}
void fetchResults(const PricingEngine::results *) const override
+ Here is the call graph for this function:

◆ payNominal()

Real payNominal ( ) const

Definition at line 69 of file crossccybasisswap.hpp.

69{ return payNominal_; }

◆ payCurrency()

const Currency & payCurrency ( ) const

Definition at line 70 of file crossccybasisswap.hpp.

70{ return payCurrency_; }

◆ paySchedule()

const Schedule & paySchedule ( ) const

Definition at line 71 of file crossccybasisswap.hpp.

71{ return paySchedule_; }

◆ payIndex()

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

Definition at line 72 of file crossccybasisswap.hpp.

72{ return payIndex_; }

◆ paySpread()

Spread paySpread ( ) const

Definition at line 73 of file crossccybasisswap.hpp.

73{ return paySpread_; }

◆ payGearing()

Real payGearing ( ) const

Definition at line 74 of file crossccybasisswap.hpp.

74{ return payGearing_; }

◆ recNominal()

Real recNominal ( ) const

Definition at line 76 of file crossccybasisswap.hpp.

76{ return recNominal_; }

◆ recCurrency()

const Currency & recCurrency ( ) const

Definition at line 77 of file crossccybasisswap.hpp.

77{ return recCurrency_; }

◆ recSchedule()

const Schedule & recSchedule ( ) const

Definition at line 78 of file crossccybasisswap.hpp.

78{ return recSchedule_; }

◆ recIndex()

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

Definition at line 79 of file crossccybasisswap.hpp.

79{ return recIndex_; }

◆ recSpread()

Spread recSpread ( ) const

Definition at line 80 of file crossccybasisswap.hpp.

80{ return recSpread_; }

◆ recGearing()

Real recGearing ( ) const

Definition at line 81 of file crossccybasisswap.hpp.

81{ return recGearing_; }

◆ fairPaySpread()

Spread fairPaySpread ( ) const

Definition at line 86 of file crossccybasisswap.hpp.

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

◆ fairRecSpread()

Spread fairRecSpread ( ) const

Definition at line 91 of file crossccybasisswap.hpp.

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

◆ setupExpired()

void setupExpired ( ) const
overrideprotected

Definition at line 196 of file crossccybasisswap.cpp.

196 {
198 fairPaySpread_ = Null<Spread>();
199 fairRecSpread_ = Null<Spread>();
200}
void setupExpired() const override
+ Here is the call graph for this function:

◆ initialize()

void initialize ( )
private

Definition at line 55 of file crossccybasisswap.cpp.

55 {
56 // Pay leg
57 if (auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(payIndex_)) {
58 // ON leg
69 } else {
80 }
81 } else {
82 // Ibor leg
83 legs_[0] = IborLeg(paySchedule_, payIndex_)
88 }
89 payer_[0] = -1.0;
91 // Pay leg notional exchange at start.
92 Date initialPayDate = paySchedule_.dates().front();
93 QuantLib::ext::shared_ptr<CashFlow> initialPayCF(new SimpleCashFlow(-payNominal_, initialPayDate));
94 legs_[0].insert(legs_[0].begin(), initialPayCF);
95 // Pay leg notional exchange at end.
96 Date finalPayDate = paySchedule_.dates().back();
97 QuantLib::ext::shared_ptr<CashFlow> finalPayCF(new SimpleCashFlow(payNominal_, finalPayDate));
98 legs_[0].push_back(finalPayCF);
99
100 // Receive leg
101 if (auto on = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(recIndex_)) {
102 // ON leg
113 } else {
124 }
125 } else {
126 // Ibor leg
127 legs_[1] = IborLeg(recSchedule_, recIndex_)
132 }
133 payer_[1] = +1.0;
135 // Receive leg notional exchange at start.
136 Date initialRecDate = recSchedule_.dates().front();
137 QuantLib::ext::shared_ptr<CashFlow> initialRecCF(new SimpleCashFlow(-recNominal_, initialRecDate));
138 legs_[1].insert(legs_[1].begin(), initialRecCF);
139 // Receive leg notional exchange at end.
140 Date finalRecDate = recSchedule_.dates().back();
141 QuantLib::ext::shared_ptr<CashFlow> finalRecCF(new SimpleCashFlow(recNominal_, finalRecDate));
142 legs_[1].push_back(finalRecCF);
143
144 // Register the instrument with all cashflows on each leg.
145 for (Size legNo = 0; legNo < 2; legNo++) {
146 Leg::iterator it;
147 for (it = legs_[legNo].begin(); it != legs_[legNo].end(); ++it) {
148 registerWith(*it);
149 }
150 }
151}
helper class building a sequence of overnight coupons
AverageONLeg & withGearing(Real gearing)
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 & withGearings(Real gearing)
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)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ payNominal_

Real payNominal_
private

Definition at line 107 of file crossccybasisswap.hpp.

◆ payCurrency_

Currency payCurrency_
private

Definition at line 108 of file crossccybasisswap.hpp.

◆ paySchedule_

Schedule paySchedule_
private

Definition at line 109 of file crossccybasisswap.hpp.

◆ payIndex_

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

Definition at line 110 of file crossccybasisswap.hpp.

◆ paySpread_

Spread paySpread_
private

Definition at line 111 of file crossccybasisswap.hpp.

◆ payGearing_

Real payGearing_
private

Definition at line 112 of file crossccybasisswap.hpp.

◆ recNominal_

Real recNominal_
private

Definition at line 114 of file crossccybasisswap.hpp.

◆ recCurrency_

Currency recCurrency_
private

Definition at line 115 of file crossccybasisswap.hpp.

◆ recSchedule_

Schedule recSchedule_
private

Definition at line 116 of file crossccybasisswap.hpp.

◆ recIndex_

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

Definition at line 117 of file crossccybasisswap.hpp.

◆ recSpread_

Spread recSpread_
private

Definition at line 118 of file crossccybasisswap.hpp.

◆ recGearing_

Real recGearing_
private

Definition at line 119 of file crossccybasisswap.hpp.

◆ payPaymentLag_

Size payPaymentLag_
private

Definition at line 121 of file crossccybasisswap.hpp.

◆ recPaymentLag_

Size recPaymentLag_
private

Definition at line 122 of file crossccybasisswap.hpp.

◆ payIncludeSpread_

boost::optional<bool> payIncludeSpread_
private

Definition at line 124 of file crossccybasisswap.hpp.

◆ payLookback_

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

Definition at line 125 of file crossccybasisswap.hpp.

◆ payFixingDays_

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

Definition at line 126 of file crossccybasisswap.hpp.

◆ payRateCutoff_

boost::optional<Size> payRateCutoff_
private

Definition at line 127 of file crossccybasisswap.hpp.

◆ payIsAveraged_

boost::optional<bool> payIsAveraged_
private

Definition at line 128 of file crossccybasisswap.hpp.

◆ recIncludeSpread_

boost::optional<bool> recIncludeSpread_
private

Definition at line 129 of file crossccybasisswap.hpp.

◆ recLookback_

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

Definition at line 130 of file crossccybasisswap.hpp.

◆ recFixingDays_

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

Definition at line 131 of file crossccybasisswap.hpp.

◆ recRateCutoff_

boost::optional<Size> recRateCutoff_
private

Definition at line 132 of file crossccybasisswap.hpp.

◆ recIsAveraged_

boost::optional<bool> recIsAveraged_
private

Definition at line 133 of file crossccybasisswap.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_
private

Definition at line 134 of file crossccybasisswap.hpp.

◆ fairPaySpread_

Spread fairPaySpread_
mutableprivate

Definition at line 136 of file crossccybasisswap.hpp.

◆ fairRecSpread_

Spread fairRecSpread_
mutableprivate

Definition at line 137 of file crossccybasisswap.hpp.