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

Interpolated cap floor term volatility curve. More...

#include <qle/termstructures/capfloortermvolcurve.hpp>

+ Inheritance diagram for InterpolatedCapFloorTermVolCurve< Interpolator >:
+ Collaboration diagram for InterpolatedCapFloorTermVolCurve< Interpolator >:

Public Member Functions

 InterpolatedCapFloorTermVolCurve (QuantLib::Natural settlementDays, const QuantLib::Calendar &calendar, QuantLib::BusinessDayConvention bdc, const std::vector< QuantLib::Period > &optionTenors, const std::vector< QuantLib::Handle< QuantLib::Quote > > &volatilities, const QuantLib::DayCounter &dayCounter=QuantLib::Actual365Fixed(), bool flatFirstPeriod=true, const Interpolator &interpolator=Interpolator())
 
 InterpolatedCapFloorTermVolCurve (const QuantLib::Date &settlementDate, const QuantLib::Calendar &calendar, QuantLib::BusinessDayConvention bdc, const std::vector< QuantLib::Period > &optionTenors, const std::vector< QuantLib::Handle< QuantLib::Quote > > &volatilities, const QuantLib::DayCounter &dayCounter=QuantLib::Actual365Fixed(), bool flatFirstPeriod=true, const Interpolator &interpolator=Interpolator())
 
TermStructure interface
QuantLib::Date maxDate () const override
 
VolatilityTermStructure interface
QuantLib::Rate minStrike () const override
 
QuantLib::Rate maxStrike () const override
 
LazyObject interface
void update () override
 
void performCalculations () const override
 
CapFloorTermVolCurve interface
std::vector< QuantLib::Period > optionTenors () const override
 Return the tenors used in the CapFloorTermVolCurve. More...
 
Inspectors
const std::vector< QuantLib::Date > & optionDates () const
 
const std::vector< QuantLib::Time > & optionTimes () const
 
