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

#include <qle/models/yoyswaphelper.hpp>

+ Inheritance diagram for YoYSwapHelper:
+ Collaboration diagram for YoYSwapHelper:

Public Member Functions

 YoYSwapHelper (const QuantLib::Handle< QuantLib::Quote > &rate, QuantLib::Natural settlementDays, const QuantLib::Period &tenor, const QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > &yoyIndex, const QuantLib::Handle< QuantLib::YieldTermStructure > &rateCurve, const QuantLib::Period &observationLag, const QuantLib::Calendar &yoyCalendar, QuantLib::BusinessDayConvention yoyConvention, const QuantLib::DayCounter &yoyDayCount, const QuantLib::Calendar &fixedCalendar, QuantLib::BusinessDayConvention fixedConvention, const QuantLib::DayCounter &fixedDayCount, const QuantLib::Calendar &paymentCalendar, QuantLib::BusinessDayConvention paymentConvention, const QuantLib::Period &fixedTenor=1 *QuantLib::Years, const QuantLib::Period &yoyTenor=1 *QuantLib::Years)
 Year on year helper constructor. More...
 
CalibrationHelper interface
QuantLib::Real calibrationError () override
 
Observer interface
void update () override
 

YoYSwapHelper inspectors

QuantLib::Handle< QuantLib::Quote > rate_
 The YoY market swap quote. More...
 
QuantLib::ext::shared_ptr< QuantLib::YearOnYearInflationSwap > yoySwap_
 The underlying YoY swap. More...
 
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engine_
 The pricing engine used to value the YoY swap. More...
 
QuantLib::Date evaluationDate_
 
QuantLib::Natural settlementDays_
 
QuantLib::Period tenor_
 
QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > yoyIndex_
 
QuantLib::Handle< QuantLib::YieldTermStructure > rateCurve_
 
QuantLib::Period observationLag_
 
QuantLib::Calendar yoyCalendar_
 
QuantLib::BusinessDayConvention yoyConvention_
 
QuantLib::DayCounter yoyDayCount_
 
QuantLib::Calendar fixedCalendar_
 
QuantLib::BusinessDayConvention fixedConvention_
 
QuantLib::DayCounter fixedDayCount_
 
QuantLib::Calendar paymentCalendar_
 
QuantLib::BusinessDayConvention paymentConvention_
 
QuantLib::Period fixedTenor_
 
QuantLib::Period yoyTenor_
 
QuantLib::ext::shared_ptr< QuantLib::YearOnYearInflationSwap > yoySwap () const
 
void setPricingEngine (const QuantLib::ext::shared_ptr< QuantLib::PricingEngine > &engine)
 Set the pricing engine to be used by the underlying YoY swap. More...
 
QuantLib::Real marketRate () const
 Return the market fair year on year rate. More...
 
QuantLib::Real modelRate () const
 Return the model implied fair year on year rate. More...
 
void createSwap ()
 Create the underlying YoY swap. More...
 

Detailed Description

Year on year (YoY) inflation swap calibration helper.

Definition at line 35 of file yoyswaphelper.hpp.

Constructor & Destructor Documentation

◆ YoYSwapHelper()

YoYSwapHelper ( const QuantLib::Handle< QuantLib::Quote > &  rate,
QuantLib::Natural  settlementDays,
const QuantLib::Period &  tenor,
const QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > &  yoyIndex,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  rateCurve,
const QuantLib::Period &  observationLag,
const QuantLib::Calendar &  yoyCalendar,
QuantLib::BusinessDayConvention  yoyConvention,
const QuantLib::DayCounter &  yoyDayCount,
const QuantLib::Calendar &  fixedCalendar,
QuantLib::BusinessDayConvention  fixedConvention,
const QuantLib::DayCounter &  fixedDayCount,
const QuantLib::Calendar &  paymentCalendar,
QuantLib::BusinessDayConvention  paymentConvention,
const QuantLib::Period &  fixedTenor = 1 * QuantLib::Years,
const QuantLib::Period &  yoyTenor = 1 * QuantLib::Years 
)

Year on year helper constructor.

