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

#include <qle/termstructures/swaptionvolcube2.hpp>

+ Inheritance diagram for SwaptionVolCube2:
+ Collaboration diagram for SwaptionVolCube2:

Public Member Functions

 SwaptionVolCube2 (const Handle< SwaptionVolatilityStructure > &atmVolStructure, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const std::vector< Spread > &strikeSpreads, const std::vector< std::vector< Handle< Quote > > > &volSpreads, const QuantLib::ext::shared_ptr< SwapIndex > &swapIndexBase, const QuantLib::ext::shared_ptr< SwapIndex > &shortSwapIndexBase, bool vegaWeightedSmileFit, bool flatExtrapolation, bool volsAreSpreads=true)
 
LazyObject interface
void performCalculations () const override
 

SwaptionVolatilityCube inspectors

const bool flatExtrapolation_
 
const bool volsAreSpreads_
 
std::vector< Interpolation2D > volSpreadsInterpolator_
 
std::vector< Matrix > volSpreadsMatrix_
 
const Matrix & volSpreads (Size i) const
 
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl (const Date &optionDate, const Period &swapTenor) const override
 
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl (Time optionTime, Time swapLength) const override
 

Detailed Description

Definition at line 50 of file swaptionvolcube2.hpp.

Constructor & Destructor Documentation

◆ SwaptionVolCube2()

SwaptionVolCube2 ( const Handle< SwaptionVolatilityStructure > &  atmVolStructure,
const std::vector< Period > &  optionTenors,
const std::vector< Period > &  swapTenors,
const std::vector< Spread > &  strikeSpreads,
const std::vector< std::vector< Handle< Quote > > > &  volSpreads,
const QuantLib::ext::shared_ptr< SwapIndex > &  swapIndexBase,
const QuantLib::ext::shared_ptr< SwapIndex > &  shortSwapIndexBase,
bool  vegaWeightedSmileFit,
bool  flatExtrapolation,
bool  volsAreSpreads = true 
)

The swaption vol cube is made up of ordered swaption vol surface layers, each layer referring to a swap index of a given length (in years), all indexes belonging to the same family. In order to identify the family (and its market conventions) an index of whatever length from that family must be passed in as swapIndexBase.

Often for short swap length the swap index family is different, e.g. the EUR case: swap vs 6M Euribor is used for length>1Y, while swap vs 3M Euribor is used for the 1Y length. The shortSwapIndexBase is used to identify this second family.

If flatExtrapolation is true the implied volatility is extrapolated flat in strike direction.

in case volsAreSpreads is false the given volSpreads are interpreted as absolute vols, in this case the volSpreads inspectors also return absolute vols

Definition at line 50 of file swaptionvolcube2.cpp.

57 : SwaptionVolatilityCube(atmVolStructure, optionTenors, swapTenors, strikeSpreads, volSpreads, swapIndexBase,
58 shortSwapIndexBase, vegaWeightedSmileFit),
59 flatExtrapolation_(flatExtrapolation), volsAreSpreads_(volsAreSpreads), volSpreadsInterpolator_(nStrikes_),
60 volSpreadsMatrix_(nStrikes_, Matrix(optionTenors.size(), swapTenors.size(), 0.0)) {
61 QL_REQUIRE(std::find(strikeSpreads_.begin(), strikeSpreads_.end(), 0.0) != strikeSpreads_.end(),
62 "SwaptionVolCube2: strikeSpreads must contain 0.0 for atm vols");
63}
std::vector< Matrix > volSpreadsMatrix_
const Matrix & volSpreads(Size i) const
std::vector< Interpolation2D > volSpreadsInterpolator_

Member Function Documentation

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 65 of file swaptionvolcube2.cpp.

