Table of Contents

Class SabrFunctions

Namespace
NanoQL.TermStructures
Assembly
NanoQL.dll

The SABR functions: Hagan's lognormal and normal expansions of the SABR volatility, Le Floc'h and Kennedy's expansion, the parameters' validation and Le Floc'h and Kennedy's initial guess for a calibration.

public static class SabrFunctions
Inheritance
SabrFunctions
Inherited Members

Remarks

The expansions keep QuantLib's order of operations, so their values are QuantLib's bit for bit wherever the C runtime's functions agree with .NET's. A VolatilityType outside its members is refused on entry, where QuantLib takes any value other than Normal as lognormal.

Methods

SabrFlochKennedyVolatility(double, double, double, double, double, double, double)

Le Floc'h and Kennedy's expansion of the lognormal SABR volatility, with no check of its arguments.

public static double SabrFlochKennedyVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho)

Parameters

strike double

The strike.

forward double

The forward.

expiryTime double

The time to expiry.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

Returns

double

The volatility; a second-order Taylor expansion where the strike is within 0.25% of the forward.

SabrGuess(double, double, double, double, double, double, double, double, double, double, VolatilityType)

Le Floc'h and Kennedy's initial guess for a SABR calibration (Le Floc'h and Kennedy, "Explicit SABR Calibration through Simple Expansions"): the parameters matching the at-the-money volatility, skew and curvature that three volatilities around the forward give.

public static ImmutableArray<double> SabrGuess(double k_m, double vol_m, double k_0, double vol_0, double k_p, double vol_p, double forward, double expiryTime, double beta, double shift, VolatilityType volatilityType)

Parameters

k_m double

The strike before the one closest to the forward.

vol_m double

Its volatility.

k_0 double

The strike closest to the forward.

vol_0 double

Its volatility.

k_p double

The strike after the one closest to the forward.

vol_p double

Its volatility.

forward double

The forward.

expiryTime double

The time to expiry.

beta double

SABR's β, which the guess returns as given.

shift double

The shift.

volatilityType VolatilityType

Normal, or shifted lognormal.

Returns

ImmutableArray<double>

The guesses α, β, ν and ρ, in that order.

Remarks

A non-finite argument is refused, where QuantLib computes on it: a NaN smile gives ρ the sign of a NaN, which depends on which NaN an operation keeps, so QuantLib's value there isn't a number a caller can use. α is the smallest positive root of the guess's cubic, or its first estimate where the cubic has none, as QuantLib's.

Exceptions

ArgumentOutOfRangeException

volatilityType isn't a member of its type.

ArgumentException

An argument is NaN or infinite.

SabrVolatility(double, double, double, double, double, double, double, VolatilityType)

The SABR volatility of the given type, its arguments checked.

public static double SabrVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho, VolatilityType volatilityType = VolatilityType.ShiftedLognormal)

Parameters

strike double

The strike, positive.

forward double

The forward, positive.

expiryTime double

The time to expiry, non-negative.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

volatilityType VolatilityType

Normal, or shifted lognormal.

Returns

double

The volatility.

Exceptions

ArgumentOutOfRangeException

volatilityType isn't a member of its type.

ArgumentException

An argument is out of its range.

ShiftedSabrVolatility(double, double, double, double, double, double, double, double, VolatilityType)

The shifted SABR volatility of the given type, its arguments checked.

public static double ShiftedSabrVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho, double shift, VolatilityType volatilityType = VolatilityType.ShiftedLognormal)

Parameters

strike double

The strike; strike + shift positive.

forward double

The forward; forward + shift positive.

expiryTime double

The time to expiry, non-negative.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

shift double

The shift added to the strike and the forward.

volatilityType VolatilityType

Normal, or shifted lognormal.

Returns

double

The volatility.

Exceptions

ArgumentOutOfRangeException

volatilityType isn't a member of its type.

ArgumentException

An argument is out of its range.

UnsafeSabrLogNormalVolatility(double, double, double, double, double, double, double)

Hagan's lognormal SABR volatility, with no check of its arguments.

public static double UnsafeSabrLogNormalVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho)

Parameters

strike double

The strike.

forward double

The forward.

expiryTime double

The time to expiry.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

Returns

double

The volatility.

UnsafeSabrNormalVolatility(double, double, double, double, double, double, double)

The normal SABR volatility, with no check of its arguments.

public static double UnsafeSabrNormalVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho)

Parameters

strike double

The strike.

forward double

The forward.

expiryTime double

The time to expiry.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

Returns

double

The volatility.

Remarks

As QuantLib's: Deloitte's "SABR sensitivities" note.

UnsafeSabrVolatility(double, double, double, double, double, double, double, VolatilityType)

The SABR volatility of the given type, with no check of its arguments.

public static double UnsafeSabrVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho, VolatilityType volatilityType = VolatilityType.ShiftedLognormal)

Parameters

strike double

The strike.

forward double

The forward.

expiryTime double

The time to expiry.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

volatilityType VolatilityType

Normal, or shifted lognormal.

Returns

double

The volatility.

Exceptions

ArgumentOutOfRangeException

volatilityType isn't a member of its type.

UnsafeShiftedSabrVolatility(double, double, double, double, double, double, double, double, VolatilityType)

The shifted SABR volatility of the given type, with no check of its arguments.

public static double UnsafeShiftedSabrVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho, double shift, VolatilityType volatilityType = VolatilityType.ShiftedLognormal)

Parameters

strike double

The strike.

forward double

The forward.

expiryTime double

The time to expiry.

alpha double

SABR's α.

beta double

SABR's β.

nu double

SABR's ν.

rho double

SABR's ρ.

shift double

The shift added to the strike and the forward.

volatilityType VolatilityType

Normal, or shifted lognormal.

Returns

double

The volatility.

Exceptions

ArgumentOutOfRangeException

volatilityType isn't a member of its type.

ValidateSabrParameters(double, double, double, double)

Checks SABR's parameters.

public static void ValidateSabrParameters(double alpha, double beta, double nu, double rho)

Parameters

alpha double

SABR's α, positive.

beta double

SABR's β, in [0, 1].

nu double

SABR's ν, non-negative.

rho double

SABR's ρ, in (−1, 1).

Exceptions

ArgumentException

A parameter is out of its range, or NaN.