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

#include <qle/instruments/crossccyfixfloatswap.hpp>

+ Inheritance diagram for CrossCcyFixFloatSwap:
+ Collaboration diagram for CrossCcyFixFloatSwap:

Classes

class  arguments
 
class  results
 

Public Types

enum  Type { Receiver = -1 , Payer = 1 }
 

Public Member Functions

Constructors
 CrossCcyFixFloatSwap (Type type, QuantLib::Real fixedNominal, const QuantLib::Currency &fixedCurrency, const QuantLib::Schedule &fixedSchedule, QuantLib::Rate fixedRate, const QuantLib::DayCounter &fixedDayCount, QuantLib::BusinessDayConvention fixedPaymentBdc, QuantLib::Natural fixedPaymentLag, const QuantLib::Calendar &fixedPaymentCalendar, QuantLib::Real floatNominal, const QuantLib::Currency &floatCurrency, const QuantLib::Schedule &floatSchedule, const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &floatIndex, QuantLib::Spread floatSpread, QuantLib::BusinessDayConvention floatPaymentBdc, QuantLib::Natural floatPaymentLag, const QuantLib::Calendar &floatPaymentCalendar)
 Detailed constructor. More...
 
Inspectors
Type type () const
 
QuantLib::Real fixedNominal () const
 
const QuantLib::Currency & fixedCurrency () const
 
const QuantLib::Schedule & fixedSchedule () const
 
QuantLib::Rate fixedRate () const
 
const QuantLib::DayCounter & fixedDayCount () const
 
QuantLib::BusinessDayConvention fixedPaymentBdc () const
 
QuantLib::Natural fixedPaymentLag () const
 
const QuantLib::Calendar & fixedPaymentCalendar () const
 
QuantLib::Real floatNominal () const
 
const QuantLib::Currency & floatCurrency () const
 
const QuantLib::Schedule & floatSchedule () const
 
const QuantLib::ext::shared_ptr< QuantLib::IborIndex > & floatIndex () const
 
QuantLib::Rate floatSpread () const
 
QuantLib::BusinessDayConvention floatPaymentBdc () const
 
QuantLib::Natural floatPaymentLag () const
 
const QuantLib::Calendar & floatPaymentCalendar () const
 
Additional interface
QuantLib::Rate fairFixedRate () const
 
QuantLib::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

Type type_
 
QuantLib::Real fixedNominal_
 
QuantLib::Currency fixedCurrency_
 
QuantLib::Schedule fixedSchedule_
 
QuantLib::Rate fixedRate_
 
QuantLib::DayCounter fixedDayCount_
 
QuantLib::BusinessDayConvention fixedPaymentBdc_
 
QuantLib::Natural fixedPaymentLag_
 
QuantLib::Calendar fixedPaymentCalendar_
 
QuantLib::Real floatNominal_
 
QuantLib::Currency floatCurrency_
 
QuantLib::Schedule floatSchedule_
 
QuantLib::ext::shared_ptr< QuantLib::IborIndex > floatIndex_
 
QuantLib::Spread floatSpread_
 
QuantLib::BusinessDayConvention floatPaymentBdc_
 
QuantLib::Natural floatPaymentLag_
 
QuantLib::Calendar floatPaymentCalendar_
 
QuantLib::Rate fairFixedRate_
 
QuantLib::Spread fairSpread_
 
void setupArguments (QuantLib::PricingEngine::arguments *a) const override
 
void fetchResults (const QuantLib::PricingEngine::results *r) const override
 
void setupExpired () const override
 

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 fixed vs float swap

Definition at line 36 of file crossccyfixfloatswap.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Receiver 
Payer 

Definition at line 38 of file crossccyfixfloatswap.hpp.

Constructor & Destructor Documentation

◆ CrossCcyFixFloatSwap()

CrossCcyFixFloatSwap ( Type  type,
QuantLib::Real  fixedNominal,
const QuantLib::Currency &  fixedCurrency,
const QuantLib::Schedule &  fixedSchedule,
QuantLib::Rate  fixedRate,
const QuantLib::DayCounter &  fixedDayCount,
QuantLib::BusinessDayConvention  fixedPaymentBdc,
QuantLib::Natural  fixedPaymentLag,
const QuantLib::Calendar &  fixedPaymentCalendar,
QuantLib::Real  floatNominal,
const QuantLib::Currency &  floatCurrency,
const QuantLib::Schedule &  floatSchedule,
const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &  floatIndex,
QuantLib::Spread  floatSpread,
QuantLib::BusinessDayConvention  floatPaymentBdc,
QuantLib::Natural  floatPaymentLag,
const QuantLib::Calendar &  floatPaymentCalendar 
)

