Class SwaptionVolatilityMatrix
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The at-the-money swaption-volatility matrix: the volatility of a swaption, bilinearly interpolated in the swap length and the option time between the market volatilities of a grid of option dates and swap tenors.
public sealed class SwaptionVolatilityMatrix : SwaptionVolatilityDiscrete
- Inheritance
-
SwaptionVolatilityMatrix
- Inherited Members
- Extension Methods
Remarks
The volatility matrix has a row per option date and a column per swap tenor: the element (i, j) is the volatility of the i-th option and the j-th tenor; the shifts, when given, are laid out alike. The constructor copies both. Outside the grid the interpolation extends linearly, or, with flat extrapolation, takes the nearest edge's value; a query outside the structure's range is refused unless extrapolation is enabled or requested.
QuantLib's constructors on quotes and on a Matrix coincide once a quote is a double: the Matrix forms are kept, and the floating forms, whose reference date is the evaluation date adjusted on the calendar, are Create(Calendar, BusinessDayConvention, IEnumerable<Period>, IEnumerable<Period>, Matrix, DayCounter, EvaluationContext, bool, VolatilityType, Matrix?). As in QuantLib, the smile sections are by time, flat at the at-the-money volatility (read at a dummy strike of 5%), and the shift is read without the lognormal check that ConstantSwaptionVolatility makes.
Constructors
SwaptionVolatilityMatrix(Date, Calendar?, BusinessDayConvention, IEnumerable<Date>, IEnumerable<Period>, Matrix, DayCounter, bool, VolatilityType, Matrix?)
Initializes a new instance of the SwaptionVolatilityMatrix class with a fixed reference date, on option dates.
public SwaptionVolatilityMatrix(Date referenceDate, Calendar? calendar, BusinessDayConvention bdc, IEnumerable<Date> optionDates, IEnumerable<Period> swapTenors, Matrix volatilities, DayCounter dayCounter, bool flatExtrapolation = false, VolatilityType type = VolatilityType.ShiftedLognormal, Matrix? shifts = null)
Parameters
referenceDateDateThe reference date.
calendarCalendarThe calendar of option dates computed from tenors, or null, QuantLib's empty calendar.
bdcBusinessDayConventionThe convention adjusting option dates computed from tenors.
optionDatesIEnumerable<Date>The option dates, after the reference date and increasing.
swapTenorsIEnumerable<Period>The swap tenors, positive, increasing, and in months or years.
volatilitiesMatrixThe volatilities: a row per option date and a column per swap tenor.
dayCounterDayCounterThe day counter.
flatExtrapolationboolWhether the volatilities extrapolate flat outside the grid, rather than linearly.
typeVolatilityTypeThe volatility type.
shiftsMatrixThe shifts, laid out as the volatilities; zero when null or empty, QuantLib's default
Matrix().
Exceptions
- ArgumentNullException
A collection, the volatilities or the day counter is null.
- ArgumentException
The dates are empty, not after the reference date or not increasing, the swap tenors are empty, not positive, not increasing or not in months or years, a matrix's size isn't the grid's, or there are fewer than two option dates or swap tenors.
- ArgumentOutOfRangeException
bdcortypeisn't a member of its type.- NanoQLException
Two swap tenors can't be compared.
SwaptionVolatilityMatrix(Date, Calendar?, BusinessDayConvention, IEnumerable<Period>, IEnumerable<Period>, Matrix, DayCounter, bool, VolatilityType, Matrix?)
Initializes a new instance of the SwaptionVolatilityMatrix class with a fixed reference date, on option tenors.
public SwaptionVolatilityMatrix(Date referenceDate, Calendar? calendar, BusinessDayConvention bdc, IEnumerable<Period> optionTenors, IEnumerable<Period> swapTenors, Matrix volatilities, DayCounter dayCounter, bool flatExtrapolation = false, VolatilityType type = VolatilityType.ShiftedLognormal, Matrix? shifts = null)
Parameters
referenceDateDateThe reference date.
calendarCalendarThe calendar of the option dates, or null, QuantLib's empty calendar, with which option dates can't be computed from tenors.
bdcBusinessDayConventionThe convention adjusting the option dates.
optionTenorsIEnumerable<Period>The option tenors, positive and increasing.
swapTenorsIEnumerable<Period>The swap tenors, positive, increasing, and in months or years.
volatilitiesMatrixThe volatilities: a row per option tenor and a column per swap tenor.
dayCounterDayCounterThe day counter.
flatExtrapolationboolWhether the volatilities extrapolate flat outside the grid, rather than linearly.
typeVolatilityTypeThe volatility type.
shiftsMatrixThe shifts, laid out as the volatilities; zero when null or empty, QuantLib's default
Matrix().
Exceptions
- ArgumentNullException
A collection, the volatilities or the day counter is null.
- ArgumentException
The tenors are empty, not positive or not increasing, a swap tenor isn't in months or years, a matrix's size isn't the grid's, or there are fewer than two option or swap tenors.
- ArgumentOutOfRangeException
bdcortypeisn't a member of its type.- NanoQLException
Two tenors can't be compared, or the calendar is null.
Properties
MaxDate
Gets the latest date for which the structure returns volatilities: the last option date.
public override Date MaxDate { get; }
Property Value
MaxSwapTenor
Gets the largest swap tenor for which the structure returns volatilities: the last swap tenor.
public override Period MaxSwapTenor { get; }
Property Value
VolatilityType
Gets the type of the volatilities the structure returns; by default shifted lognormal.
public override VolatilityType VolatilityType { get; }
Property Value
Methods
Create(Calendar, BusinessDayConvention, IEnumerable<Period>, IEnumerable<Period>, Matrix, DayCounter, EvaluationContext, bool, VolatilityType, Matrix?)
A volatility matrix whose reference date is the evaluation date, adjusted on the calendar: QuantLib's floating forms, on settlement days 0.
public static SwaptionVolatilityMatrix Create(Calendar calendar, BusinessDayConvention bdc, IEnumerable<Period> optionTenors, IEnumerable<Period> swapTenors, Matrix volatilities, DayCounter dayCounter, EvaluationContext context, bool flatExtrapolation = false, VolatilityType type = VolatilityType.ShiftedLognormal, Matrix? shifts = null)
Parameters
calendarCalendarThe calendar the reference date is adjusted on and the option dates are computed on.
bdcBusinessDayConventionThe convention adjusting the option dates.
optionTenorsIEnumerable<Period>The option tenors, positive and increasing.
swapTenorsIEnumerable<Period>The swap tenors, positive, increasing, and in months or years.
volatilitiesMatrixThe volatilities: a row per option tenor and a column per swap tenor.
dayCounterDayCounterThe day counter.
contextEvaluationContextThe evaluation context.
flatExtrapolationboolWhether the volatilities extrapolate flat outside the grid, rather than linearly.
typeVolatilityTypeThe volatility type.
shiftsMatrixThe shifts, laid out as the volatilities; zero when null or empty, QuantLib's default
Matrix().
Returns
- SwaptionVolatilityMatrix
The structure, with a fixed reference date.
Exceptions
- ArgumentNullException
context,calendar, a collection, the volatilities or the day counter is null.- ArgumentException
The tenors are empty, not positive or not increasing, a swap tenor isn't in months or years, a matrix's size isn't the grid's, or there are fewer than two option or swap tenors.
- ArgumentOutOfRangeException
bdcortypeisn't a member of its type.- NanoQLException
Two tenors can't be compared.
Locate(Date, Period)
The lower indexes of the volatility matrix's corners surrounding an option date and a swap tenor.
public (int OptionIndex, int SwapIndex) Locate(Date optionDate, Period swapTenor)
Parameters
Returns
Exceptions
- ArgumentException
The swap tenor isn't positive, or isn't in months or years.
Locate(double, double)
The lower indexes of the volatility matrix's corners surrounding an option time and a swap length.
public (int OptionIndex, int SwapIndex) Locate(double optionTime, double swapLength)
Parameters
Returns
MaxStrike()
The maximum strike for which the structure returns values.
public override double MaxStrike()
Returns
- double
The strike.
MinStrike()
The minimum strike for which the structure returns values.
public override double MinStrike()
Returns
- double
The strike.
ShiftImpl(double, double)
The interpolated shift, for either volatility type: QuantLib's matrix makes no lognormal check.
protected override double ShiftImpl(double optionTime, double swapLength)
Parameters
Returns
- double
The shift.
SmileSectionImpl(double, double)
The smile section for an option time and a swap length, without range checks.
protected override SmileSection SmileSectionImpl(double optionTime, double swapLength)
Parameters
Returns
- SmileSection
The smile section.
VolatilityImpl(double, double, double)
The volatility for an option time, a swap length and a strike, without range checks.
protected override double VolatilityImpl(double optionTime, double swapLength, double strike)
Parameters
optionTimedoubleThe option time.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
Returns
- double
The volatility.