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

Cap/floor smile volatility surface. More...

#include <qle/termstructures/capfloortermvolsurface.hpp>

+ Inheritance diagram for CapFloorTermVolSurfaceExact:
+ Collaboration diagram for CapFloorTermVolSurfaceExact:

Public Types

enum  InterpolationMethod { BicubicSpline , Bilinear }
 

Public Member Functions

 CapFloorTermVolSurfaceExact (Natural settlementDays, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Rate > &strikes, const std::vector< std::vector< Handle< Quote > > > &, const DayCounter &dc=Actual365Fixed(), InterpolationMethod interpolationMethod=BicubicSpline)
 floating reference date, floating market data More...
 
 CapFloorTermVolSurfaceExact (const Date &settlementDate, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Rate > &strikes, const std::vector< std::vector< Handle< Quote > > > &, const DayCounter &dc=Actual365Fixed(), InterpolationMethod interpolationMethod=BicubicSpline)
 fixed reference date, floating market data More...
 
 CapFloorTermVolSurfaceExact (const Date &settlementDate, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Rate > &strikes, const Matrix &volatilities, const DayCounter &dc=Actual365Fixed(), InterpolationMethod interpolationMethod=BicubicSpline)
 fixed reference date, fixed market data More...
 
 CapFloorTermVolSurfaceExact (Natural settlementDays, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Rate > &strikes, const Matrix &volatilities, const DayCounter &dc=Actual365Fixed(), InterpolationMethod interpolationMethod=BicubicSpline)
 floating reference date, fixed market data More...
 
TermStructure interface
Date maxDate () const override
 
VolatilityTermStructure interface
Real minStrike () const override
 
Real maxStrike () const override
 
LazyObject interface
void update () override
 
void performCalculations () 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
 

some inspectors

Size nOptionTenors_
 
std::vector< Date > optionDates_
 
std::vector< Time > optionTimes_
 
Date evaluationDate_
 
Size nStrikes_
 
std::vector< std::vector< Handle< Quote > > > volHandles_
 
Matrix vols_
 
InterpolationMethod interpolationMethod_
 
Interpolation2D interpolation_
 
const std::vector< Date > & optionDates () const
 
const std::vector< Time > & optionTimes () const
 
InterpolationMethod interpolationMethod () const
 
Volatility volatilityImpl (Time t, Rate strike) const override
 
void checkInputs () const
 
void initializeOptionDatesAndTimes () const
 
void registerWithMarketData ()
 
void interpolate ()
 

Additional Inherited Members

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

Detailed Description

Cap/floor smile volatility surface.

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 with given length and given strike.

This is a copy of the QL CapFloorTermVolSurface but gives the option to use BiLinear instead of BiCubic Spline interpolation. Default is BiCubic Spline for backwards compatibility with QuantLib

Definition at line 93 of file capfloortermvolsurface.hpp.

Member Enumeration Documentation

◆ InterpolationMethod

Constructor & Destructor Documentation

◆ CapFloorTermVolSurfaceExact() [1/4]

CapFloorTermVolSurfaceExact ( Natural  settlementDays,
const Calendar &  calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Rate > &  strikes,
const std::vector< std::vector< Handle< Quote > > > &  ,
const DayCounter &  dc = Actual365Fixed(),
InterpolationMethod  interpolationMethod = BicubicSpline 
)

floating reference date, floating market data

◆ CapFloorTermVolSurfaceExact() [2/4]

CapFloorTermVolSurfaceExact ( const Date &  settlementDate,
const Calendar &  calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Rate > &  strikes,
const std::vector< std::vector< Handle< Quote > > > &  ,
const DayCounter &  dc = Actual365Fixed(),
InterpolationMethod  interpolationMethod = BicubicSpline 
)

fixed reference date, floating market data

◆ CapFloorTermVolSurfaceExact() [3/4]

CapFloorTermVolSurfaceExact ( const Date &  settlementDate,
const Calendar &  calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Rate > &  strikes,
const Matrix &  volatilities,
const DayCounter &  dc = Actual365Fixed(),
InterpolationMethod  interpolationMethod = BicubicSpline 
)

fixed reference date, fixed market data

◆ CapFloorTermVolSurfaceExact() [4/4]

CapFloorTermVolSurfaceExact ( Natural  settlementDays,
const Calendar &  calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Rate > &  strikes,
const Matrix &  volatilities,
const DayCounter &  dc = Actual365Fixed(),
InterpolationMethod  interpolationMethod = BicubicSpline 
)

floating reference date, fixed market data

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 166 of file capfloortermvolsurface.hpp.

166 {
167 calculate();
168 return optionDateFromTenor(optionTenors_.back());
169}
std::vector< QuantLib::Period > optionTenors_

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 171 of file capfloortermvolsurface.hpp.

171{ return strikes_.front(); }
std::vector< QuantLib::Rate > strikes_

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 173 of file capfloortermvolsurface.hpp.

173{ return strikes_.back(); }

◆ update()

void update ( )
override

Definition at line 151 of file capfloortermvolsurface.cpp.

151 {
152 // recalculate dates if necessary...
153 if (moving_) {
154 Date d = Settings::instance().evaluationDate();
155 if (evaluationDate_ != d) {
156 evaluationDate_ = d;
158 }
159 }
161}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 170 of file capfloortermvolsurface.cpp.