Definition at line 44 of file yoyswaphelper.cpp.

60 : rate_(rate),
61 evaluationDate_(Settings::instance().evaluationDate()),
62 settlementDays_(settlementDays),
63 tenor_(tenor),
64 yoyIndex_(yoyIndex),
65 rateCurve_(rateCurve),
66 observationLag_(observationLag),
67 yoyCalendar_(yoyCalendar),
68 yoyConvention_(yoyConvention),
69 yoyDayCount_(yoyDayCount),
70 fixedCalendar_(fixedCalendar),
71 fixedConvention_(fixedConvention),
72 fixedDayCount_(fixedDayCount),
73 paymentCalendar_(paymentCalendar),
74 paymentConvention_(paymentConvention),
75 fixedTenor_(fixedTenor),
76 yoyTenor_(yoyTenor) {
77
78 registerWith(rate_);
79 registerWith(Settings::instance().evaluationDate());
80 registerWith(yoyIndex_);
81
82 createSwap();
83}
QuantLib::DayCounter fixedDayCount_
QuantLib::Period observationLag_
QuantLib::BusinessDayConvention paymentConvention_
QuantLib::Period yoyTenor_
QuantLib::Period fixedTenor_
QuantLib::Date evaluationDate_
void createSwap()
Create the underlying YoY swap.
QuantLib::DayCounter yoyDayCount_
QuantLib::Natural settlementDays_
QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > yoyIndex_
QuantLib::BusinessDayConvention yoyConvention_
QuantLib::Calendar paymentCalendar_
QuantLib::BusinessDayConvention fixedConvention_
QuantLib::Handle< QuantLib::YieldTermStructure > rateCurve_
QuantLib::Calendar yoyCalendar_
QuantLib::Handle< QuantLib::Quote > rate_
The YoY market swap quote.
QuantLib::Calendar fixedCalendar_
QuantLib::Period tenor_
+ Here is the call graph for this function:

Member Function Documentation

◆ calibrationError()

Real calibrationError ( )
override

Definition at line 85 of file yoyswaphelper.cpp.

85 {
86 yoySwap_->setPricingEngine(engine_);
87 return rate_->value() - yoySwap_->fairRate();
88}
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engine_
The pricing engine used to value the YoY swap.
QuantLib::ext::shared_ptr< QuantLib::YearOnYearInflationSwap > yoySwap_
The underlying YoY swap.

◆ update()

void update ( )
override

Definition at line 90 of file yoyswaphelper.cpp.

90 {
91 if (evaluationDate_ != Settings::instance().evaluationDate()) {
92 evaluationDate_ = Settings::instance().evaluationDate();
93 createSwap();
94 }
95 notifyObservers();
96}
+ Here is the call graph for this function:

◆ yoySwap()

QuantLib::ext::shared_ptr< YearOnYearInflationSwap > yoySwap ( ) const

Definition at line 98 of file yoyswaphelper.cpp.

98 {
99 return yoySwap_;
100}

◆ setPricingEngine()

void setPricingEngine ( const QuantLib::ext::shared_ptr< QuantLib::PricingEngine > &  engine)

Set the pricing engine to be used by the underlying YoY swap.

Definition at line 102 of file yoyswaphelper.cpp.

102 {
103 engine_ = engine;
104}

◆ marketRate()

Real marketRate ( ) const

Return the market fair year on year rate.

Definition at line 106 of file yoyswaphelper.cpp.

106 {
107 return rate_->value();
108}

◆ modelRate()

Real modelRate ( ) const

Return the model implied fair year on year rate.

Definition at line 110 of file yoyswaphelper.cpp.

110 {
111 yoySwap_->setPricingEngine(engine_);
112 return yoySwap_->fairRate();
113}

◆ createSwap()

void createSwap ( )
private

Create the underlying YoY swap.

Definition at line 115 of file yoyswaphelper.cpp.

