Class SwaptionVolatilityStructure
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The base class of swaption volatility structures: volatilities by option date and swap tenor.
public abstract class SwaptionVolatilityStructure : VolatilityTermStructure
- Inheritance
-
SwaptionVolatilityStructure
- Derived
- Inherited Members
- Extension Methods
Remarks
An option is given by its tenor from the reference date, its date or its time, and the swap by its tenor or its length in years, so each query has QuantLib's six overloads. A tenor's option date is the reference date advanced on the structure's calendar; a swap tenor's length is SwapLength(Period).
The smile sections pass the extrapolate flag as QuantLib does: those by an option time and a swap tenor, and
by an option tenor or date and a swap length, check the query with the flag and then call the overload by option
time or date and swap length without it, which checks the query again without extrapolating.
Constructors
SwaptionVolatilityStructure(Date, Calendar?, BusinessDayConvention, DayCounter, int?)
Initializes a new instance of the SwaptionVolatilityStructure class.
protected SwaptionVolatilityStructure(Date referenceDate, Calendar? calendar, BusinessDayConvention bdc, DayCounter dc, int? settlementDays = null)
Parameters
referenceDateDateThe reference date.
calendarCalendarThe calendar of the option dates, or null, QuantLib's empty calendar.
bdcBusinessDayConventionThe convention adjusting option dates computed from tenors.
dcDayCounterThe day counter.
settlementDaysint?The settlement days the reference date was calculated with, if any.
Properties
MaxSwapTenor
Gets the largest swap tenor for which the structure returns volatilities.
public abstract Period MaxSwapTenor { get; }
Property Value
VolatilityType
Gets the type of the volatilities the structure returns; by default shifted lognormal.
public virtual VolatilityType VolatilityType { get; }
Property Value
Methods
BlackVariance(Date, Period, double, bool)
The Black variance for an option date, a swap tenor and a strike: the volatility squared times the time.
public double BlackVariance(Date optionDate, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
BlackVariance(Date, double, double, bool)
The Black variance for an option date, a swap length and a strike: the volatility squared times the time.
public double BlackVariance(Date optionDate, double swapLength, double strike, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
BlackVariance(Period, Period, double, bool)
The Black variance for an option tenor, a swap tenor and a strike.
public double BlackVariance(Period optionTenor, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
BlackVariance(Period, double, double, bool)
The Black variance for an option tenor, a swap length and a strike.
public double BlackVariance(Period optionTenor, double swapLength, double strike, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
BlackVariance(double, Period, double, bool)
The Black variance for an option time, a swap tenor and a strike: the volatility squared times the time.
public double BlackVariance(double optionTime, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
BlackVariance(double, double, double, bool)
The Black variance for an option time, a swap length and a strike: the volatility squared times the time.
public double BlackVariance(double optionTime, double swapLength, double strike, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The variance.
CheckSwapTenor(Period, bool)
Checks that a swap tenor is positive and in the structure's range, or that extrapolation is allowed.
protected void CheckSwapTenor(Period swapTenor, bool extrapolate)
Parameters
Exceptions
- NanoQLException
The tenor isn't positive or is past the maximum swap tenor.
CheckSwapTenor(double, bool)
Checks that a swap length is positive and in the structure's range, or that extrapolation is allowed.
protected void CheckSwapTenor(double swapLength, bool extrapolate)
Parameters
Exceptions
- NanoQLException
The length isn't positive or is past the maximum swap length.
MaxSwapLength()
The largest swap length for which the structure returns volatilities: the length of MaxSwapTenor.
public double MaxSwapLength()
Returns
- double
The length, in years.
Exceptions
- ArgumentException
The maximum swap tenor has no swap length (SwapLength(Period)).
Shift(Date, Period, bool)
The shift for an option date and a swap tenor.
public double Shift(Date optionDate, Period swapTenor, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Exceptions
- NanoQLException
The swap tenor or the date is outside the structure's domain.
Shift(Date, double, bool)
The shift for an option date and a swap length.
public double Shift(Date optionDate, double swapLength, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Exceptions
- NanoQLException
The swap length or the date is outside the structure's domain.
Shift(Period, Period, bool)
The shift for an option tenor and a swap tenor.
public double Shift(Period optionTenor, Period swapTenor, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Shift(Period, double, bool)
The shift for an option tenor and a swap length.
public double Shift(Period optionTenor, double swapLength, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Shift(double, Period, bool)
The shift for an option time and a swap tenor.
public double Shift(double optionTime, Period swapTenor, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Exceptions
- NanoQLException
The swap tenor or the time is outside the structure's domain.
Shift(double, double, bool)
The shift for an option time and a swap length.
public double Shift(double optionTime, double swapLength, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The shift.
Exceptions
- NanoQLException
The swap length or the time is outside the structure's domain.
ShiftImpl(Date, Period)
The shift for an option date and a swap tenor, without range checks; by default the one for the date's time and the tenor's swap length.
protected virtual double ShiftImpl(Date optionDate, Period swapTenor)
Parameters
Returns
- double
The shift.
ShiftImpl(double, double)
The shift for an option time and a swap length, without range checks; by default 0, for a shifted lognormal structure only.
protected virtual double ShiftImpl(double optionTime, double swapLength)
Parameters
Returns
- double
The shift.
Exceptions
- NanoQLException
The structure's volatilities aren't shifted lognormal.
SmileSection(Date, Period, bool)
The smile section for an option date and a swap tenor.
public SmileSection SmileSection(Date optionDate, Period swapTenor, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- SmileSection
The smile section.
Exceptions
- NanoQLException
The swap tenor or the date is outside the structure's domain.
SmileSection(Date, double, bool)
The smile section for an option date and a swap length: the query is checked with the flag, and the section is the one for the date's time, checked again without it.
public SmileSection SmileSection(Date optionDate, double swapLength, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range, in the first check only.
Returns
- SmileSection
The smile section.
Exceptions
- NanoQLException
The swap length or the date is outside the structure's domain.
SmileSection(Period, Period, bool)
The smile section for an option tenor and a swap tenor.
public SmileSection SmileSection(Period optionTenor, Period swapTenor, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- SmileSection
The smile section.
SmileSection(Period, double, bool)
The smile section for an option tenor and a swap length: the query is checked with the flag, and the section is the one for the tenor's option date, checked again without it.
public SmileSection SmileSection(Period optionTenor, double swapLength, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range, in the first check only.
Returns
- SmileSection
The smile section.
Exceptions
- NanoQLException
The swap length or the date is outside the structure's domain.
SmileSection(double, Period, bool)
The smile section for an option time and a swap tenor: the query is checked with the flag, and the section is the one for the time and the tenor's swap length, checked again without it.
public SmileSection SmileSection(double optionTime, Period swapTenor, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapTenorPeriodThe swap tenor.
extrapolateboolWhether to extrapolate outside the structure's range, in the first check only.
Returns
- SmileSection
The smile section.
Exceptions
- NanoQLException
The swap tenor or the time is outside the structure's domain.
SmileSection(double, double, bool)
The smile section for an option time and a swap length.
public SmileSection SmileSection(double optionTime, double swapLength, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapLengthdoubleThe swap length, in years.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- SmileSection
The smile section.
Exceptions
- NanoQLException
The swap length or the time is outside the structure's domain.
SmileSectionImpl(Date, Period)
The smile section for an option date and a swap tenor, without range checks; by default the one for the date's time and the tenor's swap length.
protected virtual SmileSection SmileSectionImpl(Date optionDate, Period swapTenor)
Parameters
Returns
- SmileSection
The smile section.
SmileSectionImpl(double, double)
The smile section for an option time and a swap length, without range checks.
protected abstract SmileSection SmileSectionImpl(double optionTime, double swapLength)
Parameters
Returns
- SmileSection
The smile section.
SwapLength(Date, Date)
The swap length between two dates: the days between them in months of 365.25/12 days, rounded to whole months, in years.
public double SwapLength(Date start, Date end)
Parameters
Returns
- double
The length, in years.
Exceptions
- ArgumentException
A date is
default(Date), or the end isn't after the start.
SwapLength(Period)
The swap length of a swap tenor: its length in years, a tenor in months counting twelfths.
public double SwapLength(Period swapTenor)
Parameters
swapTenorPeriodThe swap tenor, in months or years.
Returns
- double
The length, in years.
Exceptions
- ArgumentException
The tenor isn't positive, or isn't in months or years.
Volatility(Date, Period, double, bool)
The volatility for an option date, a swap tenor and a strike.
public double Volatility(Date optionDate, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Exceptions
- NanoQLException
The swap tenor, the date or the strike is outside the structure's domain.
Volatility(Date, double, double, bool)
The volatility for an option date, a swap length and a strike.
public double Volatility(Date optionDate, double swapLength, double strike, bool extrapolate = false)
Parameters
optionDateDateThe option date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Exceptions
- NanoQLException
The swap length, the date or the strike is outside the structure's domain.
Volatility(Period, Period, double, bool)
The volatility for an option tenor, a swap tenor and a strike.
public double Volatility(Period optionTenor, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Volatility(Period, double, double, bool)
The volatility for an option tenor, a swap length and a strike.
public double Volatility(Period optionTenor, double swapLength, double strike, bool extrapolate = false)
Parameters
optionTenorPeriodThe option tenor, from the reference date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Volatility(double, Period, double, bool)
The volatility for an option time, a swap tenor and a strike.
public double Volatility(double optionTime, Period swapTenor, double strike, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapTenorPeriodThe swap tenor.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Exceptions
- NanoQLException
The swap tenor, the time or the strike is outside the structure's domain.
Volatility(double, double, double, bool)
The volatility for an option time, a swap length and a strike.
public double Volatility(double optionTime, double swapLength, double strike, bool extrapolate = false)
Parameters
optionTimedoubleThe option time, from the reference date.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
extrapolateboolWhether to extrapolate outside the structure's range.
Returns
- double
The volatility.
Exceptions
- NanoQLException
The swap length, the time or the strike is outside the structure's domain.
VolatilityImpl(Date, Period, double)
The volatility for an option date, a swap tenor and a strike, without range checks; by default the one for the date's time and the tenor's swap length.
protected virtual double VolatilityImpl(Date optionDate, Period swapTenor, double strike)
Parameters
Returns
- double
The volatility.
VolatilityImpl(double, double, double)
The volatility for an option time, a swap length and a strike, without range checks.
protected abstract double VolatilityImpl(double optionTime, double swapLength, double strike)
Parameters
optionTimedoubleThe option time.
swapLengthdoubleThe swap length, in years.
strikedoubleThe strike.
Returns
- double
The volatility.