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

#include <qle/termstructures/piecewiseatmoptionletcurve.hpp>

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

Public Types

typedef PiecewiseOptionletCurve< Interpolator, Bootstrap >::this_curve optionlet_curve
 

Public Member Functions

 PiecewiseAtmOptionletCurve (QuantLib::Natural settlementDays, const QuantLib::ext::shared_ptr< CapFloorTermVolCurve > &cftvc, 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< QuantLib::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 >())
 
 PiecewiseAtmOptionletCurve (const QuantLib::Date &referenceDate, const QuantLib::ext::shared_ptr< CapFloorTermVolCurve > &cftvc, 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< QuantLib::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 >())
 
Inspectors
QuantLib::VolatilityType capFloorVolType () const
 Volatility type for the underlying ATM cap floor curve. More...
 
QuantLib::Real capFloorVolDisplacement () const
 The applicable shift if the underlying ATM cap floor curve has shifted lognormal volatility. More...
 
Observer interface
void update () override
 
LazyObject interface
void performCalculations () const override
 
TermStructure interface
QuantLib::Date maxDate () const override
 
VolatilityTermStructure interface
QuantLib::Rate minStrike () const override
 
QuantLib::Rate maxStrike () const override
 

OptionletVolatilityStructure interface

typedef QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
 Store the vector of ATM cap floor helpers that are used in the bootstrap. More...
 
QuantLib::ext::shared_ptr< CapFloorTermVolCurvecftvc_
 The underlying ATM cap floor term volatility curve. More...
 
bool flatFirstPeriod_
 Flat optionlet volatility before first optionlet fixing date. More...
 
QuantLib::VolatilityType capFloorVolType_
 Volatility type for the underlying ATM cap floor volatility curve. More...
 
QuantLib::Real capFloorVolDisplacement_
 The applicable shift if the underlying ATM cap floor volatility curve has shifted lognormal volatility. More...
 
QuantLib::VolatilityType volatilityType_
 This optionlet structure's volatility type. More...
 
QuantLib::Real displacement_
 This optionlet structure's shift if its volatility type is shifted lognormal. 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...
 
QuantLib::ext::shared_ptr< optionlet_curvecurve_
 The stripped optionlet curve. More...
 
std::vector< QuantLib::Period > tenors_
 Store the helper tenors. More...
 
std::vector< QuantLib::ext::shared_ptr< helper > > helpers_
 
std::vector< QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > > quotes_
 Store the ATM cap floor curve quotes. More...
 
QuantLib::VolatilityType volatilityType () const override
 
QuantLib::Real displacement () const override
 
QuantLib::ext::shared_ptr< optionlet_curvecurve () const
 The underlying optionlet curve. More...
 
QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl (QuantLib::Time optionTime) const override
 
QuantLib::Volatility volatilityImpl (QuantLib::Time optionTime, QuantLib::Rate strike) const override
 
void initialise (const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &index, const QuantLib::Handle< QuantLib::YieldTermStructure > &discount)
 Shared initialisation. More...
 

Detailed Description

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

Helper class to strip caplet/floorlet volatilities from the cap floor term volatilities of a CapFloorTermVolCurve.

Definition at line 36 of file piecewiseatmoptionletcurve.hpp.

Member Typedef Documentation

◆ optionlet_curve

typedef PiecewiseOptionletCurve<Interpolator,Bootstrap>::this_curve optionlet_curve

Definition at line 39 of file piecewiseatmoptionletcurve.hpp.

◆ helper

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

Store the vector of ATM cap floor helpers that are used in the bootstrap.

Definition at line 144 of file piecewiseatmoptionletcurve.hpp.

Constructor & Destructor Documentation

◆ PiecewiseAtmOptionletCurve() [1/2]

PiecewiseAtmOptionletCurve ( QuantLib::Natural  settlementDays,
const QuantLib::ext::shared_ptr< CapFloorTermVolCurve > &  cftvc,
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< QuantLib::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>() 
)

Definition at line 156 of file piecewiseatmoptionletcurve.hpp.

