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

#include <qle/models/dkimpliedyoyinflationtermstructure.hpp>

+ Inheritance diagram for DkImpliedYoYInflationTermStructure:
+ Collaboration diagram for DkImpliedYoYInflationTermStructure:

Public Member Functions

 DkImpliedYoYInflationTermStructure (const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index, bool indexIsInterpolated)
 
- Public Member Functions inherited from YoYInflationModelTermStructure
 YoYInflationModelTermStructure (const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index, bool indexIsInterpolated)
 
void update () override
 
QuantLib::Date maxDate () const override
 
QuantLib::Time maxTime () const override
 
const QuantLib::Date & referenceDate () const override
 
QuantLib::Date baseDate () const override
 
virtual void referenceDate (const QuantLib::Date &d)
 Set the reference date. More...
 
void state (const QuantLib::Array &s)
 Set the current state variables. More...
 
void move (const QuantLib::Date &d, const QuantLib::Array &s)
 Set the current state and move the reference date to date d. More...
 
QuantLib::Real yoyRate (const QuantLib::Date &d, const QuantLib::Period &obsLag=-1 *QuantLib::Days, bool forceLinearInterpolation=false, bool extrapolate=false) const
 

YoYInflationModelTermStructure interface

std::map< QuantLib::Date, QuantLib::Real > yoyRates (const std::vector< QuantLib::Date > &dates, const QuantLib::Period &obsLag=-1 *QuantLib::Days) const override
 
QuantLib::Real yoySwapletRate (QuantLib::Time S, QuantLib::Time T) const
 
void checkState () const override
 

Additional Inherited Members

- Protected Member Functions inherited from YoYInflationModelTermStructure
QuantLib::Real yoyRateImpl (QuantLib::Time t) const override
 This cannot be called. The implementation is set to throw an exception. More...
 
- Protected Attributes inherited from YoYInflationModelTermStructure
QuantLib::ext::shared_ptr< CrossAssetModelmodel_
 
QuantLib::Size index_
 
bool indexIsInterpolated_
 
QuantLib::Date referenceDate_
 
QuantLib::Time relativeTime_
 
QuantLib::Array state_
 

Detailed Description

Dodgson Kainth (DK) implied year on year inflation term structure

Definition at line 35 of file dkimpliedyoyinflationtermstructure.hpp.

Constructor & Destructor Documentation

◆ DkImpliedYoYInflationTermStructure()

DkImpliedYoYInflationTermStructure ( const QuantLib::ext::shared_ptr< CrossAssetModel > &  model,
QuantLib::Size  index,
bool  indexIsInterpolated 
)

Constructor taking the cross asset model, model, and the index of the relevant inflation component within the model, index.

Definition at line 33 of file dkimpliedyoyinflationtermstructure.cpp.

35 : YoYInflationModelTermStructure(model, index, indexIsInterpolated) {}
YoYInflationModelTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index, bool indexIsInterpolated)

Member Function Documentation

◆ yoyRates()

map< Date, Real > yoyRates ( const std::vector< QuantLib::Date > &  dates,
const QuantLib::Period &  obsLag = -1 *QuantLib::Days 
) const
overridevirtual

Return the year-on-year rates for the maturities associated with dates. If an obsLag is explicitly provided and not set to -1 * QuantLib::Days, it is used as the observation lag. Otherwise, the term structure's observation lag is used.

Implements YoYInflationModelTermStructure.

Definition at line 37 of file dkimpliedyoyinflationtermstructure.cpp.

