Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
InterpolatedCPIVolatilitySurface< Interpolator2D > Class Template Reference

Interpolated zero inflation volatility structure. More...

#include <qle/termstructures/interpolatedcpivolatilitysurface.hpp>

+ Inheritance diagram for InterpolatedCPIVolatilitySurface< Interpolator2D >:
+ Collaboration diagram for InterpolatedCPIVolatilitySurface< Interpolator2D >:

Public Member Functions

 InterpolatedCPIVolatilitySurface (const std::vector< Period > &optionTenors, const std::vector< Real > &strikes, const std::vector< std::vector< Handle< Quote > > > quotes, const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &index, const bool quotedInstrumentsAreInterpolated, const Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc, const Period &observationLag, const Date &capFloorStartDate=Date(), const Interpolator2D &interpolator2d=Interpolator2D(), const QuantLib::VolatilityType volType=QuantLib::ShiftedLognormal, const double displacement=0.0)
 
QL_DEPRECATED InterpolatedCPIVolatilitySurface (const std::vector< Period > &optionTenors, const std::vector< Real > &strikes, const std::vector< std::vector< Handle< Quote > > > quotes, const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &index, const Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc, const Period &observationLag, const Date &capFloorStartDate=Date(), const Interpolator2D &interpolator2d=Interpolator2D(), const QuantLib::VolatilityType volType=QuantLib::ShiftedLognormal, const double displacement=0.0)
 
LazyObject interface
void performCalculations () const override
 
void update () override
 
Limits
QuantLib::Real minStrike () const override
 the minimum strike for which the term structure can return vols More...
 
QuantLib::Real maxStrike () const override
 the maximum strike for which the term structure can return vols More...
 
QuantLib::Date maxDate () const override
 maximum date for which the term structure can return vols More...
 
- Public Member Functions inherited from CPIVolatilitySurface
 CPIVolatilitySurface (QuantLib::Natural settlementDays, const QuantLib::Calendar &, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const QuantLib::Period &observationLag, QuantLib::Frequency frequency, bool indexIsInterpolated, const QuantLib::Date &capFloorStartDate=QuantLib::Date(), QuantLib::VolatilityType volType=QuantLib::ShiftedLognormal, double displacement=0.0)
 
QuantLib::Date optionDateFromTenor (const QuantLib::Period &tenor) const override
 Computes the expiry date from the capFloorStartDate() More...
 
QuantLib::Date baseDate () const override
 base date will be in the past More...
 
QuantLib::VolatilityType volatilityType () const
 Returns the volatility type. More...
 
double displacement () const
 Returns the displacement for lognormal volatilities. More...
 
bool isLogNormal () const
 
QuantLib::Volatility volatility (const QuantLib::Date &maturityDate, QuantLib::Rate strike, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days), bool extrapolate=false) const override
 
virtual QuantLib::Real atmStrike (const QuantLib::Date &maturity, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days)) const =0
 
QuantLib::Date capFloorStartDate () const
 

Inspectors

std::vector< QuantLib::Period > optionTenors_
 
std::vector< QuantLib::Time > optionTimes_
 
std::vector< QuantLib::Rate > strikes_
 
std::vector< std::vector< Handle< Quote > > > quotes_
 
QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > index_
 
Matrix volData_
 
QuantLib::Interpolation2D vols_
 
Interpolator2D interpolator2d_
 
const std::vector< QuantLib::Real > & strikes ()
 
const std::vector< QuantLib::Period > & optionTenors ()
 
const std::vector< std::vector< Handle< Quote > > > & quotes ()
 
const QuantLib::Matrix & volData ()
 
QuantLib::Volatility volatilityImpl (QuantLib::Time length, QuantLib::Rate strike) const override
 
QuantLib::Real atmStrike (const QuantLib::Date &maturity, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days)) const override
 

Additional Inherited Members

- Protected Member Functions inherited from CPIVolatilitySurface
virtual double fixingTime (const QuantLib::Date &maturityDate) const
 Computes the expiry time from the capFloorStartDate() More...
 
- Protected Attributes inherited from CPIVolatilitySurface
QuantLib::VolatilityType volType_
 
double displacement_
 

Detailed Description

template<class Interpolator2D>
class QuantExt::InterpolatedCPIVolatilitySurface< Interpolator2D >

Interpolated zero inflation volatility structure.

The surface provides interpolated CPI Black volatilities. Volatility data is passed in as a vector of vector of quote Handles. When performCalculations is called, current quote values are copied to a matrix and the interpolator is updated.

Definition at line 44 of file interpolatedcpivolatilitysurface.hpp.

Constructor & Destructor Documentation

◆ InterpolatedCPIVolatilitySurface() [1/2]