Detailed constructor.

Definition at line 28 of file crossccyfixfloatswap.cpp.

40
41 // Build the float leg
42 Leg floatLeg = IborLeg(floatSchedule_, floatIndex_)
43 .withNotionals(floatNominal_)
44 .withSpreads(floatSpread_)
45 .withPaymentAdjustment(floatPaymentBdc_)
46 .withPaymentLag(floatPaymentLag_)
47 .withPaymentCalendar(floatPaymentCalendar_);
48
49 // Register with each floating rate coupon
50 for (Leg::const_iterator it = floatLeg.begin(); it < floatLeg.end(); ++it)
51 registerWith(*it);
52
53 // Initial notional exchange
54 Date aDate = floatSchedule_.dates().front();
55 aDate = floatPaymentCalendar_.adjust(aDate, floatPaymentBdc_);
56 QuantLib::ext::shared_ptr<CashFlow> aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(-floatNominal_, aDate);
57 floatLeg.insert(floatLeg.begin(), aCashflow);
58
59 // Final notional exchange
60 aDate = floatLeg.back()->date();
61 aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(floatNominal_, aDate);
62 floatLeg.push_back(aCashflow);
63
64 // Build the fixed rate leg
65 Leg fixedLeg = FixedRateLeg(fixedSchedule_)
66 .withNotionals(fixedNominal_)
67 .withCouponRates(fixedRate_, fixedDayCount_)
68 .withPaymentAdjustment(fixedPaymentBdc_)
69 .withPaymentLag(fixedPaymentLag)
70 .withPaymentCalendar(fixedPaymentCalendar);
71
72 // Initial notional exchange
73 aDate = fixedSchedule_.dates().front();
74 aDate = fixedPaymentCalendar_.adjust(aDate, fixedPaymentBdc_);
75 aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(-fixedNominal_, aDate);
76 fixedLeg.insert(fixedLeg.begin(), aCashflow);
77
78 // Final notional exchange
79 aDate = fixedLeg.back()->date();
80 aCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(fixedNominal_, aDate);
81 fixedLeg.push_back(aCashflow);
82
83 // Deriving from cross currency swap where:
84 // First leg should hold the pay flows
85 // Second leg should hold the receive flows
86 payer_[0] = -1.0;
87 payer_[1] = 1.0;
88 switch (type_) {
89 case Payer:
90 legs_[0] = fixedLeg;
92 legs_[1] = floatLeg;
94 break;
95 case Receiver:
96 legs_[1] = fixedLeg;
98 legs_[0] = floatLeg;
100 break;
101 default:
102 QL_FAIL("Unknown cross currency fix float swap type");
103 }
104}
QuantLib::ext::shared_ptr< QuantLib::IborIndex > floatIndex_
const QuantLib::Calendar & floatPaymentCalendar() const
const QuantLib::Currency & floatCurrency() const
const QuantLib::Schedule & fixedSchedule() const
QuantLib::Natural floatPaymentLag() const
const QuantLib::Calendar & fixedPaymentCalendar() const
const QuantLib::DayCounter & fixedDayCount() const
QuantLib::Natural fixedPaymentLag() const
QuantLib::BusinessDayConvention floatPaymentBdc() const
QuantLib::BusinessDayConvention fixedPaymentBdc() const
const QuantLib::Schedule & floatSchedule() const
QuantLib::BusinessDayConvention floatPaymentBdc_
const QuantLib::ext::shared_ptr< QuantLib::IborIndex > & floatIndex() const
const QuantLib::Currency & fixedCurrency() const
QuantLib::BusinessDayConvention fixedPaymentBdc_
CrossCcySwap(const Leg &firstLeg, const Currency &firstLegCcy, const Leg &secondLeg, const Currency &secondLegCcy)
First leg is paid and the second is received.
std::vector< Currency > currencies_
+ Here is the call graph for this function:

Member Function Documentation

◆ setupArguments()

void setupArguments ( QuantLib::PricingEngine::arguments a) const
override

Definition at line 106 of file crossccyfixfloatswap.cpp.

