Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
PiecewiseOptionletStripper< Interpolator, Bootstrap > Class Template Reference

#include <qle/termstructures/piecewiseoptionletstripper.hpp>

+ Inheritance diagram for PiecewiseOptionletStripper< Interpolator, Bootstrap >:
+ Collaboration diagram for PiecewiseOptionletStripper< Interpolator, Bootstrap >:

Public Types

typedef PiecewiseOptionletCurve< Interpolator, Bootstrap >::this_curve optionlet_curve
 

Public Member Functions

 PiecewiseOptionletStripper (const QuantLib::ext::shared_ptr< QuantExt::CapFloorTermVolSurface > &capFloorSurface, const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &index, const QuantLib::Handle< QuantLib::YieldTermStructure > &discount, bool flatFirstPeriod=true, const QuantLib::VolatilityType capFloorVolType=QuantLib::ShiftedLognormal, const QuantLib::Real capFloorVolDisplacement=0.0, const boost::optional< VolatilityType > optionletVolType=boost::none, const boost::optional< QuantLib::Real > optionletVolDisplacement=boost::none, bool interpOnOptionlets=true, const Interpolator &i=Interpolator(), const Bootstrap< optionlet_curve > &bootstrap=Bootstrap< optionlet_curve >(), const Period &rateComputationPeriod=0 *Days, const Size onCapSettlementDays=0)
 
Inspectors
QuantLib::VolatilityType capFloorVolType () const
 Volatility type for the underlying cap floor matrix. More...
 
QuantLib::Real capFloorVolDisplacement () const
 The applicable shift if the underlying cap floor matrix has shifted lognormal volatility. More...
 
- Public Member Functions inherited from OptionletStripper
const std::vector< Rate > & optionletStrikes (Size i) const override
 
const std::vector< Volatility > & optionletVolatilities (Size i) const override
 
const std::vector< Date > & optionletFixingDates () const override
 
const std::vector< Time > & optionletFixingTimes () const override
 
Size optionletMaturities () const override
 
const std::vector< Rate > & atmOptionletRates () const override
 
DayCounter dayCounter () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
BusinessDayConvention businessDayConvention () const override
 
const std::vector< Period > & optionletFixingTenors () const
 
const std::vector< Date > & optionletPaymentDates () const
 
const std::vector< Time > & optionletAccrualPeriods () const
 
ext::shared_ptr< CapFloorTermVolSurfacetermVolSurface () const
 
ext::shared_ptr< IborIndex > index () const
 
Real displacement () const override
 
VolatilityType volatilityType () const override
 
const Period & rateComputationPeriod () const
 

LazyObject interface

typedef QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
 Store the vector of helpers for each strike column. The first dimension is strike and second is option tenor. More...
 
bool flatFirstPeriod_
 Flat optionlet volatility before first optionlet fixing date. More...
 
QuantLib::VolatilityType capFloorVolType_
 Volatility type for the underlying cap floor matrix. More...
 
QuantLib::Real capFloorVolDisplacement_
 The applicable shift if the underlying cap floor matrix has shifted lognormal volatility. More...
 
bool interpOnOptionlets_
 True to interpolate on optionlet volatilities, false to interpolate on cap floor term volatilities. More...
 
Interpolator interpolator_
 The interpolator. More...
 
Bootstrap< optionlet_curvebootstrap_
 The bootstrapper. More...
 
std::vector< QuantLib::ext::shared_ptr< optionlet_curve > > strikeCurves_
 A one-dimensional optionlet curve for each strike in the underlying cap floor matrix. More...
 
std::vector< std::vector< QuantLib::ext::shared_ptr< helper > > > helpers_
 
std::vector< std::vector< QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > > > quotes_
 Store the cap floor surface quotes. The first dimension is option tenor and second is strike. More...
 
void performCalculations () const override
 

Additional Inherited Members