InterpolatedCPIVolatilitySurface ( const std::vector< Period > &  optionTenors,
const std::vector< Real > &  strikes,
const std::vector< std::vector< Handle< Quote > > >  quotes,
const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &  index,
const bool  quotedInstrumentsAreInterpolated,
const Natural  settlementDays,
const Calendar &  cal,
BusinessDayConvention  bdc,
const DayCounter &  dc,
const Period &  observationLag,
const Date &  capFloorStartDate = Date(),
const Interpolator2D &  interpolator2d = Interpolator2D(),
const QuantLib::VolatilityType  volType = QuantLib::ShiftedLognormal,
const double  displacement = 0.0 
)

Definition at line 115 of file interpolatedcpivolatilitysurface.hpp.

121 : CPIVolatilitySurface(settlementDays, cal, bdc, dc, observationLag, index->frequency(),
122 quotedInstrumentsOberserveInterpolated,
125 for (Size i = 0; i < optionTenors_.size(); ++i) {
126 QL_REQUIRE(quotes_[i].size() == strikes_.size(), "quotes row " << i << " length does not match strikes size");
127 for (Size j = 0; j < strikes_.size(); ++j)
128 registerWith(quotes_[i][j]);
129 }
130}
double displacement() const
Returns the displacement for lognormal volatilities.
QuantLib::Date capFloorStartDate() const
CPIVolatilitySurface(QuantLib::Natural settlementDays, const QuantLib::Calendar &, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const QuantLib::Period &observationLag, QuantLib::Frequency frequency, bool indexIsInterpolated, const QuantLib::Date &capFloorStartDate=QuantLib::Date(), QuantLib::VolatilityType volType=QuantLib::ShiftedLognormal, double displacement=0.0)
const std::vector< std::vector< Handle< Quote > > > & quotes()
QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > index_
std::vector< std::vector< Handle< Quote > > > quotes_
const std::vector< QuantLib::Period > & optionTenors()

◆ InterpolatedCPIVolatilitySurface() [2/2]

QL_DEPRECATED_DISABLE_WARNING InterpolatedCPIVolatilitySurface ( const std::vector< Period > &  optionTenors,
const std::vector< Real > &  strikes,
const std::vector< std::vector< Handle< Quote > > >  quotes,
const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &  index,
const Natural  settlementDays,
const Calendar &  cal,
BusinessDayConvention  bdc,
const DayCounter &  dc,
const Period &  observationLag,
const Date &  capFloorStartDate = Date(),
const Interpolator2D &  interpolator2d = Interpolator2D(),
const QuantLib::VolatilityType  volType = QuantLib::ShiftedLognormal,
const double  displacement = 0.0 
)

Definition at line 135 of file interpolatedcpivolatilitysurface.hpp.

141 : CPIVolatilitySurface(settlementDays, cal, bdc, dc, observationLag, index->frequency(), index->interpolated(),
144 for (Size i = 0; i < optionTenors_.size(); ++i) {
145 QL_REQUIRE(quotes_[i].size() == strikes_.size(), "quotes row " << i << " length does not match strikes size");
146 for (Size j = 0; j < strikes_.size(); ++j)
147 registerWith(quotes_[i][j]);
148 }
149}

Member Function Documentation

◆ performCalculations()

QL_DEPRECATED_ENABLE_WARNING void performCalculations
override

Definition at line 152 of file interpolatedcpivolatilitysurface.hpp.

152 {
153 volData_ = QuantLib::Matrix(strikes_.size(), optionTenors_.size(), QuantLib::Null<QuantLib::Real>());
154 QL_REQUIRE(quotes_.size() == optionTenors_.size(), "quotes rows does not match option tenors size");
155 optionTimes_.clear();
156 for (Size i = 0; i < optionTenors_.size(); ++i) {
157 QuantLib::Date d = optionDateFromTenor(optionTenors_[i]);
158 // Save the vols at their fixing times and not maturity
159 optionTimes_.push_back(fixingTime(d));
160 for (QuantLib::Size j = 0; j < strikes_.size(); j++)
161 volData_[j][i] = quotes_[i][j]->value();
162 }
163
164 vols_ = interpolator2d_.interpolate(optionTimes_.begin(), optionTimes_.end(), strikes_.begin(), strikes_.end(),
165 volData_);
166 // FIXME ?
167 vols_.enableExtrapolation();
168 vols_.update();
169}
virtual double fixingTime(const QuantLib::Date &maturityDate) const
Computes the expiry time from the capFloorStartDate()
QuantLib::Date optionDateFromTenor(const QuantLib::Period &tenor) const override
Computes the expiry date from the capFloorStartDate()

◆ update()

void update ( )
override

Definition at line 72 of file interpolatedcpivolatilitysurface.hpp.

