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

#include <qle/termstructures/optionletcurve.hpp>

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

Public Member Functions

 InterpolatedOptionletCurve (const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &volatilities, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dayCounter, const QuantLib::Calendar &calendar=QuantLib::Calendar(), QuantLib::VolatilityType volatilityType=QuantLib::Normal, QuantLib::Real displacement=0.0, 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
 

OptionletVolatilityStructure interface

std::vector< QuantLib::Date > dates_
 The fixing dates of the index underlying the optionlets. More...
 
QuantLib::VolatilityType volatilityType_
 The optionlet volatility type. More...
 
QuantLib::Real displacement_
 If the volatility type is ShiftedLognormal, this holds the shift value. More...
 
bool flatFirstPeriod_
 True if the volatility from the initial date to the first date is assumed flat. More...
 
QuantLib::VolatilityType volatilityType () const override
 
QuantLib::Real displacement () const override
 
QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl (QuantLib::Time optionTime) const override
 
QuantLib::Real volatilityImpl (QuantLib::Time optionTime, QuantLib::Rate strike) const override
 
void initialise ()
 Initialise the dates and the interpolation object. More...
 

Other inspectors

const std::vector< QuantLib::Time > & times () const
 
const std::vector< QuantLib::Date > & dates () const
 
const std::vector< QuantLib::Real > & volatilities () const
 
const std::vector< QuantLib::Real > & data () const
 
std::vector< std::pair< QuantLib::Date, QuantLib::Real > > nodes () const
 
 InterpolatedOptionletCurve (QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dayCounter, QuantLib::VolatilityType volatilityType=QuantLib::Normal, QuantLib::Real displacement=0.0, bool flatFirstPeriod=true, const Interpolator &interpolator=Interpolator())
 
 InterpolatedOptionletCurve (const QuantLib::Date &referenceDate, const QuantLib::Calendar &calendar, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dayCounter, QuantLib::VolatilityType volatilityType=QuantLib::Normal, QuantLib::Real displacement=0.0, bool flatFirstPeriod=true, const Interpolator &interpolator=Interpolator())
 
 InterpolatedOptionletCurve (QuantLib::Natural settlementDays, const QuantLib::Calendar &calendar, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dayCounter, QuantLib::VolatilityType volatilityType=QuantLib::Normal, QuantLib::Real displacement=0.0, bool flatFirstPeriod=true, const Interpolator &interpolator=Interpolator())
 

Detailed Description

template<class Interpolator>
class QuantExt::InterpolatedOptionletCurve< Interpolator >

OptionletVolatilityStructure based on interpolation of one-dimensional vector of optionlet volatilities

The intended use case for this class is to represent the optionlet volatilities along a strike column of a cap floor volatility surface.

Definition at line 43 of file optionletcurve.hpp.

Constructor & Destructor Documentation

◆ InterpolatedOptionletCurve() [1/4]

InterpolatedOptionletCurve ( const std::vector< QuantLib::Date > &  dates,
const std::vector< QuantLib::Real > &  volatilities,
QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dayCounter,
const QuantLib::Calendar &  calendar = QuantLib::Calendar(),
QuantLib::VolatilityType  volatilityType = QuantLib::Normal,
QuantLib::Real  displacement = 0.0,
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)

Constructor

Parameters
datesThe fixing dates of the underlying interest rate index
volatilitiesThe optionlet volatility at each of the dates
bdcBusiness day convention used when getting an optionlet expiry date from an optionlet expiry tenor
dayCounterThe day counter used to convert dates to times
calendarThe calendar used when getting an optionlet expiry date from an optionlet expiry tenor and. Also used to advance from today to reference date if necessary.
volatilityTypeThe volatility type of the provided volatilities
displacementThe applicable shift size if the volatilityType is ShiftedLognormal
flatFirstPeriodIf the volatility between the first date and second date in dates is assumed constant and equal to the second element of volatilities. This means that the first element of volatilities is ignored.
interpolatorThe interpolation object used to interpolate between the provided dates

Definition at line 149 of file optionletcurve.hpp.

154 : QuantLib::OptionletVolatilityStructure(dates.at(0), calendar, bdc, dayCounter),
155 QuantLib::InterpolatedCurve<Interpolator>(std::vector<QuantLib::Time>(), volatilities, interpolator),
157 initialise();
158}
void initialise()
Initialise the dates and the interpolation object.
QuantLib::Real displacement() const override
std::vector< QuantLib::Date > dates_
The fixing dates of the index underlying the optionlets.
QuantLib::VolatilityType volatilityType() const override
QuantLib::VolatilityType volatilityType_
The optionlet volatility type.
const std::vector< QuantLib::Real > & volatilities() const
const std::vector< QuantLib::Date > & dates() const
QuantLib::Real displacement_
If the volatility type is ShiftedLognormal, this holds the shift value.
bool flatFirstPeriod_
True if the volatility from the initial date to the first date is assumed flat.
+ Here is the call graph for this function:

◆ InterpolatedOptionletCurve() [2/4]

InterpolatedOptionletCurve ( QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dayCounter,
QuantLib::VolatilityType  volatilityType = QuantLib::Normal,
QuantLib::Real  displacement = 0.0,
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)
protected

Definition at line 161 of file optionletcurve.hpp.

166 : QuantLib::OptionletVolatilityStructure(bdc, dayCounter), QuantLib::InterpolatedCurve<Interpolator>(interpolator),

◆ InterpolatedOptionletCurve() [3/4]

InterpolatedOptionletCurve ( const QuantLib::Date &  referenceDate,
const QuantLib::Calendar &  calendar,
QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dayCounter,
QuantLib::VolatilityType  volatilityType = QuantLib::Normal,
QuantLib::Real  displacement = 0.0,
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)
protected

Definition at line 170 of file optionletcurve.hpp.

174 : QuantLib::OptionletVolatilityStructure(referenceDate, calendar, bdc, dayCounter),
175 QuantLib::InterpolatedCurve<Interpolator>(interpolator), volatilityType_(volatilityType),
176 displacement_(displacement), flatFirstPeriod_(flatFirstPeriod) {}

◆ InterpolatedOptionletCurve() [4/4]

InterpolatedOptionletCurve ( QuantLib::Natural  settlementDays,
const QuantLib::Calendar &  calendar,
QuantLib::BusinessDayConvention  bdc,
const QuantLib::DayCounter &  dayCounter,
QuantLib::VolatilityType  volatilityType = QuantLib::Normal,
QuantLib::Real  displacement = 0.0,
bool  flatFirstPeriod = true,
const Interpolator &  interpolator = Interpolator() 
)
protected

Definition at line 179 of file optionletcurve.hpp.

183 : QuantLib::OptionletVolatilityStructure(settlementDays, calendar, bdc, dayCounter),
184 QuantLib::InterpolatedCurve<Interpolator>(interpolator), volatilityType_(volatilityType),
185 displacement_(displacement), flatFirstPeriod_(flatFirstPeriod) {}

Member Function Documentation

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 187 of file optionletcurve.hpp.

187 {
188 if (this->maxDate_ != Date())
189 return this->maxDate_;
190 return dates_.back();
191}

◆ minStrike()

QuantLib::Rate minStrike
override

Definition at line 193 of file optionletcurve.hpp.

193 {
194 if (volatilityType() == QuantLib::ShiftedLognormal) {
195 return displacement_ > 0.0 ? -displacement_ : 0.0;
196 } else {
197 return QL_MIN_REAL;
198 }
199}

◆ maxStrike()

QuantLib::Rate maxStrike
override

Definition at line 201 of file optionletcurve.hpp.

201{ return QL_MAX_REAL; }

◆ volatilityType()

QuantLib::VolatilityType volatilityType
override

Definition at line 203 of file optionletcurve.hpp.

203 {
204 return volatilityType_;
205}

◆ displacement()

QuantLib::Real displacement
override

Definition at line 207 of file optionletcurve.hpp.

207{ return displacement_; }

◆ times()

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

Definition at line 209 of file optionletcurve.hpp.

209 {
210 return this->times_;
211}

◆ dates()

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

Definition at line 213 of file optionletcurve.hpp.

213 {
214 return dates_;
215}

◆ volatilities()

