QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SwaptionVolatilityMatrix Class Reference

At-the-money swaption-volatility matrix. More...

#include <swaptionvolmatrix.hpp>

+ Inheritance diagram for SwaptionVolatilityMatrix:
+ Collaboration diagram for SwaptionVolatilityMatrix:

Public Member Functions

 SwaptionVolatilityMatrix (const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const std::vector< std::vector< Handle< Quote > > > &vols, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const std::vector< std::vector< Real > > &shifts=std::vector< std::vector< Real > >())
 floating reference date, floating market data More...
 
 SwaptionVolatilityMatrix (const Date &referenceDate, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const std::vector< std::vector< Handle< Quote > > > &vols, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const std::vector< std::vector< Real > > &shifts=std::vector< std::vector< Real > >())
 fixed reference date, floating market data More...
 
 SwaptionVolatilityMatrix (const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const Matrix &volatilities, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const Matrix &shifts=Matrix())
 floating reference date, fixed market data More...
 
 SwaptionVolatilityMatrix (const Date &referenceDate, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const Matrix &volatilities, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const Matrix &shifts=Matrix())
 fixed reference date, fixed market data More...
 
 SwaptionVolatilityMatrix (const Date &referenceDate, const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Date > &optionDates, const std::vector< Period > &swapTenors, const Matrix &volatilities, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const Matrix &shifts=Matrix())
 fixed reference date and fixed market data, option dates More...
 
 SwaptionVolatilityMatrix (SwaptionVolatilityMatrix &&)=delete
 
 SwaptionVolatilityMatrix (const SwaptionVolatilityMatrix &)=delete
 
SwaptionVolatilityMatrixoperator= (SwaptionVolatilityMatrix &&)=delete
 
SwaptionVolatilityMatrixoperator= (const SwaptionVolatilityMatrix &)=delete
 
 ~SwaptionVolatilityMatrix () override=default
 
LazyObject interface
void performCalculations () const override
 
TermStructure interface
Date maxDate () const override
 the latest date for which the curve can return values More...
 
VolatilityTermStructure interface
Rate minStrike () const override
 the minimum strike for which the term structure can return vols More...
 
Rate maxStrike () const override
 the maximum strike for which the term structure can return vols More...
 
SwaptionVolatilityStructure interface
const PeriodmaxSwapTenor () const override
 the largest length for which the term structure can return vols More...
 
- Public Member Functions inherited from SwaptionVolatilityDiscrete
 SwaptionVolatilityDiscrete (const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc)
 
 SwaptionVolatilityDiscrete (const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const Date &referenceDate, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc)
 
 SwaptionVolatilityDiscrete (const std::vector< Date > &optionDates, const std::vector< Period > &swapTenors, const Date &referenceDate, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc)
 
const std::vector< Period > & optionTenors () const
 
const std::vector< Date > & optionDates () const
 
const std::vector< Time > & optionTimes () const
 
const std::vector< Period > & swapTenors () const
 
const std::vector< Time > & swapLengths () const
 
void update () override
 