163 : QuantLib::OptionletVolatilityStructure(settlementDays, cftvc->calendar(), cftvc->businessDayConvention(),
164 cftvc->dayCounter()),
165 cftvc_(cftvc), flatFirstPeriod_(flatFirstPeriod), capFloorVolType_(capFloorVolType),
167 volatilityType_(optionletVolType ? *optionletVolType : capFloorVolType),
168 displacement_(optionletVolDisplacement ? *optionletVolDisplacement : 0.0),
169 interpOnOptionlets_(interpOnOptionlets), interpolator_(i), bootstrap_(bootstrap), tenors_(cftvc_->optionTenors()),
170 helpers_(tenors_.size()), quotes_(tenors_.size()) {
171
172 initialise(index, discount);
173
174 curve_ = QuantLib::ext::make_shared<optionlet_curve>(settlementDays, helpers_, cftvc_->calendar(),
175 cftvc_->businessDayConvention(), cftvc_->dayCounter(), volatilityType_,
177}
std::vector< QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > > quotes_
Store the ATM cap floor curve quotes.
std::vector< QuantLib::ext::shared_ptr< helper > > helpers_
QuantLib::ext::shared_ptr< optionlet_curve > curve_
The stripped optionlet curve.
QuantLib::VolatilityType capFloorVolType() const
Volatility type for the underlying ATM cap floor curve.
std::vector< QuantLib::Period > tenors_
Store the helper tenors.
QuantLib::VolatilityType capFloorVolType_
Volatility type for the underlying ATM cap floor volatility curve.
QuantLib::Real capFloorVolDisplacement_
The applicable shift if the underlying ATM cap floor volatility curve has shifted lognormal volatilit...
QuantLib::VolatilityType volatilityType_
This optionlet structure's volatility type.
Bootstrap< optionlet_curve > bootstrap_
The bootstrapper.
QuantLib::ext::shared_ptr< CapFloorTermVolCurve > cftvc_
The underlying ATM cap floor term volatility curve.
bool interpOnOptionlets_
True to interpolate on optionlet volatilities, false to interpolate on cap floor term volatilities.
QuantLib::Real displacement_
This optionlet structure's shift if its volatility type is shifted lognormal.
QuantLib::Real capFloorVolDisplacement() const
The applicable shift if the underlying ATM cap floor curve has shifted lognormal volatility.
void initialise(const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &index, const QuantLib::Handle< QuantLib::YieldTermStructure > &discount)
Shared initialisation.
bool flatFirstPeriod_
Flat optionlet volatility before first optionlet fixing date.
+ Here is the call graph for this function:

◆ PiecewiseAtmOptionletCurve() [2/2]

PiecewiseAtmOptionletCurve ( const QuantLib::Date &  referenceDate,
const QuantLib::ext::shared_ptr< CapFloorTermVolCurve > &  cftvc,
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< QuantLib::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>() 
)

Definition at line 180 of file piecewiseatmoptionletcurve.hpp.

187 : QuantLib::OptionletVolatilityStructure(referenceDate, cftvc->calendar(), cftvc->businessDayConvention(),
188 cftvc->dayCounter()),
189 cftvc_(cftvc), flatFirstPeriod_(flatFirstPeriod), capFloorVolType_(capFloorVolType),
191 volatilityType_(optionletVolType ? *optionletVolType : capFloorVolType),
192 displacement_(optionletVolDisplacement ? *optionletVolDisplacement : 0.0),
193 interpOnOptionlets_(interpOnOptionlets), interpolator_(i), bootstrap_(bootstrap), tenors_(cftvc_->optionTenors()),
194 helpers_(tenors_.size()), quotes_(tenors_.size()) {
195
196 initialise(index, discount);
197
198 curve_ = QuantLib::ext::make_shared<optionlet_curve>(referenceDate, helpers_, cftvc_->calendar(),
199 cftvc_->businessDayConvention(), cftvc_->dayCounter(), volatilityType_,
201}
+ Here is the call graph for this function:

Member Function Documentation

◆ capFloorVolType()

QuantLib::VolatilityType capFloorVolType ( ) const

Volatility type for the underlying ATM cap floor curve.

Definition at line 67 of file piecewiseatmoptionletcurve.hpp.

67{ return capFloorVolType_; }

◆ capFloorVolDisplacement()

QuantLib::Real capFloorVolDisplacement ( ) const

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

Definition at line 70 of file piecewiseatmoptionletcurve.hpp.

◆ update()

void update
override

Definition at line 204 of file piecewiseatmoptionletcurve.hpp.

204 {
205
206 LazyObject::update();
207
208 if (this->moving_)
209 this->updated_ = false;
210}

◆ performCalculations()

void performCalculations
override

Definition at line 213 of file piecewiseatmoptionletcurve.hpp.

213 {
214
215 // Update the quotes from the cap floor term volatility surface
216 for (QuantLib::Size i = 0; i < tenors_.size(); i++) {
217 quotes_[i]->setValue(cftvc_->volatility(tenors_[i], 0.01));
218 }
219}

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 222 of file piecewiseatmoptionletcurve.hpp.

222 {
223 calculate();
224 return curve_->maxDate();
225}

◆ minStrike()

QuantLib::Rate minStrike
override

Definition at line 228 of file piecewiseatmoptionletcurve.hpp.

228 {
229 calculate();
230 return curve_->minStrike();
231}

◆ maxStrike()

QuantLib::Rate maxStrike
override

Definition at line 234 of file piecewiseatmoptionletcurve.hpp.

234 {
235 calculate();
236 return curve_->maxStrike();
237}

◆ volatilityType()

QuantLib::VolatilityType volatilityType
override

Definition at line 240 of file piecewiseatmoptionletcurve.hpp.

240 {
241 return volatilityType_;
242}

◆ displacement()

QuantLib::Real displacement
override

Definition at line 245 of file piecewiseatmoptionletcurve.hpp.

245 {
246 return displacement_;
247}

◆ curve()

QuantLib::ext::shared_ptr< typename PiecewiseAtmOptionletCurve< Interpolator, Bootstrap >::optionlet_curve > curve

The underlying optionlet curve.

Definition at line 251 of file piecewiseatmoptionletcurve.hpp.

251 {
252 calculate();
253 return curve_;
254}

◆ smileSectionImpl()

QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl ( QuantLib::Time  optionTime) const
overrideprotected

Definition at line 258 of file piecewiseatmoptionletcurve.hpp.

258 {
259 calculate();
260 return curve_->smileSection(optionTime, true);
261}

◆ volatilityImpl()

QuantLib::Volatility volatilityImpl ( QuantLib::Time  optionTime,
QuantLib::Rate  strike 
) const
overrideprotected

Definition at line 264 of file piecewiseatmoptionletcurve.hpp.

265 {
266 calculate();
267 return curve_->volatility(optionTime, 0.01, true);
268}

◆ initialise()

void initialise ( const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &  index,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discount 
)
private

Shared initialisation.

Definition at line 271 of file piecewiseatmoptionletcurve.hpp.

273 {
274
275 // Readability
276 using QuantLib::Handle;
277 using QuantLib::Null;
278 using QuantLib::Period;
279 using QuantLib::Quote;
280 using QuantLib::Rate;
281 using QuantLib::Real;
282 using QuantLib::SimpleQuote;
283 using QuantLib::Size;
284 using std::vector;
285
286 // Observe the underlying cap floor term volatility curve
287 registerWith(cftvc_);
288
289 // If the term structure is not moving, ensure that the cap floor helpers are not moving and are set up with the
290 // correct effective date relative to the reference date. Mimic logic in MakeCapFloor here.
291 Date effectiveDate;
292 if (!this->moving_) {
293 Calendar cal = index->fixingCalendar();
294 Date ref = referenceDate();
295 ref = cal.adjust(ref);
296 effectiveDate = cal.advance(ref, index->fixingDays() * Days);
297 }
298
299 // Number of tenors, helpers and quotes depends on whether we are interpolating on optionlet volatilities or
300 // cap floor term volatilities
301 if (!interpOnOptionlets_) {
302
303 // We are interpolating on the cap floor term volatilities
304 Period indexTenor = index->tenor();
305 Period maxCapFloorTenor = tenors_.back();
306
307 // Add tenor of first cap floor - 2 x index tenor since first optionlet is excluded
308 tenors_.clear();
309 tenors_.push_back(indexTenor + indexTenor);
310 QL_REQUIRE(maxCapFloorTenor >= tenors_.back(),
311 "First cap floor tenor, " << tenors_.back()
312 << ", is greater than cap floor term vol surface's max tenor, "
313 << maxCapFloorTenor);
314
315 // Add all term cap floor instruments up to max tenor of term vol surface
316 Period nextTenor = tenors_.back() + indexTenor;
317 while (nextTenor <= maxCapFloorTenor) {
318 tenors_.push_back(nextTenor);
319 nextTenor += indexTenor;
320 }
321
322 // Resize the helpers and quotes vectors
323 quotes_.resize(tenors_.size());
324 helpers_.resize(tenors_.size());
325 }
326
327 // Initialise the quotes and helpers
328 for (Size i = 0; i < tenors_.size(); i++) {
329 quotes_[i] = QuantLib::ext::make_shared<SimpleQuote>(cftvc_->volatility(tenors_[i], 0.01));
330 helpers_[i] = QuantLib::ext::make_shared<CapFloorHelper>(
331 CapFloorHelper::Cap, tenors_[i], Null<Real>(), Handle<Quote>(quotes_[i]), index, discount, this->moving_,
333 }
334}
+ Here is the caller graph for this function:

Member Data Documentation

◆ cftvc_

QuantLib::ext::shared_ptr<CapFloorTermVolCurve> cftvc_
private

The underlying ATM cap floor term volatility curve.

Definition at line 111 of file piecewiseatmoptionletcurve.hpp.

◆ flatFirstPeriod_

bool flatFirstPeriod_
private

Flat optionlet volatility before first optionlet fixing date.

Definition at line 114 of file piecewiseatmoptionletcurve.hpp.

◆ capFloorVolType_

QuantLib::VolatilityType capFloorVolType_
private

Volatility type for the underlying ATM cap floor volatility curve.

Definition at line 117 of file piecewiseatmoptionletcurve.hpp.

◆ capFloorVolDisplacement_

QuantLib::Real capFloorVolDisplacement_
private

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

Definition at line 120 of file piecewiseatmoptionletcurve.hpp.

◆ volatilityType_

QuantLib::VolatilityType volatilityType_
private

This optionlet structure's volatility type.

Definition at line 123 of file piecewiseatmoptionletcurve.hpp.

◆ displacement_

QuantLib::Real displacement_
private

This optionlet structure's shift if its volatility type is shifted lognormal.

Definition at line 126 of file piecewiseatmoptionletcurve.hpp.

◆ interpOnOptionlets_

bool interpOnOptionlets_
private

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

Definition at line 129 of file piecewiseatmoptionletcurve.hpp.

◆ interpolator_

Interpolator interpolator_
private

The interpolator.

Definition at line 132 of file piecewiseatmoptionletcurve.hpp.

◆ bootstrap_

Bootstrap<optionlet_curve> bootstrap_
private

The bootstrapper.

Definition at line 135 of file piecewiseatmoptionletcurve.hpp.

◆ curve_

QuantLib::ext::shared_ptr<optionlet_curve> curve_
private

The stripped optionlet curve.

Definition at line 138 of file piecewiseatmoptionletcurve.hpp.

◆ tenors_

std::vector<QuantLib::Period> tenors_
private

Store the helper tenors.

Definition at line 141 of file piecewiseatmoptionletcurve.hpp.

◆ helpers_

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

Definition at line 145 of file piecewiseatmoptionletcurve.hpp.

◆ quotes_

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

Store the ATM cap floor curve quotes.

Definition at line 148 of file piecewiseatmoptionletcurve.hpp.