106 {
108 if (CrossCcyFixFloatSwap::arguments* args = dynamic_cast<CrossCcyFixFloatSwap::arguments*>(a)) {
109 args->fixedRate = fixedRate_;
110 args->spread = floatSpread_;
111 }
112}
void setupArguments(PricingEngine::arguments *args) const override
+ Here is the call graph for this function:

◆ fetchResults()

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

Definition at line 114 of file crossccyfixfloatswap.cpp.

114 {
115
117
118 // Depending on the pricing engine used, we may have CrossCcyFixFloatSwap::results
119 if (const CrossCcyFixFloatSwap::results* res = dynamic_cast<const CrossCcyFixFloatSwap::results*>(r)) {
120 // If we have CrossCcyFixFloatSwap::results from the pricing engine
121 fairFixedRate_ = res->fairFixedRate;
122 fairSpread_ = res->fairSpread;
123 } else {
124 // If not, set them to Null to indicate a calculation is needed below
125 fairFixedRate_ = Null<Rate>();
126 fairSpread_ = Null<Spread>();
127 }
128
129 // Calculate fair rate and spread if they are still Null here
130 static Spread basisPoint = 1.0e-4;
131
132 Size idxFixed = type_ == Payer ? 0 : 1;
133 if (fairFixedRate_ == Null<Rate>() && legBPS_[idxFixed] != Null<Real>())
134 fairFixedRate_ = fixedRate_ - NPV_ / (legBPS_[idxFixed] / basisPoint);
135
136 Size idxFloat = type_ == Payer ? 1 : 0;
137 if (fairSpread_ == Null<Spread>() && legBPS_[idxFloat] != Null<Real>())
138 fairSpread_ = floatSpread_ - NPV_ / (legBPS_[idxFloat] / basisPoint);
139}
void fetchResults(const PricingEngine::results *) const override
+ Here is the call graph for this function:

◆ type()

Type type ( ) const

Definition at line 64 of file crossccyfixfloatswap.hpp.

64{ return type_; }

◆ fixedNominal()

QuantLib::Real fixedNominal ( ) const

Definition at line 66 of file crossccyfixfloatswap.hpp.

66{ return fixedNominal_; }

◆ fixedCurrency()

const QuantLib::Currency & fixedCurrency ( ) const

Definition at line 67 of file crossccyfixfloatswap.hpp.

67{ return fixedCurrency_; }

◆ fixedSchedule()

const QuantLib::Schedule & fixedSchedule ( ) const

Definition at line 68 of file crossccyfixfloatswap.hpp.

68{ return fixedSchedule_; }

◆ fixedRate()

QuantLib::Rate fixedRate ( ) const

Definition at line 69 of file crossccyfixfloatswap.hpp.

69{ return fixedRate_; }

◆ fixedDayCount()

const QuantLib::DayCounter & fixedDayCount ( ) const

Definition at line 70 of file crossccyfixfloatswap.hpp.

70{ return fixedDayCount_; }

◆ fixedPaymentBdc()

QuantLib::BusinessDayConvention fixedPaymentBdc ( ) const

Definition at line 71 of file crossccyfixfloatswap.hpp.

71{ return fixedPaymentBdc_; }

◆ fixedPaymentLag()

QuantLib::Natural fixedPaymentLag ( ) const

Definition at line 72 of file crossccyfixfloatswap.hpp.

72{ return fixedPaymentLag_; }
+ Here is the caller graph for this function:

◆ fixedPaymentCalendar()

const QuantLib::Calendar & fixedPaymentCalendar ( ) const

Definition at line 73 of file crossccyfixfloatswap.hpp.

73{ return fixedPaymentCalendar_; }
+ Here is the caller graph for this function:

◆ floatNominal()

QuantLib::Real floatNominal ( ) const

Definition at line 75 of file crossccyfixfloatswap.hpp.

75{ return floatNominal_; }

◆ floatCurrency()

const QuantLib::Currency & floatCurrency ( ) const

Definition at line 76 of file crossccyfixfloatswap.hpp.

76{ return floatCurrency_; }

◆ floatSchedule()

const QuantLib::Schedule & floatSchedule ( ) const

Definition at line 77 of file crossccyfixfloatswap.hpp.

77{ return floatSchedule_; }

◆ floatIndex()

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

Definition at line 78 of file crossccyfixfloatswap.hpp.

78{ return floatIndex_; }

◆ floatSpread()

QuantLib::Rate floatSpread ( ) const

Definition at line 79 of file crossccyfixfloatswap.hpp.