Date optionDateFromTime (Time optionTime) const
 additional inspectors More...
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 
- Public Member Functions inherited from SwaptionVolatilityStructure
 SwaptionVolatilityStructure (BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 
 SwaptionVolatilityStructure (const Date &referenceDate, const Calendar &calendar, BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 initialize with a fixed reference date More...
 
 SwaptionVolatilityStructure (Natural settlementDays, const Calendar &, BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 calculate the reference date based on the global evaluation date More...
 
 ~SwaptionVolatilityStructure () override=default
 
Volatility volatility (const Period &optionTenor, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option tenor and swap tenor More...
 
Volatility volatility (const Date &optionDate, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option date and swap tenor More...
 
Volatility volatility (Time optionTime, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option time and swap tenor More...
 
Volatility volatility (const Period &optionTenor, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option tenor and swap length More...
 
Volatility volatility (const Date &optionDate, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option date and swap length More...
 
Volatility volatility (Time optionTime, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the volatility for a given option time and swap length More...
 
Real blackVariance (const Period &optionTenor, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option tenor and swap tenor More...
 
Real blackVariance (const Date &optionDate, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option date and swap tenor More...
 
Real blackVariance (Time optionTime, const Period &swapTenor, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option time and swap tenor More...
 
Real blackVariance (const Period &optionTenor, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option tenor and swap length More...
 
Real blackVariance (const Date &optionDate, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option date and swap length More...
 
Real blackVariance (Time optionTime, Time swapLength, Rate strike, bool extrapolate=false) const
 returns the Black variance for a given option time and swap length More...
 
Real shift (const Period &optionTenor, const Period &swapTenor, bool extrapolate=false) const
 returns the shift for a given option tenor and swap tenor More...
 
Real shift (const Date &optionDate, const Period &swapTenor, bool extrapolate=false) const
 returns the shift for a given option date and swap tenor More...
 
Real shift (Time optionTime, const Period &swapTenor, bool extrapolate=false) const
 returns the shift for a given option time and swap tenor More...
 
Real shift (const Period &optionTenor, Time swapLength, bool extrapolate=false) const
 returns the shift for a given option tenor and swap length More...
 
Real shift (const Date &optionDate, Time swapLength, bool extrapolate=false) const
 returns the shift for a given option date and swap length More...
 
Real shift (Time optionTime, Time swapLength, bool extrapolate=false) const
 returns the shift for a given option time and swap length More...
 
ext::shared_ptr< SmileSectionsmileSection (const Period &optionTenor, const Period &swapTenor, bool extr=false) const
 returns the smile for a given option tenor and swap tenor More...
 
ext::shared_ptr< SmileSectionsmileSection (const Date &optionDate, const Period &swapTenor, bool extr=false) const
 returns the smile for a given option date and swap tenor More...
 
ext::shared_ptr< SmileSectionsmileSection (Time optionTime, const Period &swapTenor, bool extr=false) const
 returns the smile for a given option time and swap tenor More...
 
ext::shared_ptr< SmileSectionsmileSection (const Period &optionTenor, Time swapLength, bool extr=false) const
 returns the smile for a given option tenor and swap length More...
 
ext::shared_ptr< SmileSectionsmileSection (const Date &optionDate, Time swapLength, bool extr=false) const
 returns the smile for a given option date and swap length More...
 
ext::shared_ptr< SmileSectionsmileSection (Time optionTime, Time swapLength, bool extr=false) const
 returns the smile for a given option time and swap length More...
 
Time maxSwapLength () const
 the largest swapLength for which the term structure can return vols More...
 
Time swapLength (const Period &swapTenor) const
 implements the conversion between swap tenor and swap (time) length More...
 
Time swapLength (const Date &start, const Date &end) const
 implements the conversion between swap dates and swap (time) length More...
 
- Public Member Functions inherited from VolatilityTermStructure
 VolatilityTermStructure (BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 
 VolatilityTermStructure (const Date &referenceDate, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 initialize with a fixed reference date More...
 
 VolatilityTermStructure (Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter &dc=DayCounter())
 calculate the reference date based on the global evaluation date More...
 
virtual BusinessDayConvention businessDayConvention () const
 the business day convention used in tenor to date conversion More...
 
Date optionDateFromTenor (const Period &) const
 period/date conversion More...
 
- Public Member Functions inherited from TermStructure
 TermStructure (DayCounter dc=DayCounter())
 default constructor More...
 
 TermStructure (const Date &referenceDate, Calendar calendar=Calendar(), DayCounter dc=DayCounter())
 initialize with a fixed reference date More...
 
 TermStructure (Natural settlementDays, Calendar, DayCounter dc=DayCounter())
 calculate the reference date based on the global evaluation date More...
 
 ~TermStructure () override=default
 
virtual DayCounter dayCounter () const
 the day counter used for date/time conversion More...
 
Time timeFromReference (const Date &date) const
 date/time conversion More...
 
virtual Time maxTime () const
 the latest time for which the curve can return values More...
 
virtual const DatereferenceDate () const
 the date at which discount = 1.0 and/or variance = 0.0 More...
 
virtual Calendar calendar () const
 the calendar used for reference and/or option date calculation More...
 
virtual Natural settlementDays () const
 the settlementDays used for reference date calculation More...
 
- Public Member Functions inherited from Extrapolator
 Extrapolator ()=default
 
virtual ~Extrapolator ()=default
 
void enableExtrapolation (bool b=true)
 enable extrapolation in subsequent calls More...
 
void disableExtrapolation (bool b=true)
 disable extrapolation in subsequent calls More...
 
bool allowsExtrapolation () const
 tells whether extrapolation is enabled More...
 

Other inspectors

std::vector< std::vector< Handle< Quote > > > volHandles_
 
std::vector< std::vector< Real > > shiftValues_
 
Matrix volatilities_
 
Matrix shifts_
 
Interpolation2D interpolation_
 
Interpolation2D interpolationShifts_
 
VolatilityType volatilityType_
 
std::pair< Size, Sizelocate (const Date &optionDate, const Period &swapTenor) const
 returns the lower indexes of surrounding volatility matrix corners More...
 
std::pair< Size, Sizelocate (Time optionTime, Time swapLength) const
 returns the lower indexes of surrounding volatility matrix corners More...
 
VolatilityType volatilityType () const override
 volatility type More...
 
ext::shared_ptr< SmileSectionsmileSectionImpl (Time, Time) const override
 
Volatility volatilityImpl (Time optionTime, Time swapLength, Rate strike) const override
 
Real shiftImpl (Time optionTime, Time swapLength) const override
 
void checkInputs (Size volRows, Size volsColumns, Size shiftRows, Size shiftsColumns) const
 
void registerWithMarketData ()
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from LazyObject
virtual void calculate () const
 
- Protected Member Functions inherited from SwaptionVolatilityStructure
virtual ext::shared_ptr< SmileSectionsmileSectionImpl (const Date &optionDate, const Period &swapTenor) const
 
virtual Volatility volatilityImpl (const Date &optionDate, const Period &swapTenor, Rate strike) const
 
virtual Real shiftImpl (const Date &optionDate, const Period &swapTenor) const
 
void checkSwapTenor (const Period &swapTenor, bool extrapolate) const
 
void checkSwapTenor (Time swapLength, bool extrapolate) const
 
- Protected Member Functions inherited from VolatilityTermStructure
void checkStrike (Rate strike, bool extrapolate) const
 strike-range check More...
 
- Protected Member Functions inherited from TermStructure
void checkRange (const Date &d, bool extrapolate) const
 date-range check More...
 
void checkRange (Time t, bool extrapolate) const
 time-range check More...
 
- Protected Attributes inherited from SwaptionVolatilityDiscrete
Size nOptionTenors_
 
std::vector< PeriodoptionTenors_
 
std::vector< DateoptionDates_
 
std::vector< TimeoptionTimes_
 
Interpolation optionInterpolator_
 
std::vector< RealoptionDatesAsReal_
 
std::vector< TimeoptionInterpolatorTimes_
 
std::vector< RealoptionInterpolatorDatesAsReal_
 
Size nSwapTenors_
 
std::vector< PeriodswapTenors_
 
std::vector< TimeswapLengths_
 
Date cachedReferenceDate_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 
- Protected Attributes inherited from TermStructure
bool moving_ = false
 
bool updated_ = true
 
Calendar calendar_
 

Detailed Description

At-the-money swaption-volatility matrix.

This class provides the at-the-money volatility for a given swaption by interpolating a volatility matrix whose elements are the market volatilities of a set of swaption with given option date and swapLength.

The volatility matrix M must be defined so that:

Definition at line 51 of file swaptionvolmatrix.hpp.

Constructor & Destructor Documentation

◆ SwaptionVolatilityMatrix() [1/7]

SwaptionVolatilityMatrix ( const Calendar calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Period > &  swapTenors,
const std::vector< std::vector< Handle< Quote > > > &  vols,
const DayCounter dayCounter,
bool  flatExtrapolation = false,
VolatilityType  type = ShiftedLognormal,
const std::vector< std::vector< Real > > &  shifts = std::vector<std::vector<Real> >() 
)

floating reference date, floating market data

Definition at line 36 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ SwaptionVolatilityMatrix() [2/7]

SwaptionVolatilityMatrix ( const Date referenceDate,
const Calendar calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Period > &  swapTenors,
const std::vector< std::vector< Handle< Quote > > > &  vols,
const DayCounter dayCounter,
bool  flatExtrapolation = false,
VolatilityType  type = ShiftedLognormal,
const std::vector< std::vector< Real > > &  shifts = std::vector<std::vector<Real> >() 
)

fixed reference date, floating market data

Definition at line 73 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ SwaptionVolatilityMatrix() [3/7]

SwaptionVolatilityMatrix ( const Calendar calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Period > &  swapTenors,
const Matrix volatilities,
const DayCounter dayCounter,
bool  flatExtrapolation = false,
VolatilityType  type = ShiftedLognormal,
const Matrix shifts = Matrix() 
)

floating reference date, fixed market data

Definition at line 111 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ SwaptionVolatilityMatrix() [4/7]

SwaptionVolatilityMatrix ( const Date referenceDate,
const Calendar calendar,
BusinessDayConvention  bdc,
const std::vector< Period > &  optionTenors,
const std::vector< Period > &  swapTenors,
const Matrix volatilities,
const DayCounter dayCounter,
bool  flatExtrapolation = false,
VolatilityType  type = ShiftedLognormal,
const Matrix shifts = Matrix() 
)

fixed reference date, fixed market data

Definition at line 159 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ SwaptionVolatilityMatrix() [5/7]

SwaptionVolatilityMatrix ( const Date referenceDate,
const Calendar calendar,
BusinessDayConvention  bdc,
const std::vector< Date > &  optionDates,
const std::vector< Period > &  swapTenors,
const Matrix volatilities,
const DayCounter dayCounter,
bool  flatExtrapolation = false,
VolatilityType  type = ShiftedLognormal,
const Matrix shifts = Matrix() 
)

fixed reference date and fixed market data, option dates

Definition at line 208 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ SwaptionVolatilityMatrix() [6/7]

◆ SwaptionVolatilityMatrix() [7/7]

◆ ~SwaptionVolatilityMatrix()

~SwaptionVolatilityMatrix ( )
overridedefault

Member Function Documentation

◆ operator=() [1/2]

◆ operator=() [2/2]

SwaptionVolatilityMatrix & operator= ( const SwaptionVolatilityMatrix )
delete

◆ performCalculations()

void performCalculations ( ) const
overridevirtual

This method must implement any calculations which must be (re)done in order to calculate the desired results.

Reimplemented from SwaptionVolatilityDiscrete.

Definition at line 294 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ maxDate()

Date maxDate ( ) const
overridevirtual

the latest date for which the curve can return values

Implements TermStructure.

Definition at line 175 of file swaptionvolmatrix.hpp.

◆ minStrike()

Rate minStrike ( ) const
overridevirtual

the minimum strike for which the term structure can return vols

Implements VolatilityTermStructure.

Definition at line 179 of file swaptionvolmatrix.hpp.

◆ maxStrike()

Rate maxStrike ( ) const
overridevirtual

the maximum strike for which the term structure can return vols

Implements VolatilityTermStructure.

Definition at line 183 of file swaptionvolmatrix.hpp.

◆ maxSwapTenor()

const Period & maxSwapTenor ( ) const
overridevirtual

the largest length for which the term structure can return vols

Implements SwaptionVolatilityStructure.

Definition at line 187 of file swaptionvolmatrix.hpp.

◆ locate() [1/2]

std::pair< Size, Size > locate ( const Date optionDate,
const Period swapTenor 
) const

returns the lower indexes of surrounding volatility matrix corners

Definition at line 137 of file swaptionvolmatrix.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ locate() [2/2]

std::pair< Size, Size > locate ( Time  optionTime,
Time  swapLength 
) const

returns the lower indexes of surrounding volatility matrix corners

Definition at line 143 of file swaptionvolmatrix.hpp.

+ Here is the call graph for this function:

◆ volatilityType()

VolatilityType volatilityType ( ) const
overridevirtual

volatility type

Reimplemented from SwaptionVolatilityStructure.

Definition at line 198 of file swaptionvolmatrix.hpp.

+ Here is the caller graph for this function:

◆ smileSectionImpl()

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

Implements SwaptionVolatilityStructure.

Definition at line 320 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:

◆ volatilityImpl()

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

Implements SwaptionVolatilityStructure.

Definition at line 191 of file swaptionvolmatrix.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shiftImpl()

Real shiftImpl ( Time  optionTime,
Time  swapLength 
) const
overrideprotectedvirtual

Reimplemented from SwaptionVolatilityStructure.

Definition at line 202 of file swaptionvolmatrix.hpp.

+ Here is the call graph for this function:

◆ checkInputs()

void checkInputs ( Size  volRows,
Size  volsColumns,
Size  shiftRows,
Size  shiftsColumns 
) const
private

Definition at line 257 of file swaptionvolmatrix.cpp.

+ Here is the caller graph for this function:

◆ registerWithMarketData()

void registerWithMarketData ( )
private

Definition at line 287 of file swaptionvolmatrix.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ volHandles_

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

Definition at line 166 of file swaptionvolmatrix.hpp.

◆ shiftValues_

std::vector<std::vector<Real> > shiftValues_
private

Definition at line 167 of file swaptionvolmatrix.hpp.

◆ volatilities_

Matrix volatilities_
mutableprivate

Definition at line 168 of file swaptionvolmatrix.hpp.

◆ shifts_

Matrix shifts_
private

Definition at line 168 of file swaptionvolmatrix.hpp.

◆ interpolation_

Interpolation2D interpolation_
private

Definition at line 169 of file swaptionvolmatrix.hpp.

◆ interpolationShifts_

Interpolation2D interpolationShifts_
private

Definition at line 169 of file swaptionvolmatrix.hpp.

◆ volatilityType_

VolatilityType volatilityType_
private

Definition at line 170 of file swaptionvolmatrix.hpp.