72 {
73 LazyObject::update();
74 CPIVolatilitySurface::update();
75 }

◆ minStrike()

QuantLib::Real minStrike
override

the minimum strike for which the term structure can return vols

Definition at line 171 of file interpolatedcpivolatilitysurface.hpp.

171 {
172 return strikes_.front() - QL_EPSILON;
173}

◆ maxStrike()

QuantLib::Real maxStrike
override

the maximum strike for which the term structure can return vols

Definition at line 175 of file interpolatedcpivolatilitysurface.hpp.

175 {
176 return strikes_.back() + QL_EPSILON;
177}

◆ maxDate()

QuantLib::Date maxDate
override

maximum date for which the term structure can return vols

Definition at line 179 of file interpolatedcpivolatilitysurface.hpp.

179 {
180 QuantLib::Date today = QuantLib::Settings::instance().evaluationDate();
181 return today + optionTenors_.back();
182}

◆ strikes()

const std::vector< QuantLib::Real > & strikes ( )

Definition at line 90 of file interpolatedcpivolatilitysurface.hpp.

90{ return strikes_; }

◆ optionTenors()

const std::vector< QuantLib::Period > & optionTenors ( )

Definition at line 91 of file interpolatedcpivolatilitysurface.hpp.

91{ return optionTenors_; }

◆ quotes()

const std::vector< std::vector< Handle< Quote > > > & quotes ( )

Definition at line 92 of file interpolatedcpivolatilitysurface.hpp.

92{ return quotes_; }

◆ volData()

const QuantLib::Matrix & volData ( )

Definition at line 93 of file interpolatedcpivolatilitysurface.hpp.

93{ return volData_; }

◆ volatilityImpl()

QuantLib::Volatility volatilityImpl ( QuantLib::Time  length,
QuantLib::Rate  strike 
) const
override

Definition at line 185 of file interpolatedcpivolatilitysurface.hpp.

186 {
187 calculate();
188 return vols_(length, strike);
189}

◆ atmStrike()

QuantLib::Real atmStrike ( const QuantLib::Date &  maturity,
const QuantLib::Period &  obsLag = QuantLib::Period(-1, QuantLib::Days) 
) const
overridevirtual

Implements CPIVolatilitySurface.

Definition at line 192 of file interpolatedcpivolatilitysurface.hpp.

193 {
194 QuantLib::Period lag = obsLag == -1 * QuantLib::Days ? observationLag() : obsLag;
195 QuantLib::Date fixingDate = ZeroInflation::fixingDate(maturity, lag, frequency(), indexIsInterpolated());
196 double forwardCPI = ZeroInflation::cpiFixing(index_, maturity, lag, indexIsInterpolated());
197 double baseCPI = ZeroInflation::cpiFixing(
198 index_, capFloorStartDate(), observationLag(), indexIsInterpolated());
199 double atm = forwardCPI / baseCPI;
200 double ttm =
201 QuantLib::inflationYearFraction(frequency(), indexIsInterpolated(), dayCounter(), baseDate(), fixingDate);
202 return std::pow(atm, 1.0 / ttm) - 1.0;
203}
QuantLib::Date baseDate() const override
base date will be in the past
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
Definition: inflation.cpp:183
QuantLib::Rate cpiFixing(const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &index, const QuantLib::Date &maturity, const QuantLib::Period &obsLag, bool interpolated)
Computes a CPI fixing giving an zeroIndex, with interpolation if needed.
Definition: inflation.cpp:166
+ Here is the call graph for this function:

Member Data Documentation

◆ optionTenors_

std::vector<QuantLib::Period> optionTenors_
mutableprivate

Definition at line 103 of file interpolatedcpivolatilitysurface.hpp.

◆ optionTimes_

std::vector<QuantLib::Time> optionTimes_
mutableprivate

Definition at line 104 of file interpolatedcpivolatilitysurface.hpp.

◆ strikes_

std::vector<QuantLib::Rate> strikes_
mutableprivate

Definition at line 105 of file interpolatedcpivolatilitysurface.hpp.

◆ quotes_

std::vector<std::vector<Handle<Quote> > > quotes_
mutableprivate

Definition at line 106 of file interpolatedcpivolatilitysurface.hpp.

◆ index_

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

Definition at line 107 of file interpolatedcpivolatilitysurface.hpp.

◆ volData_

Matrix volData_
mutableprivate

Definition at line 108 of file interpolatedcpivolatilitysurface.hpp.

◆ vols_

QuantLib::Interpolation2D vols_
mutableprivate

Definition at line 109 of file interpolatedcpivolatilitysurface.hpp.

◆ interpolator2d_

Interpolator2D interpolator2d_
private

Definition at line 110 of file interpolatedcpivolatilitysurface.hpp.