- Public Member Functions inherited from CapFloorTermVolCurve
 CapFloorTermVolCurve (QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 CapFloorTermVolCurve (const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 CapFloorTermVolCurve (QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 calculate the reference date based on the global evaluation date More...
 

CapFloorTermVolatilityStructure interface

QuantLib::Size nOptionTenors_
 Number of underlying cap floor instruments. More...
 
std::vector< QuantLib::Period > optionTenors_
 Underlying cap floor tenors. More...
 
std::vector< QuantLib::Date > optionDates_
 
std::vector< QuantLib::Time > optionTimes_
 
std::vector< QuantLib::Handle< QuantLib::Quote > > volatilities_
 Cap floor term volatility quotes. More...
 
bool flatFirstPeriod_
 True for flat volatility from time zero to the first cap floor date. More...
 
QuantLib::Volatility volatilityImpl (QuantLib::Time length, QuantLib::Rate) const override
 
void checkInputs () const
 Check the constructor arguments for consistency. More...
 
void registerWithMarketData ()
 Register this curve with the volatility quotes. More...
 

Detailed Description

template<class Interpolator>
class QuantExt::InterpolatedCapFloorTermVolCurve< Interpolator >

Interpolated cap floor term volatility curve.

Class that interpolates a vector of cap floor volatilities.

Based on the class QuantLib::CapFloorTermVolCurve with changes:

Definition at line 70 of file capfloortermvolcurve.hpp.

Constructor & Destructor Documentation

◆ InterpolatedCapFloorTermVolCurve() [1/2]

InterpolatedCapFloorTermVolCurve ( QuantLib::Natural  settlementDays,
const QuantLib::Calendar &  calendar,
QuantLib::BusinessDayConvention  bdc,
const std::vector< QuantLib::Period > &  optionTenors,
const std::vector< QuantLib::Handle< QuantLib::Quote > > &  volatilities,
const QuantLib::DayCounter &  dayCounter = QuantLib::Actual365Fixed(),
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)

Constructor with floating reference date

Parameters
settlementDaysNumber of days from evaluation date to curve reference date.
calendarThe calendar used to derive cap floor maturity dates from optionTenors. Also used to advance from today to reference date if necessary.
bdcThe business day convention used to derive cap floor maturity dates from optionTenors.
optionTenorsThe cap floor tenors. The first tenor must be positive.
volatilitiesThe cap floor volatility quotes.
dayCounterThe day counter used to convert from dates to times.
flatFirstPeriodSet to true to use the first element of volatilities between time zero and the first element of optionTenors. If this is false, the volatility at time zero is set to zero and interpolation between time and the first element of optionTenors is used.
interpolatorAn instance of the interpolator to use. Allows for specification of Interpolator instances that use a constructor that takes arguments.

Definition at line 184 of file capfloortermvolcurve.hpp.

189 : CapFloorTermVolCurve(settlementDays, calendar, bdc, dayCounter), QuantLib::InterpolatedCurve<Interpolator>(
190 optionTenors.size() + 1, interpolator),
192 optionTimes_(nOptionTenors_), volatilities_(volatilities), flatFirstPeriod_(flatFirstPeriod) {
193
194 checkInputs();
196}
CapFloorTermVolCurve(QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
void registerWithMarketData()
Register this curve with the volatility quotes.
std::vector< QuantLib::Period > optionTenors() const override
Return the tenors used in the CapFloorTermVolCurve.
void checkInputs() const
Check the constructor arguments for consistency.
std::vector< QuantLib::Handle< QuantLib::Quote > > volatilities_
Cap floor term volatility quotes.
QuantLib::Size nOptionTenors_
Number of underlying cap floor instruments.
std::vector< QuantLib::Period > optionTenors_
Underlying cap floor tenors.
bool flatFirstPeriod_
True for flat volatility from time zero to the first cap floor date.
+ Here is the call graph for this function:

◆ InterpolatedCapFloorTermVolCurve() [2/2]

InterpolatedCapFloorTermVolCurve ( const QuantLib::Date &  settlementDate,
const QuantLib::Calendar &  calendar,
QuantLib::BusinessDayConvention  bdc,
const std::vector< QuantLib::Period > &  optionTenors,
const std::vector< QuantLib::Handle< QuantLib::Quote > > &  volatilities,
const QuantLib::DayCounter &  dayCounter = QuantLib::Actual365Fixed(),
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)

Constructor with fixed reference date

Parameters
settlementDateThe curve reference date.
calendarThe calendar used to derive cap floor maturity dates from optionTenors. Also used to advance from today to reference date if necessary.
bdcThe business day convention used to derive cap floor maturity dates from optionTenors.
optionTenorsThe cap floor tenors. The first tenor must be positive.
volatilitiesThe cap floor volatility quotes.
dayCounterThe day counter used to convert from dates to times.
flatFirstPeriodSet to true to use the first element of volatilities between time zero and the first element of optionTenors. If this is false, the volatility at time zero is set to zero and interpolation between time and the first element of optionTenors is used.
interpolatorAn instance of the interpolator to use. Allows for specification of Interpolator instances that use a constructor that takes arguments.

Definition at line 199 of file capfloortermvolcurve.hpp.

204 : CapFloorTermVolCurve(settlementDate, calendar, bdc, dayCounter), QuantLib::InterpolatedCurve<Interpolator>(
205 optionTenors.size() + 1, interpolator),
207 optionTimes_(nOptionTenors_), volatilities_(volatilities), flatFirstPeriod_(flatFirstPeriod) {
208
209 checkInputs();
211}
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 213 of file capfloortermvolcurve.hpp.

213 {
214 calculate();
215 return optionDates_.back();
216}

◆ minStrike()

QuantLib::Rate minStrike
override

Definition at line 218 of file capfloortermvolcurve.hpp.

218 {
219 return QL_MIN_REAL;
220}

◆ maxStrike()

QuantLib::Rate maxStrike
override

Definition at line 222 of file capfloortermvolcurve.hpp.

222 {
223 return QL_MAX_REAL;
224}

◆ update()

void update
override

Definition at line 226 of file capfloortermvolcurve.hpp.

226 {
227 CapFloorTermVolatilityStructure::update();
228 LazyObject::update();
229}

◆ performCalculations()

void performCalculations
override

Definition at line 231 of file capfloortermvolcurve.hpp.

231 {
232
233 // Populate the InterpolatedCurve members
234 // We make the time zero volatility equal to zero here. However, if flatFirstPeriod is set to true, there is no
235 // interpolation between time 0 and the first option date so this value of 0.0 is effectively ignored.
236 this->times_[0] = 0.0;
237 this->data_[0] = 0.0;
238 for (Size i = 0; i < nOptionTenors_; ++i) {
239 optionDates_[i] = optionDateFromTenor(optionTenors_[i]);
240 optionTimes_[i] = timeFromReference(optionDates_[i]);
241 this->times_[i + 1] = optionTimes_[i];
242 this->data_[i + 1] = volatilities_[i]->value();
243 }
244
245 // Would rather call setupInterpolation() but it is not a const method
246 this->interpolation_ =
247 this->interpolator_.interpolate(this->times_.begin(), this->times_.end(), this->data_.begin());
248}

◆ optionTenors()

std::vector< QuantLib::Period > optionTenors ( ) const
overridevirtual

Return the tenors used in the CapFloorTermVolCurve.

Implements CapFloorTermVolCurve.

Definition at line 251 of file capfloortermvolcurve.hpp.

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

◆ optionDates()

const std::vector< QuantLib::Date > & optionDates

Definition at line 257 of file capfloortermvolcurve.hpp.

257 {
258 calculate();
259 return optionDates_;
260}

◆ optionTimes()

const std::vector< QuantLib::Time > & optionTimes

Definition at line 263 of file capfloortermvolcurve.hpp.

263 {
264 calculate();
265 return optionTimes_;
266}

◆ volatilityImpl()

QuantLib::Volatility volatilityImpl ( QuantLib::Time  length,
QuantLib::Rate   
) const
overrideprotected

Definition at line 269 of file capfloortermvolcurve.hpp.

270 {
271
272 calculate();
273
274 if (flatFirstPeriod_ && length < this->times_[1])
275 return this->data_[1];
276 else
277 return this->interpolation_(length, true);
278}

◆ checkInputs()

void checkInputs
private

Check the constructor arguments for consistency.

Definition at line 280 of file capfloortermvolcurve.hpp.

280 {
281 QL_REQUIRE(!optionTenors_.empty(), "The option tenor vector cannot be empty");
282 QL_REQUIRE(nOptionTenors_ == volatilities_.size(), "Mismatch between number of option tenors ("
283 << nOptionTenors_ << ") and number of volatilities ("
284 << volatilities_.size() << ")");
285 QL_REQUIRE(optionTenors_[0] > 0 * Days, "First option tenor needs to be positive but is: " << optionTenors_[0]);
286 for (QuantLib::Size i = 1; i < nOptionTenors_; ++i) {
287 QL_REQUIRE(optionTenors_[i] > optionTenors_[i - 1],
288 "Non increasing option tenor: " << QuantLib::io::ordinal(i) << " is " << optionTenors_[i - 1]
289 << " and " << QuantLib::io::ordinal(i + 1) << " is "
290 << optionTenors_[i]);
291 }
292}
+ Here is the caller graph for this function:

◆ registerWithMarketData()

void registerWithMarketData
private

Register this curve with the volatility quotes.

Definition at line 294 of file capfloortermvolcurve.hpp.

294 {
295 for (QuantLib::Size i = 0; i < volatilities_.size(); ++i)
296 registerWith(volatilities_[i]);
297}
+ Here is the caller graph for this function:

Member Data Documentation

◆ nOptionTenors_

QuantLib::Size nOptionTenors_
private

Number of underlying cap floor instruments.

Definition at line 161 of file capfloortermvolcurve.hpp.

◆ optionTenors_

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

Underlying cap floor tenors.

Definition at line 164 of file capfloortermvolcurve.hpp.

◆ optionDates_

std::vector<QuantLib::Date> optionDates_
mutableprivate

Underlying cap floor maturity dates. Mutable since if the curve is moving, the dates need to be updated from const method.

Definition at line 169 of file capfloortermvolcurve.hpp.

◆ optionTimes_

std::vector<QuantLib::Time> optionTimes_
mutableprivate

Time to maturity of underlying cap floor instruments. Mutable since if the curve is moving, the times need to be updated from const method.

Definition at line 174 of file capfloortermvolcurve.hpp.

◆ volatilities_

std::vector<QuantLib::Handle<QuantLib::Quote> > volatilities_
private

Cap floor term volatility quotes.

Definition at line 177 of file capfloortermvolcurve.hpp.

◆ flatFirstPeriod_

bool flatFirstPeriod_
private

True for flat volatility from time zero to the first cap floor date.

Definition at line 180 of file capfloortermvolcurve.hpp.