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

Cap/floor smile volatility surface sparse. More...

#include <qle/termstructures/capfloortermvolsurfacesparse.hpp>

+ Inheritance diagram for CapFloorTermVolSurfaceSparse< InterpolatorStrike, InterpolatorExpiry >:
+ Collaboration diagram for CapFloorTermVolSurfaceSparse< InterpolatorStrike, InterpolatorExpiry >:

Public Member Functions

 CapFloorTermVolSurfaceSparse (const QuantLib::Date &referenceDate, const QuantLib::Calendar &calendar, const QuantLib::BusinessDayConvention &bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &tenors, const std::vector< QuantLib::Real > &strikes, const std::vector< QuantLib::Volatility > &volatilities, bool lowerStrikeConstExtrap=true, bool upperStrikeConstExtrap=true, bool timeFlatExtrapolation=false)
 fixed reference date, fixed market data More...
 
 CapFloorTermVolSurfaceSparse (QuantLib::Natural settlementDays, const QuantLib::Calendar &calendar, const QuantLib::BusinessDayConvention &bdc, const QuantLib::DayCounter &dc, const std::vector< QuantLib::Period > &tenors, const std::vector< QuantLib::Real > &strikes, const std::vector< QuantLib::Volatility > &volatilities, bool lowerStrikeConstExtrap=true, bool upperStrikeConstExtrap=true, bool timeFlatExtrapolation=false)
 floating reference date, fixed market data More...
 
TermStructure interface
QuantLib::Date maxDate () const override
 
VolatilityTermStructure interface
QuantLib::Real minStrike () const override
 
QuantLib::Real maxStrike () const override
 
- Public Member Functions inherited from CapFloorTermVolSurface
 CapFloorTermVolSurface (QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter(), std::vector< QuantLib::Period > optionTenors={}, std::vector< QuantLib::Rate > strikes={})
 default constructor More...
 
 CapFloorTermVolSurface (const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc=QuantLib::DayCounter(), std::vector< QuantLib::Period > optionTenors={}, std::vector< QuantLib::Rate > strikes={})
 initialize with a fixed reference date More...
 
 CapFloorTermVolSurface (QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter(), std::vector< QuantLib::Period > optionTenors={}, std::vector< QuantLib::Rate > strikes={})
 calculate the reference date based on the global evaluation date More...
 
const std::vector< QuantLib::Period > & optionTenors () const
 
const std::vector< QuantLib::Rate > & strikes () const
 
void update () override
 
void performCalculations () const override
 

LazyObject interface

QuantLib::ext::shared_ptr< OptionInterpolator2d< InterpolatorStrike, InterpolatorExpiry > > optionInterpolator_
 
std::vector< QuantLib::Period > allTenors_
 
std::vector< QuantLib::Real > allStrikes_
 
std::vector< QuantLib::Volatility > allVols_
 
bool lowerStrikeConstExtrap_
 
bool upperStrikeConstExtrap_
 
void performCalculations () const override
 
QuantLib::Volatility volatilityImpl (Time t, Rate strike) const override
 
void initialiseStrikesTenors ()
 

Additional Inherited Members

- Protected Attributes inherited from CapFloorTermVolSurface
std::vector< QuantLib::Period > optionTenors_
 
std::vector< QuantLib::Rate > strikes_
 

Detailed Description

template<class InterpolatorStrike, class InterpolatorExpiry>
class QuantExt::CapFloorTermVolSurfaceSparse< InterpolatorStrike, InterpolatorExpiry >

Cap/floor smile volatility surface sparse.

This class provides the volatility for a given cap/floor interpolating a volatility surface whose elements are the market term volatilities of a set of caps/floors.

Definition at line 45 of file capfloortermvolsurfacesparse.hpp.

Constructor & Destructor Documentation

◆ CapFloorTermVolSurfaceSparse() [1/2]

CapFloorTermVolSurfaceSparse ( const QuantLib::Date &  referenceDate,
const QuantLib::Calendar &  calendar,
const QuantLib::BusinessDayConvention &  bdc,
const QuantLib::DayCounter &  dc,
const std::vector< QuantLib::Period > &  tenors,
const std::vector< QuantLib::Real > &  strikes,
const std::vector< QuantLib::Volatility > &  volatilities,
bool  lowerStrikeConstExtrap = true,
bool  upperStrikeConstExtrap = true,
bool  timeFlatExtrapolation = false 
)

fixed reference date, fixed market data

Definition at line 90 of file capfloortermvolsurfacesparse.hpp.