- Protected Member Functions inherited from OptionletStripper
 OptionletStripper (const ext::shared_ptr< QuantExt::CapFloorTermVolSurface > &, const ext::shared_ptr< IborIndex > &index, const Handle< YieldTermStructure > &discount=Handle< YieldTermStructure >(), const VolatilityType type=ShiftedLognormal, const Real displacement=0.0, const Period &rateComputationPeriod=0 *Days, const Size onCapSettlementDays=0)
 
virtual void populateDates () const
 Method to populate the dates, times and accruals that can be overridden in derived classes. More...
 
- Protected Attributes inherited from OptionletStripper
ext::shared_ptr< CapFloorTermVolSurfacetermVolSurface_
 
ext::shared_ptr< IborIndex > index_
 
Handle< YieldTermStructure > discount_
 
Size nStrikes_
 
Size nOptionletTenors_
 
std::vector< std::vector< Rate > > optionletStrikes_
 
std::vector< std::vector< Volatility > > optionletVolatilities_
 
std::vector< Time > optionletTimes_
 
std::vector< Date > optionletDates_
 
std::vector< Period > optionletTenors_
 
std::vector< Rate > atmOptionletRate_
 
std::vector< Date > optionletPaymentDates_
 
std::vector< Time > optionletAccrualPeriods_
 
std::vector< Period > capFloorLengths_
 
const VolatilityType volatilityType_
 
const Real displacement_
 
const Period rateComputationPeriod_
 
const Size onCapSettlementDays_
 

Detailed Description

template<class Interpolator, template< class > class Bootstrap = QuantExt::IterativeBootstrap>
class QuantExt::PiecewiseOptionletStripper< Interpolator, Bootstrap >

Helper class to strip optionlet (i.e. caplet/floorlet) volatilities from the cap floor term volatilities of a CapFloorTermVolSurface.

Definition at line 37 of file piecewiseoptionletstripper.hpp.

Member Typedef Documentation

◆ optionlet_curve

typedef PiecewiseOptionletCurve<Interpolator,Bootstrap>::this_curve optionlet_curve

Definition at line 40 of file piecewiseoptionletstripper.hpp.

◆ helper

typedef QuantLib::BootstrapHelper<QuantLib::OptionletVolatilityStructure> helper
private

Store the vector of helpers for each strike column. The first dimension is strike and second is option tenor.

Definition at line 90 of file piecewiseoptionletstripper.hpp.

Constructor & Destructor Documentation

◆ PiecewiseOptionletStripper()

PiecewiseOptionletStripper ( const QuantLib::ext::shared_ptr< QuantExt::CapFloorTermVolSurface > &  capFloorSurface,
const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &  index,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discount,
bool  flatFirstPeriod = true,
const QuantLib::VolatilityType  capFloorVolType = QuantLib::ShiftedLognormal,
const QuantLib::Real  capFloorVolDisplacement = 0.0,
const boost::optional< VolatilityType >  optionletVolType = boost::none,
const boost::optional< QuantLib::Real >  optionletVolDisplacement = boost::none,
bool  interpOnOptionlets = true,
const Interpolator &  i = Interpolator(),
const Bootstrap< optionlet_curve > &  bootstrap = Bootstrap<optionlet_curve>(),
const Period &  rateComputationPeriod = 0 * Days,
const Size  onCapSettlementDays = 0 
)

Definition at line 98 of file piecewiseoptionletstripper.hpp.