const std::vector< QuantLib::Real > & volatilities

Definition at line 217 of file optionletcurve.hpp.

217 {
219 this->data_[0] = this->data_[1];
220 return this->data_;
221}

◆ data()

const std::vector< QuantLib::Real > & data

Definition at line 223 of file optionletcurve.hpp.

223 {
225 this->data_[0] = this->data_[1];
226 return this->data_;
227}

◆ nodes()

std::vector< std::pair< QuantLib::Date, QuantLib::Real > > nodes

Definition at line 230 of file optionletcurve.hpp.

230 {
231 std::vector<std::pair<QuantLib::Date, QuantLib::Real> > results(dates_.size());
232 for (QuantLib::Size i = 0; i < dates_.size(); ++i)
233 results[i] = std::make_pair(dates_[i], this->data_[i]);
235 results[0].second = this->data_[1];
236 return results;
237}

◆ smileSectionImpl()

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

Gives a flat SmileSection at the requested optionTime. The flat value is obtained by interpolating the input volatilities at the given optionTime.

Definition at line 241 of file optionletcurve.hpp.

241 {
242 QuantLib::Volatility vol = volatility(optionTime, 0.0, true);
243 return QuantLib::ext::make_shared<QuantLib::FlatSmileSection>(
244 optionTime, vol, dayCounter(), QuantLib::Null<QuantLib::Rate>(), volatilityType_, displacement_);
245}

◆ volatilityImpl()

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

Gives the interpolated optionlet volatility at the requested optionTime. The strike is ignored.

Definition at line 248 of file optionletcurve.hpp.

248 {
249 if (flatFirstPeriod_ && optionTime < this->times_[1])
250 return this->data_[1];
251 else
252 return this->interpolation_(optionTime, true);
253}

◆ initialise()

void initialise
private

Initialise the dates and the interpolation object.

Definition at line 255 of file optionletcurve.hpp.

255 {
256
257 QL_REQUIRE(dates_.size() >= T::requiredPoints, "Not enough input dates given for interpolation method");
258 QL_REQUIRE(this->data_.size() == dates_.size(), "Number of dates does not equal the number of volatilities");
259
260 this->times_.resize(dates_.size());
261 this->times_[0] = 0.0;
262 for (QuantLib::Size i = 1; i < dates_.size(); ++i) {
263 QL_REQUIRE(dates_[i] > dates_[i - 1], "Dates must be increasing but "
264 << QuantLib::io::ordinal(i) << " date " << dates_[i]
265 << " is not after " << QuantLib::io::ordinal(i - 1) << " date "
266 << dates_[i - 1]);
267 this->times_[i] = dayCounter().yearFraction(dates_[0], dates_[i]);
268 QL_REQUIRE(!QuantLib::close(this->times_[i], this->times_[i - 1]),
269 "The " << QuantLib::io::ordinal(i) << " date " << dates_[i] << " and "
270 << QuantLib::io::ordinal(i - 1) << " date " << dates_[i - 1]
271 << " correspond to the same time, " << this->times_[i]
272 << ", under this curve's day count convention, " << dayCounter());
273 QL_REQUIRE(this->data_[i] > 0.0,
274 "The " << QuantLib::io::ordinal(i) << " volatility, " << this->data_[i] << ", is not positive");
275 }
276
278 this->data_[0] = this->data_[1];
279
280 this->setupInterpolation();
281}
+ Here is the caller graph for this function:

Member Data Documentation

◆ dates_

std::vector<QuantLib::Date> dates_
mutableprotected

The fixing dates of the index underlying the optionlets.

Definition at line 127 of file optionletcurve.hpp.

◆ volatilityType_

QuantLib::VolatilityType volatilityType_
private

The optionlet volatility type.

Definition at line 131 of file optionletcurve.hpp.

◆ displacement_

QuantLib::Real displacement_
private

If the volatility type is ShiftedLognormal, this holds the shift value.

Definition at line 134 of file optionletcurve.hpp.

◆ flatFirstPeriod_

bool flatFirstPeriod_
private

True if the volatility from the initial date to the first date is assumed flat.

Definition at line 137 of file optionletcurve.hpp.