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

Wrapper class for a BlackVolTermStructure that easily exposes ATM vols. More...

#include <qle/termstructures/blackvolsurfacewithatm.hpp>

+ Inheritance diagram for BlackVolatilityWithATM:
+ Collaboration diagram for BlackVolatilityWithATM:

Public Member Functions

 BlackVolatilityWithATM (const QuantLib::ext::shared_ptr< BlackVolTermStructure > &surface, const Handle< Quote > &spot, const Handle< YieldTermStructure > &yield1=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &yield2=Handle< YieldTermStructure >())
 Constructor. This is a floating term structure (settlement days is zero) More...
 
TermStructure interface
DayCounter dayCounter () const override
 
Date maxDate () const override
 
Time maxTime () const override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
VolatilityTermStructure interface
Rate minStrike () const override
 
Rate maxStrike () const override
 

Inspectors

QuantLib::ext::shared_ptr< BlackVolTermStructuresurface_
 
Handle< Quote > spot_
 
Handle< YieldTermStructure > yield1_
 
Handle< YieldTermStructure > yield2_
 
QuantLib::ext::shared_ptr< BlackVolTermStructuresurface () const
 
Handle< Quote > spot () const
 
Handle< YieldTermStructure > yield1 () const
 
Handle< YieldTermStructure > yield2 () const
 
Volatility blackVolImpl (Time t, Real strike) const override
 

Detailed Description

Wrapper class for a BlackVolTermStructure that easily exposes ATM vols.

This class implements BlackVolatilityTermStructure and takes a surface (well, any BlackVolTermStructure) as an input. If asked for a volatility with strike=Null<Real>() or 0 it will calculate the forward value and use this as the strike, this makes it easy to access ATMF values.

The forward value is calculated using the input spot and yield curves, so can be used for both FX and Equity vols.

For FX markets, one should set the spot to be the FX spot rate, yield1 to be the base discount curve and yield2 to be the reference discount curve (e.g. EURUSD, yield1 = EUR).

For Equity markets, one should set the spot to be the equity price, yield1 to be the discount curve and yield2 to be the dividend curve.

Definition at line 50 of file blackvolsurfacewithatm.hpp.

Constructor & Destructor Documentation

◆ BlackVolatilityWithATM()

BlackVolatilityWithATM ( const QuantLib::ext::shared_ptr< BlackVolTermStructure > &  surface,
const Handle< Quote > &  spot,
const Handle< YieldTermStructure > &  yield1 = Handle<YieldTermStructure>(),
const Handle< YieldTermStructure > &  yield2 = Handle<YieldTermStructure>() 
)

Constructor. This is a floating term structure (settlement days is zero)

Definition at line 23 of file blackvolsurfacewithatm.cpp.

26 : BlackVolatilityTermStructure(0, surface->calendar(), surface->businessDayConvention(), surface->dayCounter()),
28
29 QL_REQUIRE(!spot.empty(), "No spot handle provided");
30
31 if (surface->allowsExtrapolation())
32 this->enableExtrapolation();
33
34 registerWith(surface);
35 registerWith(spot);
36 registerWith(yield1);
37 registerWith(yield2);
38}
Handle< YieldTermStructure > yield2() const
QuantLib::ext::shared_ptr< BlackVolTermStructure > surface_
QuantLib::ext::shared_ptr< BlackVolTermStructure > surface() const
Handle< YieldTermStructure > yield1() const
Handle< YieldTermStructure > yield1_
Handle< YieldTermStructure > yield2_
+ Here is the call graph for this function:

Member Function Documentation

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 59 of file blackvolsurfacewithatm.hpp.

59{ return surface_->dayCounter(); }

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 60 of file blackvolsurfacewithatm.hpp.

60{ return surface_->maxDate(); }

◆ maxTime()

Time maxTime ( ) const
override

Definition at line 61 of file blackvolsurfacewithatm.hpp.

61{ return surface_->maxTime(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 62 of file blackvolsurfacewithatm.hpp.

62{ return surface_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 63 of file blackvolsurfacewithatm.hpp.

63{ return surface_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 64 of file blackvolsurfacewithatm.hpp.

64{ return surface_->settlementDays(); }

◆ minStrike()

Rate minStrike ( ) const
override

Definition at line 69 of file blackvolsurfacewithatm.hpp.

69{ return surface_->minStrike(); }

◆ maxStrike()

Rate maxStrike ( ) const
override

Definition at line 70 of file blackvolsurfacewithatm.hpp.

70{ return surface_->maxStrike(); }

◆ surface()

QuantLib::ext::shared_ptr< BlackVolTermStructure > surface ( ) const

Definition at line 75 of file blackvolsurfacewithatm.hpp.

75{ return surface_; }
+ Here is the caller graph for this function:

◆ spot()

Handle< Quote > spot ( ) const

Definition at line 76 of file blackvolsurfacewithatm.hpp.

76{ return spot_; }
+ Here is the caller graph for this function:

◆ yield1()

Handle< YieldTermStructure > yield1 ( ) const

Definition at line 77 of file blackvolsurfacewithatm.hpp.

77{ return yield1_; }
+ Here is the caller graph for this function:

◆ yield2()

Handle< YieldTermStructure > yield2 ( ) const

Definition at line 78 of file blackvolsurfacewithatm.hpp.

78{ return yield2_; }
+ Here is the caller graph for this function:

◆ blackVolImpl()

Volatility blackVolImpl ( Time  t,
Real  strike 
) const
overrideprotected

Definition at line 40 of file blackvolsurfacewithatm.cpp.

40 {
41 if (strike == Null<Real>() || strike == 0) {
42 // calculate fwd(t)
43 strike = spot_->value();
44 if (!yield1_.empty() && !yield2_.empty())
45 strike *= yield2_->discount(t, true) / yield1_->discount(t, true);
46 }
47 return surface_->blackVol(t, strike);
48}

Member Data Documentation

◆ surface_

QuantLib::ext::shared_ptr<BlackVolTermStructure> surface_
private

Definition at line 86 of file blackvolsurfacewithatm.hpp.

◆ spot_

Handle<Quote> spot_
private

Definition at line 87 of file blackvolsurfacewithatm.hpp.

◆ yield1_

Handle<YieldTermStructure> yield1_
private

Definition at line 88 of file blackvolsurfacewithatm.hpp.

◆ yield2_

Handle<YieldTermStructure> yield2_
private

Definition at line 88 of file blackvolsurfacewithatm.hpp.