105 : OptionletStripper(capFloorSurface, index, discount, optionletVolType ? *optionletVolType : capFloorVolType,
106 optionletVolDisplacement ? *optionletVolDisplacement : 0.0, rateComputationPeriod,
107 onCapSettlementDays),
111
112 // Readability
113 // typedef QuantLib::BootstrapHelper<QuantLib::OptionletVolatilityStructure> helper;
114 using QuantLib::Handle;
115 using QuantLib::Period;
116 using QuantLib::Quote;
117 using QuantLib::SimpleQuote;
118 using QuantLib::Size;
119 using std::vector;
120
121 vector<Rate> strikes = termVolSurface_->strikes();
122
123 bool isOis = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(index) != nullptr;
124
125 // If we interpolate on term volatility surface first and then bootstrap, we have a cap floor helper for every
126 // optionlet maturity.
127 vector<Period> tenors = interpOnOptionlets_ ? termVolSurface_->optionTenors() : capFloorLengths_;
128 quotes_.resize(tenors.size());
129
130 // Initialise the quotes and helpers
131 for (Size j = 0; j < strikes.size(); j++) {
132 for (Size i = 0; i < tenors.size(); i++) {
133 quotes_[i].push_back(QuantLib::ext::make_shared<SimpleQuote>(termVolSurface_->volatility(tenors[i], strikes[j])));
134 if(isOis) {
135 Date effDate = index_->fixingCalendar().advance(
136 index_->fixingCalendar().adjust(capFloorSurface->referenceDate()), onCapSettlementDays_ * Days);
137 helpers_[j].push_back(QuantLib::ext::make_shared<OISCapFloorHelper>(
139 Handle<Quote>(quotes_[i].back()), QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(index_), discount_,
141 } else {
142 helpers_[j].push_back(QuantLib::ext::make_shared<CapFloorHelper>(
143 CapFloorHelper::Automatic, tenors[i], strikes[j], Handle<Quote>(quotes_[i].back()), index_,
145 }
146 }
147 }
148}
const Period & rateComputationPeriod() const
std::vector< Period > capFloorLengths_
Handle< YieldTermStructure > discount_
OptionletStripper(const ext::shared_ptr< QuantExt::CapFloorTermVolSurface > &, const ext::shared_ptr< IborIndex > &index, const Handle< YieldTermStructure > &discount=Handle< YieldTermStructure >(), const VolatilityType type=ShiftedLognormal, const Real displacement=0.0, const Period &rateComputationPeriod=0 *Days, const Size onCapSettlementDays=0)
ext::shared_ptr< IborIndex > index() const
ext::shared_ptr< CapFloorTermVolSurface > termVolSurface_
ext::shared_ptr< IborIndex > index_
std::vector< QuantLib::ext::shared_ptr< optionlet_curve > > strikeCurves_
A one-dimensional optionlet curve for each strike in the underlying cap floor matrix.
QuantLib::VolatilityType capFloorVolType() const
Volatility type for the underlying cap floor matrix.
std::vector< std::vector< QuantLib::ext::shared_ptr< helper > > > helpers_
QuantLib::VolatilityType capFloorVolType_
Volatility type for the underlying cap floor matrix.
QuantLib::Real capFloorVolDisplacement_
The applicable shift if the underlying cap floor matrix has shifted lognormal volatility.
Bootstrap< optionlet_curve > bootstrap_
The bootstrapper.
bool interpOnOptionlets_
True to interpolate on optionlet volatilities, false to interpolate on cap floor term volatilities.
std::vector< std::vector< QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > > > quotes_
Store the cap floor surface quotes. The first dimension is option tenor and second is strike.
QuantLib::Real capFloorVolDisplacement() const
The applicable shift if the underlying cap floor matrix has shifted lognormal volatility.
bool flatFirstPeriod_
Flat optionlet volatility before first optionlet fixing date.
vector< Real > strikes
+ Here is the call graph for this function:

Member Function Documentation

◆ capFloorVolType()

QuantLib::VolatilityType capFloorVolType ( ) const

Volatility type for the underlying cap floor matrix.

Definition at line 57 of file piecewiseoptionletstripper.hpp.

57{ return capFloorVolType_; }

◆ capFloorVolDisplacement()

QuantLib::Real capFloorVolDisplacement ( ) const

The applicable shift if the underlying cap floor matrix has shifted lognormal volatility.

Definition at line 60 of file piecewiseoptionletstripper.hpp.

◆ performCalculations()

void performCalculations
override

Definition at line 151 of file piecewiseoptionletstripper.hpp.

151 {
152
153 // Some localised typedefs and using declarations to make the code more readable
154 using QuantLib::Period;
155 using QuantLib::Rate;
156 using QuantLib::Size;
157 using std::vector;
158
159 // Update dates
161
162 // Readability
163 vector<Rate> strikes = termVolSurface_->strikes();
164 vector<Period> tenors = interpOnOptionlets_ ? termVolSurface_->optionTenors() : capFloorLengths_;
165
166 // Update the quotes from the cap floor term volatility surface
167 for (Size i = 0; i < tenors.size(); i++) {
168 for (Size j = 0; j < strikes.size(); j++) {
169 quotes_[i][j]->setValue(termVolSurface_->volatility(tenors[i], strikes[j]));
170 }
171 }
172
173 // Populate the strike curves
174 for (Size j = 0; j < strikes.size(); j++) {
175 strikeCurves_[j] = QuantLib::ext::make_shared<optionlet_curve>(
176 termVolSurface_->referenceDate(), helpers_[j], termVolSurface_->calendar(),
177 termVolSurface_->businessDayConvention(), termVolSurface_->dayCounter(), volatilityType_, displacement_,
179 }
180
181 // Populate the optionlet volatilities and standard deviations
182 for (Size j = 0; j < strikes.size(); j++) {
183 for (Size i = 0; i < nOptionletTenors_; ++i) {
184 optionletVolatilities_[i][j] = strikeCurves_[j]->volatility(optionletDates_[i], strikes[j]);
185 }
186 }
187}
std::vector< std::vector< Volatility > > optionletVolatilities_
std::vector< Date > optionletDates_
const VolatilityType volatilityType_
virtual void populateDates() const
Method to populate the dates, times and accruals that can be overridden in derived classes.

Member Data Documentation

◆ flatFirstPeriod_

bool flatFirstPeriod_
private

Flat optionlet volatility before first optionlet fixing date.

Definition at line 69 of file piecewiseoptionletstripper.hpp.

◆ capFloorVolType_

QuantLib::VolatilityType capFloorVolType_
private

Volatility type for the underlying cap floor matrix.

Definition at line 72 of file piecewiseoptionletstripper.hpp.

◆ capFloorVolDisplacement_

QuantLib::Real capFloorVolDisplacement_
private

The applicable shift if the underlying cap floor matrix has shifted lognormal volatility.

Definition at line 75 of file piecewiseoptionletstripper.hpp.

◆ interpOnOptionlets_

bool interpOnOptionlets_
private

True to interpolate on optionlet volatilities, false to interpolate on cap floor term volatilities.

Definition at line 78 of file piecewiseoptionletstripper.hpp.

◆ interpolator_

Interpolator interpolator_
private

The interpolator.

Definition at line 81 of file piecewiseoptionletstripper.hpp.

◆ bootstrap_

Bootstrap<optionlet_curve> bootstrap_
private

The bootstrapper.

Definition at line 84 of file piecewiseoptionletstripper.hpp.

◆ strikeCurves_

std::vector<QuantLib::ext::shared_ptr<optionlet_curve> > strikeCurves_
mutableprivate

A one-dimensional optionlet curve for each strike in the underlying cap floor matrix.

Definition at line 87 of file piecewiseoptionletstripper.hpp.

◆ helpers_

std::vector<std::vector<QuantLib::ext::shared_ptr<helper> > > helpers_
private

Definition at line 91 of file piecewiseoptionletstripper.hpp.

◆ quotes_

std::vector<std::vector<QuantLib::ext::shared_ptr<QuantLib::SimpleQuote> > > quotes_
private

Store the cap floor surface quotes. The first dimension is option tenor and second is strike.

Definition at line 94 of file piecewiseoptionletstripper.hpp.