Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CrossCcyFixFloatSwapHelper Class Reference

Cross currency fix vs. float swap helper. More...

#include <qle/termstructures/crossccyfixfloatswaphelper.hpp>

+ Inheritance diagram for CrossCcyFixFloatSwapHelper:
+ Collaboration diagram for CrossCcyFixFloatSwapHelper:

Public Member Functions

 CrossCcyFixFloatSwapHelper (const QuantLib::Handle< QuantLib::Quote > &rate, const QuantLib::Handle< QuantLib::Quote > &spotFx, QuantLib::Natural settlementDays, const QuantLib::Calendar &paymentCalendar, QuantLib::BusinessDayConvention paymentConvention, const QuantLib::Period &tenor, const QuantLib::Currency &fixedCurrency, QuantLib::Frequency fixedFrequency, QuantLib::BusinessDayConvention fixedConvention, const QuantLib::DayCounter &fixedDayCount, const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &index, const QuantLib::Handle< QuantLib::YieldTermStructure > &floatDiscount, const Handle< Quote > &spread=Handle< Quote >(), bool endOfMonth=false)
 
Observer interface
void update () override
 
BootstrapHelper interface
QuantLib::Real impliedQuote () const override
 
void setTermStructure (QuantLib::YieldTermStructure *) override
 
Inspectors
QuantLib::ext::shared_ptr< CrossCcyFixFloatSwapswap () const
 
Visitability
void accept (QuantLib::AcyclicVisitor &) override
 

RelativeDateBootstrapHelper interface

QuantLib::Handle< QuantLib::Quote > spotFx_
 
QuantLib::Natural settlementDays_
 
QuantLib::Calendar paymentCalendar_
 
QuantLib::BusinessDayConvention paymentConvention_
 
QuantLib::Period tenor_
 
QuantLib::Currency fixedCurrency_
 
QuantLib::Frequency fixedFrequency_
 
QuantLib::BusinessDayConvention fixedConvention_
 
QuantLib::DayCounter fixedDayCount_
 
QuantLib::ext::shared_ptr< QuantLib::IborIndex > index_
 
QuantLib::Handle< QuantLib::YieldTermStructure > floatDiscount_
 
QuantLib::Handle< QuantLib::Quote > spread_
 
bool endOfMonth_
 
QuantLib::ext::shared_ptr< CrossCcyFixFloatSwapswap_
 
QuantLib::RelinkableHandle< QuantLib::YieldTermStructure > termStructureHandle_
 
void initializeDates () override
 

Detailed Description

Cross currency fix vs. float swap helper.

Rate helper for bootstrapping with fixed vs. float cross currency swaps

Definition at line 39 of file crossccyfixfloatswaphelper.hpp.

Constructor & Destructor Documentation

◆ CrossCcyFixFloatSwapHelper()

CrossCcyFixFloatSwapHelper ( const QuantLib::Handle< QuantLib::Quote > &  rate,
const QuantLib::Handle< QuantLib::Quote > &  spotFx,
QuantLib::Natural  settlementDays,
const QuantLib::Calendar &  paymentCalendar,
QuantLib::BusinessDayConvention  paymentConvention,
const QuantLib::Period &  tenor,
const QuantLib::Currency &  fixedCurrency,
QuantLib::Frequency  fixedFrequency,
QuantLib::BusinessDayConvention  fixedConvention,
const QuantLib::DayCounter &  fixedDayCount,
const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &  index,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  floatDiscount,
const Handle< Quote > &  spread = Handle<Quote>(),
bool  endOfMonth = false 
)

Definition at line 33 of file crossccyfixfloatswaphelper.cpp.