170 {
171 // check if date recalculation must be called here
172
173 for (Size i = 0; i < nOptionTenors_; ++i)
174 for (Size j = 0; j < nStrikes_; ++j)
175 vols_[i][j] = volHandles_[i][j]->value();
176
177 interpolation_.update();
178}
std::vector< std::vector< Handle< Quote > > > volHandles_

◆ optionDates()

const std::vector< Date > & optionDates ( ) const

Definition at line 180 of file capfloortermvolsurface.hpp.

180 {
181 // what if quotes are not available?
182 calculate();
183 return optionDates_;
184}

◆ optionTimes()

const std::vector< Time > & optionTimes ( ) const

Definition at line 186 of file capfloortermvolsurface.hpp.

186 {
187 // what if quotes are not available?
188 calculate();
189 return optionTimes_;
190}

◆ interpolationMethod()

CapFloorTermVolSurfaceExact::InterpolationMethod interpolationMethod ( ) const

Definition at line 192 of file capfloortermvolsurface.hpp.

192 {
194}

◆ volatilityImpl()

Volatility volatilityImpl ( Time  t,
Rate  strike 
) const
overrideprotected

Definition at line 175 of file capfloortermvolsurface.hpp.

175 {
176 calculate();
177 return interpolation_(strike, t, true);
178}

◆ checkInputs()

void checkInputs ( ) const
private

Definition at line 113 of file capfloortermvolsurface.cpp.

113 {
114
115 QL_REQUIRE(!optionTenors_.empty(), "empty option tenor vector");
116 QL_REQUIRE(nOptionTenors_ == vols_.rows(), "mismatch between number of option tenors ("
117 << nOptionTenors_ << ") and number of volatility rows ("
118 << vols_.rows() << ")");
119 QL_REQUIRE(optionTenors_[0] > 0 * Days, "negative first option tenor: " << optionTenors_[0]);
120 for (Size i = 1; i < nOptionTenors_; ++i)
121 QL_REQUIRE(optionTenors_[i] > optionTenors_[i - 1],
122 "non increasing option tenor: " << io::ordinal(i) << " is " << optionTenors_[i - 1] << ", "
123 << io::ordinal(i + 1) << " is " << optionTenors_[i]);
124
125 QL_REQUIRE(nStrikes_ == vols_.columns(),
126 "mismatch between strikes(" << strikes_.size() << ") and vol columns (" << vols_.columns() << ")");
127 for (Size j = 1; j < nStrikes_; ++j)
128 QL_REQUIRE(strikes_[j - 1] < strikes_[j],
129 "non increasing strikes: " << io::ordinal(j) << " is " << io::rate(strikes_[j - 1]) << ", "
130 << io::ordinal(j + 1) << " is " << io::rate(strikes_[j]));
131}

◆ initializeOptionDatesAndTimes()

void initializeOptionDatesAndTimes ( ) const
private

Definition at line 163 of file capfloortermvolsurface.cpp.

163 {
164 for (Size i = 0; i < nOptionTenors_; ++i) {
165 optionDates_[i] = optionDateFromTenor(optionTenors_[i]);
166 optionTimes_[i] = timeFromReference(optionDates_[i]);
167 }
168}

◆ registerWithMarketData()

void registerWithMarketData ( )
private

Definition at line 133 of file capfloortermvolsurface.cpp.

133 {
134 for (Size i = 0; i < nOptionTenors_; ++i)
135 for (Size j = 0; j < nStrikes_; ++j)
136 registerWith(volHandles_[i][j]);
137}

◆ interpolate()

void interpolate ( )
private

Definition at line 139 of file capfloortermvolsurface.cpp.

139 {
142 QuantLib::BicubicSpline(strikes_.begin(), strikes_.end(), optionTimes_.begin(), optionTimes_.end(), vols_);
143 else if (interpolationMethod_ == Bilinear)
145 BilinearInterpolation(strikes_.begin(), strikes_.end(), optionTimes_.begin(), optionTimes_.end(), vols_);
146 else {
147 QL_FAIL("Invalid InterpolationMethod");
148 }
149}

Member Data Documentation

◆ nOptionTenors_

Size nOptionTenors_
private

Definition at line 146 of file capfloortermvolsurface.hpp.

◆ optionDates_

std::vector<Date> optionDates_
mutableprivate

Definition at line 147 of file capfloortermvolsurface.hpp.

◆ optionTimes_

std::vector<Time> optionTimes_
mutableprivate

Definition at line 148 of file capfloortermvolsurface.hpp.

◆ evaluationDate_

Date evaluationDate_
private

Definition at line 149 of file capfloortermvolsurface.hpp.

◆ nStrikes_

Size nStrikes_
private

Definition at line 151 of file capfloortermvolsurface.hpp.

◆ volHandles_

std::vector<std::vector<Handle<Quote> > > volHandles_
private

Definition at line 153 of file capfloortermvolsurface.hpp.

◆ vols_

Matrix vols_
mutableprivate

Definition at line 154 of file capfloortermvolsurface.hpp.

◆ interpolationMethod_

InterpolationMethod interpolationMethod_
private

Definition at line 157 of file capfloortermvolsurface.hpp.

◆ interpolation_

Interpolation2D interpolation_
mutableprivate

Definition at line 158 of file capfloortermvolsurface.hpp.