79{ return floatSpread_; }

◆ floatPaymentBdc()

QuantLib::BusinessDayConvention floatPaymentBdc ( ) const

Definition at line 80 of file crossccyfixfloatswap.hpp.

80{ return floatPaymentBdc_; }

◆ floatPaymentLag()

QuantLib::Natural floatPaymentLag ( ) const

Definition at line 81 of file crossccyfixfloatswap.hpp.

81{ return floatPaymentLag_; }

◆ floatPaymentCalendar()

const QuantLib::Calendar & floatPaymentCalendar ( ) const

Definition at line 82 of file crossccyfixfloatswap.hpp.

82{ return floatPaymentCalendar_; }

◆ fairFixedRate()

QuantLib::Rate fairFixedRate ( ) const

Definition at line 87 of file crossccyfixfloatswap.hpp.

87 {
88 calculate();
89 QL_REQUIRE(fairFixedRate_ != QuantLib::Null<QuantLib::Real>(), "Fair fixed rate is not available");
90 return fairFixedRate_;
91 }
+ Here is the caller graph for this function:

◆ fairSpread()

QuantLib::Spread fairSpread ( ) const

Definition at line 93 of file crossccyfixfloatswap.hpp.

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

◆ setupExpired()

void setupExpired ( ) const
overrideprotected

Definition at line 141 of file crossccyfixfloatswap.cpp.

141 {
143 fairFixedRate_ = Null<Rate>();
144 fairSpread_ = Null<Spread>();
145}
void setupExpired() const override
+ Here is the call graph for this function:

Member Data Documentation

◆ type_

Type type_
private

Definition at line 107 of file crossccyfixfloatswap.hpp.

◆ fixedNominal_

QuantLib::Real fixedNominal_
private

Definition at line 109 of file crossccyfixfloatswap.hpp.

◆ fixedCurrency_

QuantLib::Currency fixedCurrency_
private

Definition at line 110 of file crossccyfixfloatswap.hpp.

◆ fixedSchedule_

QuantLib::Schedule fixedSchedule_
private

Definition at line 111 of file crossccyfixfloatswap.hpp.

◆ fixedRate_

QuantLib::Rate fixedRate_
private

Definition at line 112 of file crossccyfixfloatswap.hpp.

◆ fixedDayCount_

QuantLib::DayCounter fixedDayCount_
private

Definition at line 113 of file crossccyfixfloatswap.hpp.

◆ fixedPaymentBdc_

QuantLib::BusinessDayConvention fixedPaymentBdc_
private

Definition at line 114 of file crossccyfixfloatswap.hpp.

◆ fixedPaymentLag_

QuantLib::Natural fixedPaymentLag_
private

Definition at line 115 of file crossccyfixfloatswap.hpp.

◆ fixedPaymentCalendar_

QuantLib::Calendar fixedPaymentCalendar_
private

Definition at line 116 of file crossccyfixfloatswap.hpp.

◆ floatNominal_

QuantLib::Real floatNominal_
private

Definition at line 118 of file crossccyfixfloatswap.hpp.

◆ floatCurrency_

QuantLib::Currency floatCurrency_
private

Definition at line 119 of file crossccyfixfloatswap.hpp.

◆ floatSchedule_

QuantLib::Schedule floatSchedule_
private

Definition at line 120 of file crossccyfixfloatswap.hpp.

◆ floatIndex_

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

Definition at line 121 of file crossccyfixfloatswap.hpp.

◆ floatSpread_

QuantLib::Spread floatSpread_
private

Definition at line 122 of file crossccyfixfloatswap.hpp.

◆ floatPaymentBdc_

QuantLib::BusinessDayConvention floatPaymentBdc_
private

Definition at line 123 of file crossccyfixfloatswap.hpp.

◆ floatPaymentLag_

QuantLib::Natural floatPaymentLag_
private

Definition at line 124 of file crossccyfixfloatswap.hpp.

◆ floatPaymentCalendar_

QuantLib::Calendar floatPaymentCalendar_
private

Definition at line 125 of file crossccyfixfloatswap.hpp.

◆ fairFixedRate_

QuantLib::Rate fairFixedRate_
mutableprivate

Definition at line 127 of file crossccyfixfloatswap.hpp.

◆ fairSpread_

QuantLib::Spread fairSpread_
mutableprivate

Definition at line 128 of file crossccyfixfloatswap.hpp.