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
SpreadedOptionletVolatility2 Class Reference

#include <qle/termstructures/spreadedoptionletvolatility2.hpp>

+ Inheritance diagram for SpreadedOptionletVolatility2:
+ Collaboration diagram for SpreadedOptionletVolatility2:

Public Member Functions

 SpreadedOptionletVolatility2 (const Handle< OptionletVolatilityStructure > &baseVol, const std::vector< Date > &optionDates, const std::vector< Real > &strikes, const std::vector< std::vector< Handle< Quote > > > &volSpreads)
 
BusinessDayConvention businessDayConvention () const override
 
Rate minStrike () const override
 
Rate maxStrike () const override
 
DayCounter dayCounter () const override
 
Date maxDate () const override
 
Time maxTime () const override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
VolatilityType volatilityType () const override
 
Real displacement () const override
 
void update () override
 
void deepUpdate () override
 

Protected Member Functions

QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl (Time optionTime) const override
 
Volatility volatilityImpl (Time optionTime, Rate strike) const override
 
void performCalculations () const override
 

Private Attributes

Handle< OptionletVolatilityStructure > baseVol_
 
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 35 of file spreadedoptionletvolatility2.hpp.

Constructor & Destructor Documentation

◆ SpreadedOptionletVolatility2()

SpreadedOptionletVolatility2 ( const Handle< OptionletVolatilityStructure > &  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 spreadedoptionletvolatility2.cpp.

31 : baseVol_(baseVol), optionDates_(optionDates), strikes_(strikes), volSpreads_(volSpreads) {
32 registerWith(baseVol_);
33
34 QL_REQUIRE(!optionDates_.empty(), "SpreadedOptionletVolatility2(): optionDates are empty");
35 QL_REQUIRE(!strikes_.empty(), "SpreadedOptionletVolatility2(): strikes are empty");
36
37 // add an artificial option date if we only have one to ensure the interpolation is working
38 if (optionDates_.size() == 1) {
39 optionDates_.push_back(optionDates_.back() + 1);
40 volSpreads_.push_back(volSpreads_.back());
41 }
42
43 // add an artificial strike if we only have one to ensure the interpolation is working
44 if (strikes_.size() == 1) {
45 strikes_.push_back(strikes_.back() + 0.01);
46 for (auto& v : volSpreads_)
47 v.push_back(v.back());
48 }
49
50 optionTimes_.resize(optionDates_.size());
51 volSpreadValues_ = Matrix(strikes_.size(), optionDates_.size());
52 for (auto const& v : volSpreads_)
53 for (auto const& q : v)
54 registerWith(q);
55}
Handle< OptionletVolatilityStructure > baseVol_
std::vector< std::vector< Handle< Quote > > > volSpreads_
vector< Real > strikes

Member Function Documentation

◆ businessDayConvention()

BusinessDayConvention businessDayConvention ( ) const
override

Definition at line 63 of file spreadedoptionletvolatility2.cpp.

63 {
64 return baseVol_->businessDayConvention();
65}

◆ minStrike()

Rate minStrike ( ) const
override

Definition at line 66 of file spreadedoptionletvolatility2.cpp.

66{ return baseVol_->minStrike(); }

◆ maxStrike()

Rate maxStrike ( ) const
override

Definition at line 67 of file spreadedoptionletvolatility2.cpp.

67{ return baseVol_->maxStrike(); }

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 57 of file spreadedoptionletvolatility2.cpp.

57{ return baseVol_->dayCounter(); }

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 58 of file spreadedoptionletvolatility2.cpp.

58{ return baseVol_->maxDate(); }

◆ maxTime()

Time maxTime ( ) const
override

Definition at line 59 of file spreadedoptionletvolatility2.cpp.

59{ return baseVol_->maxTime(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 60 of file spreadedoptionletvolatility2.cpp.

60{ return baseVol_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 61 of file spreadedoptionletvolatility2.cpp.

61{ return baseVol_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 62 of file spreadedoptionletvolatility2.cpp.

62{ return baseVol_->settlementDays(); }

◆ volatilityType()

VolatilityType volatilityType ( ) const
override

Definition at line 68 of file spreadedoptionletvolatility2.cpp.

68{ return baseVol_->volatilityType(); }

◆ displacement()

Real displacement ( ) const
override

Definition at line 69 of file spreadedoptionletvolatility2.cpp.

69{ return baseVol_->displacement(); }

◆ update()

void update ( )
override

Definition at line 99 of file spreadedoptionletvolatility2.cpp.

99 {
100 OptionletVolatilityStructure::update();
101 LazyObject::update();
102}
+ Here is the caller graph for this function:

◆ deepUpdate()

void deepUpdate ( )
override

Definition at line 104 of file spreadedoptionletvolatility2.cpp.

104 {
105 baseVol_->update();
106 update();
107}
+ Here is the call graph for this function:

◆ smileSectionImpl()

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

Definition at line 71 of file spreadedoptionletvolatility2.cpp.

71 {
72 calculate();
73 std::vector<Real> volSpreads(strikes_.size());
74 for (Size k = 0; k < strikes_.size(); ++k) {
75 volSpreads[k] = volSpreadInterpolation_(optionTime, strikes_[k]);
76 }
77 return QuantLib::ext::make_shared<SpreadedSmileSection2>(baseVol_->smileSection(optionTime), volSpreads, strikes_);
78}
+ Here is the caller graph for this function:

◆ volatilityImpl()

Volatility volatilityImpl ( Time  optionTime,
Rate  strike 
) const
overrideprotected

Definition at line 80 of file spreadedoptionletvolatility2.cpp.

80 {
81 return smileSectionImpl(optionTime)->volatility(strike);
82}
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime) const override
+ Here is the call graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprotected

Definition at line 84 of file spreadedoptionletvolatility2.cpp.

84 {
85 for (Size i = 0; i < optionDates_.size(); ++i)
86 optionTimes_[i] = timeFromReference(optionDates_[i]);
87 for (Size k = 0; k < strikes_.size(); ++k) {
88 for (Size i = 0; i < optionDates_.size(); ++i) {
89 QL_REQUIRE(!volSpreads_[i][k].empty(), "SpreadedOptionletVolatility2::performCalculations(): volSpread at "
90 << i << ", " << k << " is empty");
91 volSpreadValues_(k, i) = volSpreads_[i][k]->value();
92 }
93 }
94 volSpreadInterpolation_ = FlatExtrapolator2D(QuantLib::ext::make_shared<BilinearInterpolation>(
95 optionTimes_.begin(), optionTimes_.end(), strikes_.begin(), strikes_.end(), volSpreadValues_));
96 volSpreadInterpolation_.enableExtrapolation();
97}

Member Data Documentation

◆ baseVol_

Handle<OptionletVolatilityStructure> baseVol_
private

Definition at line 60 of file spreadedoptionletvolatility2.hpp.

◆ optionDates_

std::vector<Date> optionDates_
private

Definition at line 61 of file spreadedoptionletvolatility2.hpp.

◆ strikes_

std::vector<Real> strikes_
private

Definition at line 62 of file spreadedoptionletvolatility2.hpp.

◆ volSpreads_

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

Definition at line 63 of file spreadedoptionletvolatility2.hpp.

◆ optionTimes_

std::vector<Real> optionTimes_
mutableprivate

Definition at line 65 of file spreadedoptionletvolatility2.hpp.

◆ volSpreadValues_

Matrix volSpreadValues_
mutableprivate

Definition at line 66 of file spreadedoptionletvolatility2.hpp.

◆ volSpreadInterpolation_

Interpolation2D volSpreadInterpolation_
mutableprivate

Definition at line 67 of file spreadedoptionletvolatility2.hpp.