94 : CapFloorTermVolSurface(referenceDate, calendar, bdc, dc), allTenors_(tenors), allStrikes_(strikes), allVols_(volatilities),
95 lowerStrikeConstExtrap_(lowerStrikeConstExtrap), upperStrikeConstExtrap_(upperStrikeConstExtrap) {
96
98}
const std::vector< QuantLib::Rate > & strikes() const
CapFloorTermVolSurface(QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter(), std::vector< QuantLib::Period > optionTenors={}, std::vector< QuantLib::Rate > strikes={})
default constructor
std::vector< QuantLib::Volatility > allVols_
+ Here is the call graph for this function:

◆ CapFloorTermVolSurfaceSparse() [2/2]

CapFloorTermVolSurfaceSparse ( QuantLib::Natural  settlementDays,
const QuantLib::Calendar &  calendar,
const QuantLib::BusinessDayConvention &  bdc,
const QuantLib::DayCounter &  dc,
const std::vector< QuantLib::Period > &  tenors,
const std::vector< QuantLib::Real > &  strikes,
const std::vector< QuantLib::Volatility > &  volatilities,
bool  lowerStrikeConstExtrap = true,
bool  upperStrikeConstExtrap = true,
bool  timeFlatExtrapolation = false 
)

floating reference date, fixed market data

Definition at line 101 of file capfloortermvolsurfacesparse.hpp.

105 : CapFloorTermVolSurface(settlementDays, calendar, bdc, dc), allTenors_(tenors), allStrikes_(strikes), allVols_(volatilities),
106 lowerStrikeConstExtrap_(lowerStrikeConstExtrap), upperStrikeConstExtrap_(upperStrikeConstExtrap) {
107
109}
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 139 of file capfloortermvolsurfacesparse.hpp.

139 {
140 return optionDateFromTenor(optionTenors().back());
141}
const std::vector< QuantLib::Period > & optionTenors() const

◆ minStrike()

QuantLib::Real minStrike
override

Definition at line 144 of file capfloortermvolsurfacesparse.hpp.

144{ return strikes().front(); }

◆ maxStrike()

QuantLib::Real maxStrike
override

Definition at line 147 of file capfloortermvolsurfacesparse.hpp.

147{ return strikes().back(); }

◆ performCalculations()

void performCalculations
override

Definition at line 155 of file capfloortermvolsurfacesparse.hpp.

155 {
156 optionInterpolator_ = QuantLib::ext::make_shared<OptionInterpolator2d<IS, IE>>(referenceDate(), calendar(), businessDayConvention(), dayCounter(),
158}
QuantLib::ext::shared_ptr< OptionInterpolator2d< InterpolatorStrike, InterpolatorExpiry > > optionInterpolator_

◆ volatilityImpl()

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

Definition at line 150 of file capfloortermvolsurfacesparse.hpp.

150 {
151 return optionInterpolator_->getValue(t, strike);
152}

◆ initialiseStrikesTenors()

void initialiseStrikesTenors
private

Definition at line 112 of file capfloortermvolsurfacesparse.hpp.

112 {
113
114 for (auto t : allTenors_) {
115 // add to the unique list of option tenors
116 auto fnd = find(optionTenors_.begin(), optionTenors_.end(), t);
117 if (fnd == optionTenors_.end()) {
118 optionTenors_.push_back(t);
119 }
120 }
121 // sort the tenors
122 std::sort(optionTenors_.begin(), optionTenors_.end());
123
124 for (auto s : allStrikes_) {
125 std::vector<Real>::iterator fnd =
126 find_if(strikes_.begin(), strikes_.end(), CloseEnoughComparator(s));
127 if (fnd == strikes_.end()) {
128 strikes_.push_back(s);
129 }
130 }
131 // sort the strikes
132 std::sort(strikes_.begin(), strikes_.end());
133
134 // create the option interpolator
136}
std::vector< QuantLib::Rate > strikes_
std::vector< QuantLib::Period > optionTenors_
+ Here is the caller graph for this function:

Member Data Documentation

◆ optionInterpolator_

QuantLib::ext::shared_ptr<OptionInterpolator2d<InterpolatorStrike, InterpolatorExpiry> > optionInterpolator_
mutableprivate

Definition at line 79 of file capfloortermvolsurfacesparse.hpp.

◆ allTenors_

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

Definition at line 80 of file capfloortermvolsurfacesparse.hpp.

◆ allStrikes_

std::vector<QuantLib::Real> allStrikes_
private

Definition at line 81 of file capfloortermvolsurfacesparse.hpp.

◆ allVols_

std::vector<QuantLib::Volatility> allVols_
private

Definition at line 82 of file capfloortermvolsurfacesparse.hpp.

◆ lowerStrikeConstExtrap_

bool lowerStrikeConstExtrap_
private

Definition at line 83 of file capfloortermvolsurfacesparse.hpp.

◆ upperStrikeConstExtrap_

bool upperStrikeConstExtrap_
private

Definition at line 84 of file capfloortermvolsurfacesparse.hpp.