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

#include <qle/termstructures/spreadedyoyvolsurface.hpp>

+ Inheritance diagram for SpreadedYoYVolatilitySurface:
+ Collaboration diagram for SpreadedYoYVolatilitySurface:

Public Member Functions

 SpreadedYoYVolatilitySurface (const Handle< YoYOptionletVolatilitySurface > &baseVol, const std::vector< Date > &optionDates, const std::vector< Real > &strikes, const std::vector< std::vector< Handle< Quote > > > &volSpreads)
 
Rate minStrike () const override
 
Rate maxStrike () const override
 
Date maxDate () const override
 
Time maxTime () const override
 
const Date & referenceDate () const override
 
void update () override
 
void deepUpdate () override
 

Protected Member Functions

Volatility volatilityImpl (Time length, Rate strike) const override
 
void performCalculations () const override
 

Private Attributes

Handle< YoYOptionletVolatilitySurfacebaseVol_
 
std::vector< Date > optionDates_
 
std::vector< Real > strikes_
 
std::vector< std::vector< Handle< Quote > > > volSpreads_
 
std::vector< Real > optionTimes_
 
Matrix volSpreadValues_
 
Interpolation2D volSpreadInterpolation_
 

Detailed Description

Definition at line 36 of file spreadedyoyvolsurface.hpp.

Constructor & Destructor Documentation

◆ SpreadedYoYVolatilitySurface()

SpreadedYoYVolatilitySurface ( const Handle< YoYOptionletVolatilitySurface > &  baseVol,
const std::vector< Date > &  optionDates,
const std::vector< Real > &  strikes,
const std::vector< std::vector< Handle< Quote > > > &  volSpreads 
)

Definition at line 27 of file spreadedyoyvolsurface.cpp.

31 : YoYOptionletVolatilitySurface(baseVol->settlementDays(), baseVol->calendar(), baseVol->businessDayConvention(),
32 baseVol->dayCounter(), baseVol->observationLag(), baseVol->frequency(),
33 baseVol->indexIsInterpolated(), baseVol->volatilityType(), baseVol->displacement()),
34 baseVol_(baseVol), optionDates_(optionDates), strikes_(strikes), volSpreads_(volSpreads) {
35 registerWith(baseVol_);
36 optionTimes_.resize(optionDates_.size());
37 volSpreadValues_ = Matrix(strikes_.size(), optionDates_.size());
38 for (auto const& v : volSpreads)
39 for (auto const& q : v)
40 registerWith(q);
41}
Handle< YoYOptionletVolatilitySurface > baseVol_
std::vector< std::vector< Handle< Quote > > > volSpreads_
vector< Real > strikes

Member Function Documentation

◆ minStrike()

Rate minStrike ( ) const
override

Definition at line 46 of file spreadedyoyvolsurface.cpp.

46{ return baseVol_->minStrike(); }

◆ maxStrike()

Rate maxStrike ( ) const
override

Definition at line 47 of file spreadedyoyvolsurface.cpp.

47{ return baseVol_->maxStrike(); }

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 43 of file spreadedyoyvolsurface.cpp.

43{ return baseVol_->maxDate(); }

◆ maxTime()

Time maxTime ( ) const
override

Definition at line 44 of file spreadedyoyvolsurface.cpp.

44{ return baseVol_->maxTime(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 45 of file spreadedyoyvolsurface.cpp.

45{ return baseVol_->referenceDate(); }

◆ update()

void update ( )
override

Definition at line 72 of file spreadedyoyvolsurface.cpp.

72 {
73 YoYOptionletVolatilitySurface::update();
74 LazyObject::update();
75}
+ Here is the caller graph for this function:

◆ deepUpdate()

void deepUpdate ( )
override

Definition at line 77 of file spreadedyoyvolsurface.cpp.

77 {
78 baseVol_->update();
79 update();
80}
+ Here is the call graph for this function:

◆ volatilityImpl()

Volatility volatilityImpl ( Time  length,
Rate  strike 
) const
overrideprotected

Definition at line 49 of file spreadedyoyvolsurface.cpp.

49 {
50 calculate();
51 return baseVol_->volatility(length, strike) + volSpreadInterpolation_(length, strike);
52}

◆ performCalculations()

void performCalculations ( ) const
overrideprotected

Definition at line 54 of file spreadedyoyvolsurface.cpp.

54 {
55 for (Size i = 0; i < optionDates_.size(); ++i) {
56 // we can not support a custom obsLag here
57 if (indexIsInterpolated())
58 optionTimes_[i] = timeFromReference(optionDates_[i] - observationLag());
59 else
60 optionTimes_[i] = timeFromReference(inflationPeriod(optionDates_[i] - observationLag(), frequency()).first);
61 }
62 for (Size k = 0; k < strikes_.size(); ++k) {
63 for (Size i = 0; i < optionDates_.size(); ++i) {
64 volSpreadValues_(k, i) = volSpreads_[i][k]->value();
65 }
66 }
67 volSpreadInterpolation_ = FlatExtrapolator2D(QuantLib::ext::make_shared<BilinearInterpolation>(
68 optionTimes_.begin(), optionTimes_.end(), strikes_.begin(), strikes_.end(), volSpreadValues_));
69 volSpreadInterpolation_.enableExtrapolation();
70}

Member Data Documentation

◆ baseVol_

Handle<YoYOptionletVolatilitySurface> baseVol_
private

Definition at line 55 of file spreadedyoyvolsurface.hpp.

◆ optionDates_

std::vector<Date> optionDates_
private

Definition at line 56 of file spreadedyoyvolsurface.hpp.

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 57 of file spreadedyoyvolsurface.hpp.

◆ volSpreads_

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

Definition at line 58 of file spreadedyoyvolsurface.hpp.

◆ optionTimes_

std::vector<Real> optionTimes_
mutableprivate

Definition at line 60 of file spreadedyoyvolsurface.hpp.

◆ volSpreadValues_

Matrix volSpreadValues_
mutableprivate

Definition at line 61 of file spreadedyoyvolsurface.hpp.

◆ volSpreadInterpolation_

Interpolation2D volSpreadInterpolation_
mutableprivate

Definition at line 62 of file spreadedyoyvolsurface.hpp.