Table of Contents

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

referenceDate Date

The reference date.

calendar Calendar

The calendar of option dates computed from tenors, or null, QuantLib's empty calendar.

bdc BusinessDayConvention

The convention adjusting option dates computed from tenors.

optionDates IEnumerable<Date>

The option dates, after the reference date and increasing.

swapTenors IEnumerable<Period>

The swap tenors, positive, increasing, and in months or years.

volatilities Matrix

The volatilities: a row per option date and a column per swap tenor.

dayCounter DayCounter

The day counter.

flatExtrapolation bool

Whether the volatilities extrapolate flat outside the grid, rather than linearly.

type VolatilityType

The volatility type.

shifts Matrix

The 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

bdc or type isn'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

referenceDate Date

The reference date.

calendar Calendar

The calendar of the option dates, or null, QuantLib's empty calendar, with which option dates can't be computed from tenors.

bdc BusinessDayConvention

The convention adjusting the option dates.

optionTenors IEnumerable<Period>

The option tenors, positive and increasing.

swapTenors IEnumerable<Period>

The swap tenors, positive, increasing, and in months or years.

volatilities Matrix

The volatilities: a row per option tenor and a column per swap tenor.

dayCounter DayCounter

The day counter.

flatExtrapolation bool

Whether the volatilities extrapolate flat outside the grid, rather than linearly.

type VolatilityType

The volatility type.

shifts Matrix

The 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

bdc or type isn'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

Date

MaxSwapTenor

Gets the largest swap tenor for which the structure returns volatilities: the last swap tenor.

public override Period MaxSwapTenor { get; }

Property Value

Period

VolatilityType

Gets the type of the volatilities the structure returns; by default shifted lognormal.

public override VolatilityType VolatilityType { get; }

Property Value

VolatilityType

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

calendar Calendar

The calendar the reference date is adjusted on and the option dates are computed on.

bdc BusinessDayConvention

The convention adjusting the option dates.

optionTenors IEnumerable<Period>

The option tenors, positive and increasing.

swapTenors IEnumerable<Period>

The swap tenors, positive, increasing, and in months or years.

volatilities Matrix

The volatilities: a row per option tenor and a column per swap tenor.

dayCounter DayCounter

The day counter.

context EvaluationContext

The evaluation context.

flatExtrapolation bool

Whether the volatilities extrapolate flat outside the grid, rather than linearly.

type VolatilityType

The volatility type.

shifts Matrix

The 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

bdc or type isn'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

optionDate Date

The option date.

swapTenor Period

The swap tenor.

Returns

(int Left, int Right)

The option's (row's) index and the swap's (column's) index.

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

optionTime double

The option time.

swapLength double

The swap length, in years.

Returns

(int Left, int Right)

The option's (row's) index and the swap's (column's) index.

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

optionTime double

The option time.

swapLength double

The swap length, in years.

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

optionTime double

The option time.

swapLength double

The swap length, in years.

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

optionTime double

The option time.

swapLength double

The swap length, in years.

strike double

The strike.

Returns

double

The volatility.