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

Takes a SwaptionVolatilityMatrix with fixed reference date and turns it into a floating reference date term. More...

#include <qle/termstructures/dynamicswaptionvolmatrix.hpp>

+ Inheritance diagram for DynamicSwaptionVolatilityMatrix:
+ Collaboration diagram for DynamicSwaptionVolatilityMatrix:

Public Member Functions

 DynamicSwaptionVolatilityMatrix (const QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > &source, Natural settlementDays, const Calendar &calendar, ReactionToTimeDecay decayMode=ConstantVariance)
 

Protected Member Functions

const Period & maxSwapTenor () const override
 
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl (Time optionTime, Time swapLength) const override
 
Volatility volatilityImpl (Time optionTime, Time swapLength, Rate strike) const override
 
Real shiftImpl (Time optionTime, Time swapLength) const override
 
Real minStrike () const override
 
Real maxStrike () const override
 
Date maxDate () const override
 
void update () override
 
VolatilityType volatilityType () const override
 

Private Attributes

const QuantLib::ext::shared_ptr< SwaptionVolatilityStructuresource_
 
ReactionToTimeDecay decayMode_
 
const Date originalReferenceDate_
 
VolatilityType volatilityType_
 

Detailed Description

Takes a SwaptionVolatilityMatrix with fixed reference date and turns it into a floating reference date term.

This class takes a SwaptionVolatilityMatrix with fixed reference date and turns it into a floating reference date term structure. There are different ways of reacting to time decay that can be specified.

Warning:
the vols from the source ts are read using strike null (indicating atm)

Definition at line 45 of file dynamicswaptionvolmatrix.hpp.

Constructor & Destructor Documentation

◆ DynamicSwaptionVolatilityMatrix()

DynamicSwaptionVolatilityMatrix ( const QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > &  source,
Natural  settlementDays,
const Calendar &  calendar,
ReactionToTimeDecay  decayMode = ConstantVariance 
)

Definition at line 25 of file dynamicswaptionvolmatrix.cpp.

28 : SwaptionVolatilityStructure(settlementDays, calendar, source->businessDayConvention(), source->dayCounter()),
29 source_(source), decayMode_(decayMode), originalReferenceDate_(source->referenceDate()),
30 volatilityType_(source->volatilityType()) {}
const QuantLib::ext::shared_ptr< SwaptionVolatilityStructure > source_

Member Function Documentation

◆ maxSwapTenor()

const Period & maxSwapTenor ( ) const
overrideprotected

Definition at line 32 of file dynamicswaptionvolmatrix.cpp.

32{ return source_->maxSwapTenor(); }

◆ smileSectionImpl()

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

Definition at line 34 of file dynamicswaptionvolmatrix.cpp.

35 {
36 // null strike to indicate ATM
37 return QuantLib::ext::make_shared<FlatSmileSection>(optionTime, volatilityImpl(optionTime, swapLength, Null<Real>()),
38 source_->dayCounter(), Null<Real>(), source_->volatilityType(),
39 shiftImpl(optionTime, swapLength));
40}
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
Real shiftImpl(Time optionTime, Time swapLength) const override
+ Here is the call graph for this function:

◆ volatilityImpl()

Volatility volatilityImpl ( Time  optionTime,
Time  swapLength,
Rate  strike 
) const
overrideprotected

Definition at line 42 of file dynamicswaptionvolmatrix.cpp.

42 {
44 Real tf = source_->timeFromReference(referenceDate());
45 if (source_->volatilityType() == ShiftedLognormal) {
46 QL_REQUIRE(close_enough(source_->shift(tf + optionTime, swapLength), source_->shift(tf, swapLength)),
47 "DynamicSwaptionVolatilityMatrix: Shift must be constant in option time direction");
48 }
49 Real realisedVariance =
50 source_->blackVariance(tf + optionTime, swapLength, strike) -
51 (tf > 0.0 && !close_enough(tf, 0.0) ? source_->blackVariance(tf, swapLength, strike) : 0.0);
52 return std::sqrt(std::max(realisedVariance / optionTime, 1E-6));
53 }
55 return source_->volatility(optionTime, swapLength, strike);
56 }
57 QL_FAIL("unexpected decay mode (" << decayMode_ << ")");
58}
@ ConstantVariance
@ ForwardForwardVariance
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shiftImpl()

Real shiftImpl ( Time  optionTime,
Time  swapLength 
) const
overrideprotected

Definition at line 60 of file dynamicswaptionvolmatrix.cpp.

60 {
61 if (source_->volatilityType() == Normal) {
62 return 0.0;
63 }
65 Real tf = source_->timeFromReference(referenceDate());
66 return source_->shift(tf + optionTime, swapLength);
67 }
69 return source_->shift(optionTime, swapLength);
70 }
71 QL_FAIL("unexpected decay mode (" << decayMode_ << ")");
72}
+ Here is the caller graph for this function:

◆ minStrike()

Real minStrike ( ) const
overrideprotected

Definition at line 74 of file dynamicswaptionvolmatrix.cpp.

74{ return source_->minStrike(); }

◆ maxStrike()

Real maxStrike ( ) const
overrideprotected

Definition at line 76 of file dynamicswaptionvolmatrix.cpp.

76{ return source_->maxStrike(); }

◆ maxDate()

Date maxDate ( ) const
overrideprotected

Definition at line 78 of file dynamicswaptionvolmatrix.cpp.

78 {
80 return source_->maxDate();
81 }
83 return Date(std::min(Date::maxDate().serialNumber(), referenceDate().serialNumber() -
84 originalReferenceDate_.serialNumber() +
85 source_->maxDate().serialNumber()));
86 }
87 QL_FAIL("unexpected decay mode (" << decayMode_ << ")");
88}

◆ update()

void update ( )
overrideprotected

Definition at line 90 of file dynamicswaptionvolmatrix.cpp.

90{ SwaptionVolatilityStructure::update(); }

◆ volatilityType()

VolatilityType volatilityType ( ) const
overrideprotected

Definition at line 78 of file dynamicswaptionvolmatrix.hpp.

78{ return volatilityType_; }

Member Data Documentation

◆ source_

const QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> source_
private

Definition at line 72 of file dynamicswaptionvolmatrix.hpp.

◆ decayMode_

ReactionToTimeDecay decayMode_
private

Definition at line 73 of file dynamicswaptionvolmatrix.hpp.

◆ originalReferenceDate_

const Date originalReferenceDate_
private

Definition at line 74 of file dynamicswaptionvolmatrix.hpp.

◆ volatilityType_

VolatilityType volatilityType_
private

Definition at line 75 of file dynamicswaptionvolmatrix.hpp.