39 : RelativeDateRateHelper(rate), spotFx_(spotFx), settlementDays_(settlementDays), paymentCalendar_(paymentCalendar),
40 paymentConvention_(paymentConvention), tenor_(tenor), fixedCurrency_(fixedCurrency),
41 fixedFrequency_(fixedFrequency), fixedConvention_(fixedConvention), fixedDayCount_(fixedDayCount), index_(index),
42 floatDiscount_(floatDiscount), spread_(spread), endOfMonth_(endOfMonth) {
43
44 QL_REQUIRE(!spotFx_.empty(), "Spot FX quote cannot be empty.");
45 QL_REQUIRE(fixedCurrency_ != index_->currency(), "Fixed currency should not equal float leg currency.");
46
47 registerWith(spotFx_);
48 registerWith(index_);
49 registerWith(floatDiscount_);
50 registerWith(spread_);
51
53}
QuantLib::Handle< QuantLib::Quote > spotFx_
QuantLib::BusinessDayConvention paymentConvention_
QuantLib::Handle< QuantLib::Quote > spread_
QuantLib::BusinessDayConvention fixedConvention_
QuantLib::Handle< QuantLib::YieldTermStructure > floatDiscount_
QuantLib::ext::shared_ptr< QuantLib::IborIndex > index_
RelativeDateBootstrapHelper< YieldTermStructure > RelativeDateRateHelper
+ Here is the call graph for this function:

Member Function Documentation

◆ update()

void update ( )
override

Definition at line 55 of file crossccyfixfloatswaphelper.cpp.

55 {
56 // Maybe FX spot quote or spread quote changed
57 if (!close(spotFx_->value(), swap_->fixedNominal()) ||
58 (!spread_.empty() && !close(spread_->value(), swap_->floatSpread()))) {
60 }
61
62 // Maybe evaluation date changed. RelativeDateRateHelper will take care of this
63 // Note: if initializeDates() was called in above if statement, it will not be called
64 // again in RelativeDateRateHelper::update() because evaluationDate_ is set in
65 // initializeDates(). So, redundant instrument builds are avoided.
66 RelativeDateRateHelper::update();
67}
QuantLib::ext::shared_ptr< CrossCcyFixFloatSwap > swap_
+ Here is the call graph for this function:

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 69 of file crossccyfixfloatswaphelper.cpp.

69 {
70 QL_REQUIRE(termStructure_, "Term structure needs to be set");
71 swap_->deepUpdate();
72 return swap_->fairFixedRate();
73}

◆ setTermStructure()

void setTermStructure ( QuantLib::YieldTermStructure *  yts)
override

Definition at line 75 of file crossccyfixfloatswaphelper.cpp.

75 {
76 QuantLib::ext::shared_ptr<YieldTermStructure> temp(yts, null_deleter());
77 termStructureHandle_.linkTo(temp, false);
78 RelativeDateRateHelper::setTermStructure(yts);
79}
QuantLib::RelinkableHandle< QuantLib::YieldTermStructure > termStructureHandle_

◆ swap()

QuantLib::ext::shared_ptr< CrossCcyFixFloatSwap > swap ( ) const

Definition at line 65 of file crossccyfixfloatswaphelper.hpp.

65{ return swap_; }

◆ accept()

void accept ( QuantLib::AcyclicVisitor &  )
override

Definition at line 81 of file crossccyfixfloatswaphelper.cpp.

81 {
82 if (Visitor<CrossCcyFixFloatSwapHelper>* v1 = dynamic_cast<Visitor<CrossCcyFixFloatSwapHelper>*>(&v))
83 v1->visit(*this);
84 else
85 RateHelper::accept(v);
86}

◆ initializeDates()

void initializeDates ( )
overrideprivate

Definition at line 88 of file crossccyfixfloatswaphelper.cpp.