65 {
66
67 SwaptionVolatilityCube::performCalculations();
68 //! set volSpreadsMatrix_ by volSpreads_ quotes
69 for (Size i = 0; i < nStrikes_; i++)
70 for (Size j = 0; j < nOptionTenors_; j++)
71 for (Size k = 0; k < nSwapTenors_; k++) {
72 volSpreadsMatrix_[i][j][k] = volSpreads_[j * nSwapTenors_ + k][i]->value();
73 }
74 //! create volSpreadsInterpolator_
75 for (Size i = 0; i < nStrikes_; i++) {
78 BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(),
79 optionTimes_.end(), volSpreadsMatrix_[i]);
80 else
81 volSpreadsInterpolator_[i] = FlatExtrapolator2D(QuantLib::ext::make_shared<BilinearInterpolation>(
82 swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(),
84 volSpreadsInterpolator_[i].enableExtrapolation();
85 }
86}

◆ volSpreads()

const Matrix & volSpreads ( Size  i) const

Definition at line 82 of file swaptionvolcube2.hpp.

82{ return volSpreadsMatrix_[i]; }

◆ smileSectionImpl() [1/2]

QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl ( const Date &  optionDate,
const Period &  swapTenor 
) const
override

Definition at line 101 of file swaptionvolcube2.cpp.

102 {
103 calculate();
104 Rate atmForward = atmStrike(optionDate, swapTenor);
105 Volatility referenceVol = volsAreSpreads_ ? atmVol_->volatility(optionDate, swapTenor, atmForward) : 0.0;
106 Time optionTime = std::max(1E-6, timeFromReference(optionDate));
107 Real exerciseTimeSqrt = std::sqrt(optionTime);
108 std::vector<Real> strikes, stdDevs;
109 strikes.reserve(nStrikes_);
110 stdDevs.reserve(nStrikes_);
111 Time length = swapLength(swapTenor);
112 for (Size i = 0; i < nStrikes_; ++i) {
113 strikes.push_back(atmForward + strikeSpreads_[i]);
114 stdDevs.push_back(exerciseTimeSqrt * (referenceVol + volSpreadsInterpolator_[i](length, optionTime)));
115 }
116 Real shift = atmVol_->shift(optionTime, length);
118 return QuantLib::ext::shared_ptr<SmileSection>(new InterpolatedSmileSection<Linear>(
119 optionTime, strikes, stdDevs, atmForward, Linear(), Actual365Fixed(), volatilityType(), shift));
120 else
121 return QuantLib::ext::shared_ptr<SmileSection>(new InterpolatedSmileSection<LinearFlat>(
122 optionTime, strikes, stdDevs, atmForward, LinearFlat(), Actual365Fixed(), volatilityType(), shift));
123}
vector< Real > strikes
+ Here is the caller graph for this function:

◆ smileSectionImpl() [2/2]

QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl ( Time  optionTime,
Time  swapLength 
) const
override

Definition at line 88 of file swaptionvolcube2.cpp.

88 {
89
90 calculate();
91 Date optionDate = optionDateFromTime(optionTime);
92 Rounding rounder(0);
93 Period swapTenor(static_cast<Integer>(rounder(swapLength * 12.0)), Months);
94 // ensure that option date is valid fixing date
95 optionDate = swapTenor > shortSwapIndexBase_->tenor()
96 ? swapIndexBase_->fixingCalendar().adjust(optionDate, Following)
97 : shortSwapIndexBase_->fixingCalendar().adjust(optionDate, Following);
98 return smileSectionImpl(optionDate, swapTenor);
99}
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(const Date &optionDate, const Period &swapTenor) const override
+ Here is the call graph for this function:

Member Data Documentation

◆ flatExtrapolation_

const bool flatExtrapolation_
private

Definition at line 87 of file swaptionvolcube2.hpp.

◆ volsAreSpreads_

const bool volsAreSpreads_
private

Definition at line 87 of file swaptionvolcube2.hpp.

◆ volSpreadsInterpolator_

std::vector<Interpolation2D> volSpreadsInterpolator_
mutableprivate

Definition at line 88 of file swaptionvolcube2.hpp.

◆ volSpreadsMatrix_

std::vector<Matrix> volSpreadsMatrix_
mutableprivate

Definition at line 89 of file swaptionvolcube2.hpp.