37 {
38
39 map<Date, Real> yoys;
40 map<Date, Real> yoyswaplet;
41 map<Date, Real> yoydiscount;
42 Period useLag = obsLag == -1 * Days ? observationLag() : obsLag;
43 Calendar cal = model_->infdk(index_)->termStructure()->calendar();
44 DayCounter dc = model_->infdk(index_)->termStructure()->dayCounter();
45 Date maturity;
46
47 for (Size j = 0; j < dts.size(); j++) {
48
50 maturity = dts[j] - useLag;
51 } else {
52 maturity = inflationPeriod(dts[j] - useLag, frequency()).first;
53 }
54
55 Schedule schedule = MakeSchedule()
56 .from(baseDate())
57 .to(maturity)
58 .withTenor(1 * Years)
59 .withConvention(Unadjusted)
60 .withCalendar(cal)
61 .backwards();
62
63 Real yoyLegRate = 0.0;
64 Real fixedDiscounts = 0.0;
65 for (Size i = 1; i < schedule.dates().size(); i++) {
66 map<Date, Real>::const_iterator it = yoyswaplet.find(schedule.dates()[i]);
67 Real swapletPrice, discount;
68 if (it == yoyswaplet.end()) {
69 if (schedule.dates()[i - 1] < baseDate()) {
70 // for the first YoY swaplet, I(T_i-1) is known, obtained from a fixing. I(T_i) comes from the model
71 // directly - I(t) * Itilde(t,T).
72 Time t1 = dayCounter().yearFraction(model_->infdk(index_)->termStructure()->baseDate(),
73 schedule.dates()[i - 1]);
74 Real I1 = model_->infdkI(index_, t1, t1, state_[0], state_[1]).first;
75 Time t2 = dc.yearFraction(baseDate(), schedule.dates()[i]);
76 std::pair<Real, Real> II2 =
77 model_->infdkI(index_, relativeTime_, relativeTime_ + t2, state_[0], state_[1]);
78 Real I2 = II2.first * II2.second;
79 discount = model_->discountBond(model_->ccyIndex(model_->infdk(index_)->currency()), relativeTime_,
80 relativeTime_ + t2, state_[2]);
81 swapletPrice = discount * ((I2 / I1) - 1);
82 } else {
83 Time t1 = dc.yearFraction(baseDate(), schedule.dates()[i - 1]);
84 Time t2 = dc.yearFraction(baseDate(), schedule.dates()[i]);
85 discount = model_->discountBond(model_->ccyIndex(model_->infdk(index_)->currency()), relativeTime_,
86 relativeTime_ + t2, state_[2]);
87 swapletPrice = yoySwapletRate(t1, t2);
88 }
89 yoyswaplet[schedule.dates()[i]] = swapletPrice;
90 yoydiscount[schedule.dates()[i]] = discount;
91 } else {
92 swapletPrice = yoyswaplet[schedule.dates()[i]];
93 discount = yoydiscount[schedule.dates()[i]];
94 }
95 yoyLegRate += swapletPrice;
96 fixedDiscounts += discount;
97 }
98 Real yoyRate = (yoyLegRate / fixedDiscounts);
99
100 if (hasSeasonality()) {
101 yoyRate = seasonality()->correctYoYRate(dts[j] - useLag, yoyRate, *this);
102 }
103 yoys[dts[j]] = yoyRate;
104 }
105
106 return yoys;
107}
QuantLib::Real yoySwapletRate(QuantLib::Time S, QuantLib::Time T) const
QuantLib::ext::shared_ptr< CrossAssetModel > model_
QuantLib::Real yoyRate(const QuantLib::Date &d, const QuantLib::Period &obsLag=-1 *QuantLib::Days, bool forceLinearInterpolation=false, bool extrapolate=false) const
+ Here is the call graph for this function:

◆ yoySwapletRate()

Real yoySwapletRate ( QuantLib::Time  S,
QuantLib::Time  T 
) const
protected

Definition at line 109 of file dkimpliedyoyinflationtermstructure.cpp.

109 {
110 return model_->infdkYY(index_, relativeTime_, relativeTime_ + S,
111 relativeTime_ + T, state_[0], state_[1], state_[2]);
112}
+ Here is the caller graph for this function:

◆ checkState()

void checkState ( ) const
overrideprotectedvirtual

Override this method to perform checks on the state variable array when the state and move methods are called.

Reimplemented from YoYInflationModelTermStructure.

Definition at line 114 of file dkimpliedyoyinflationtermstructure.cpp.

114 {
115 // For DK YoY, expect the state to be three variables i.e. z_I and y_I and z_{ir}.
116 QL_REQUIRE(state_.size() == 3, "DkImpliedYoYInflationTermStructure: expected state to have " <<
117 "three elements but got " << state_.size());
118}