88 {
89
90 // Swap start and end
91 Date referenceDate = evaluationDate_ = Settings::instance().evaluationDate();
92 referenceDate = paymentCalendar_.adjust(referenceDate);
93 Date start = paymentCalendar_.advance(referenceDate, settlementDays_ * Days);
94 Date end = start + tenor_;
95
96 // Nominals
97 Real floatNominal = 1.0;
98 Real fixedNominal = spotFx_->value();
99
100 // Fixed schedule
101 Schedule fixedSchedule(start, end, Period(fixedFrequency_), paymentCalendar_, fixedConvention_, fixedConvention_,
102 DateGeneration::Backward, endOfMonth_);
103
104 // Float schedule
105 Schedule floatSchedule(start, end, index_->tenor(), paymentCalendar_, paymentConvention_, paymentConvention_,
106 DateGeneration::Backward, endOfMonth_);
107
108 // Create the swap
109 Natural paymentLag = 0;
110 Spread floatSpread = spread_.empty() ? 0.0 : spread_->value();
111 swap_.reset(new CrossCcyFixFloatSwap(CrossCcyFixFloatSwap::Payer, fixedNominal, fixedCurrency_, fixedSchedule, 0.0,
112 fixedDayCount_, paymentConvention_, paymentLag, paymentCalendar_, floatNominal,
113 index_->currency(), floatSchedule, index_, floatSpread, paymentConvention_,
114 paymentLag, paymentCalendar_));
115
116 earliestDate_ = swap_->startDate();
117 maturityDate_ = swap_->maturityDate();
118
119 // Swap is Payer => first leg is fixed leg
120 latestRelevantDate_ = earliestDate_;
121 for (Size i = 0; i < swap_->leg(0).size(); ++i) {
122 latestRelevantDate_ = std::max(latestRelevantDate_, swap_->leg(0)[i]->date());
123 }
124 pillarDate_ = latestDate_ = latestRelevantDate_;
125
126 // Attach engine
127 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<CrossCcySwapEngine>(
129 swap_->setPricingEngine(engine);
130}
+ Here is the caller graph for this function:

Member Data Documentation

◆ spotFx_

QuantLib::Handle<QuantLib::Quote> spotFx_
private

Definition at line 79 of file crossccyfixfloatswaphelper.hpp.

◆ settlementDays_

QuantLib::Natural settlementDays_
private

Definition at line 80 of file crossccyfixfloatswaphelper.hpp.

◆ paymentCalendar_

QuantLib::Calendar paymentCalendar_
private

Definition at line 81 of file crossccyfixfloatswaphelper.hpp.

◆ paymentConvention_

QuantLib::BusinessDayConvention paymentConvention_
private

Definition at line 82 of file crossccyfixfloatswaphelper.hpp.

◆ tenor_

QuantLib::Period tenor_
private

Definition at line 83 of file crossccyfixfloatswaphelper.hpp.

◆ fixedCurrency_

QuantLib::Currency fixedCurrency_
private

Definition at line 84 of file crossccyfixfloatswaphelper.hpp.

◆ fixedFrequency_

QuantLib::Frequency fixedFrequency_
private

Definition at line 85 of file crossccyfixfloatswaphelper.hpp.

◆ fixedConvention_

QuantLib::BusinessDayConvention fixedConvention_
private

Definition at line 86 of file crossccyfixfloatswaphelper.hpp.

◆ fixedDayCount_

QuantLib::DayCounter fixedDayCount_
private

Definition at line 87 of file crossccyfixfloatswaphelper.hpp.

◆ index_

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

Definition at line 88 of file crossccyfixfloatswaphelper.hpp.

◆ floatDiscount_

QuantLib::Handle<QuantLib::YieldTermStructure> floatDiscount_
private

Definition at line 89 of file crossccyfixfloatswaphelper.hpp.

◆ spread_

QuantLib::Handle<QuantLib::Quote> spread_
private

Definition at line 90 of file crossccyfixfloatswaphelper.hpp.

◆ endOfMonth_

bool endOfMonth_
private

Definition at line 91 of file crossccyfixfloatswaphelper.hpp.

◆ swap_

QuantLib::ext::shared_ptr<CrossCcyFixFloatSwap> swap_
private

Definition at line 93 of file crossccyfixfloatswaphelper.hpp.

◆ termStructureHandle_

QuantLib::RelinkableHandle<QuantLib::YieldTermStructure> termStructureHandle_
private

Definition at line 94 of file crossccyfixfloatswaphelper.hpp.