115 {
116
117 // YoY swap start date and end date.
118 JointCalendar jc(yoyCalendar_, fixedCalendar_);
119 auto start = jc.advance(evaluationDate_, settlementDays_ * Days);
120 auto end = start + tenor_;
121
122 // YoY fixed leg schedule.
123 Schedule fixedSchedule(start, end, fixedTenor_, fixedCalendar_, fixedConvention_,
124 fixedConvention_, DateGeneration::Backward, false);
125
126 // YoY leg schedule.
127 Schedule yoySchedule(start, end, yoyTenor_, yoyCalendar_, yoyConvention_,
128 yoyConvention_, DateGeneration::Backward, false);
129
130 // YoY swap
131 yoySwap_ = QuantLib::ext::make_shared<YearOnYearInflationSwap>(YearOnYearInflationSwap::Payer, 1.0,
132 fixedSchedule, 0.01, fixedDayCount_, yoySchedule, yoyIndex_, observationLag_, 0.0, yoyDayCount_,
134
135 // set coupon pricer
136 auto pricer = QuantLib::ext::make_shared<QuantLib::YoYInflationCouponPricer>(rateCurve_);
137 for (auto& c : yoySwap_->yoyLeg()) {
138 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<QuantLib::YoYInflationCoupon>(c))
139 cpn->setPricer(pricer);
140 }
141}
+ Here is the caller graph for this function:

Member Data Documentation

◆ rate_

QuantLib::Handle<QuantLib::Quote> rate_
private

The YoY market swap quote.

Definition at line 84 of file yoyswaphelper.hpp.

◆ yoySwap_

QuantLib::ext::shared_ptr<QuantLib::YearOnYearInflationSwap> yoySwap_
private

The underlying YoY swap.

Definition at line 87 of file yoyswaphelper.hpp.

◆ engine_

QuantLib::ext::shared_ptr<QuantLib::PricingEngine> engine_
private

The pricing engine used to value the YoY swap.

Definition at line 90 of file yoyswaphelper.hpp.

◆ evaluationDate_

QuantLib::Date evaluationDate_
private

Definition at line 93 of file yoyswaphelper.hpp.

◆ settlementDays_

QuantLib::Natural settlementDays_
private

Definition at line 94 of file yoyswaphelper.hpp.

◆ tenor_

QuantLib::Period tenor_
private

Definition at line 95 of file yoyswaphelper.hpp.

◆ yoyIndex_

QuantLib::ext::shared_ptr<QuantLib::YoYInflationIndex> yoyIndex_
private

Definition at line 96 of file yoyswaphelper.hpp.

◆ rateCurve_

QuantLib::Handle<QuantLib::YieldTermStructure> rateCurve_
private

Definition at line 97 of file yoyswaphelper.hpp.

◆ observationLag_

QuantLib::Period observationLag_
private

Definition at line 98 of file yoyswaphelper.hpp.

◆ yoyCalendar_

QuantLib::Calendar yoyCalendar_
private

Definition at line 99 of file yoyswaphelper.hpp.

◆ yoyConvention_

QuantLib::BusinessDayConvention yoyConvention_
private

Definition at line 100 of file yoyswaphelper.hpp.

◆ yoyDayCount_

QuantLib::DayCounter yoyDayCount_
private

Definition at line 101 of file yoyswaphelper.hpp.

◆ fixedCalendar_

QuantLib::Calendar fixedCalendar_
private

Definition at line 102 of file yoyswaphelper.hpp.

◆ fixedConvention_

QuantLib::BusinessDayConvention fixedConvention_
private

Definition at line 103 of file yoyswaphelper.hpp.

◆ fixedDayCount_

QuantLib::DayCounter fixedDayCount_
private

Definition at line 104 of file yoyswaphelper.hpp.

◆ paymentCalendar_

QuantLib::Calendar paymentCalendar_
private

Definition at line 105 of file yoyswaphelper.hpp.

◆ paymentConvention_

QuantLib::BusinessDayConvention paymentConvention_
private

Definition at line 106 of file yoyswaphelper.hpp.

◆ fixedTenor_

QuantLib::Period fixedTenor_
private

Definition at line 107 of file yoyswaphelper.hpp.

◆ yoyTenor_

QuantLib::Period yoyTenor_
private

Definition at line 108 of file yoyswaphelper.hpp.