Table of Contents

Class SviInterpolation

Namespace
NanoQL.Experimental
Assembly
NanoQL.dll

The SVI smile fitted to discrete volatilities: SVI's five parameters a, b, σ, ρ and m fitted to the lognormal volatilities at the strikes, interpolated by the volatility of the SVI smile section at the fitted parameters.

[Experimental("NQL0001")]
public sealed class SviInterpolation : Interpolation, IXabrInterpolation
Inheritance
SviInterpolation
Implements
Inherited Members
Extension Methods

Remarks

The fit is SABRInterpolation's, XABR's, over SVI's parameters: it runs when the interpolation is built, from the guesses and then, while the error stays above errorAccept, from up to maxGuesses − 1 Halton guesses seeded with QuantLib's 42, keeping the best; its values are QuantLib's at every step but where NanoQL.Experimental.SviSpecs' transforms depart from QuantLib's (a guess at an edge of the transforms' ranges, and a trial the parameters' check would refuse with a or b fixed).

As an IXabrInterpolation, its first four parameters, a, b, σ and ρ, are the slots QuantLib's coefficient holder keeps in α's, β's, ν's and ρ's places.

Immutable and thread-safe once built: it copies its inputs, and nothing writes the fit after it.

Constructors

SviInterpolation(ReadOnlySpan<double>, ReadOnlySpan<double>, double, double, double?, double?, double?, double?, double?, bool, bool, bool, bool, bool, bool, EndCriteria?, OptimizationMethod?, double, bool, int)

Initializes a new instance of the SviInterpolation class, and fits it.

public SviInterpolation(ReadOnlySpan<double> x, ReadOnlySpan<double> y, double t, double forward, double? a, double? b, double? sigma, double? rho, double? m, bool aIsFixed, bool bIsFixed, bool sigmaIsFixed, bool rhoIsFixed, bool mIsFixed, bool vegaWeighted = true, EndCriteria? endCriteria = null, OptimizationMethod? optMethod = null, double errorAccept = 0.002, bool useMaxError = false, int maxGuesses = 50)

Parameters

x ReadOnlySpan<double>

The strikes, sorted.

y ReadOnlySpan<double>

The lognormal volatilities, one per strike.

t double

The time to expiry, positive.

forward double

The forward.

a double?

a's guess, or null for the default, which keeps the total variance at the forward at 0.2²·t where the parameters' check allows it.

b double?

b's guess, or null for 2/(1+|ρ|).

sigma double?

σ's guess, or null for 0.1.

rho double?

ρ's guess, or null for −0.4.

m double?

m's guess, or null for 0.

aIsFixed bool

Whether a is fixed at its guess; a parameter not given is free.

bIsFixed bool

Whether b is fixed at its guess.

sigmaIsFixed bool

Whether σ is fixed at its guess.

rhoIsFixed bool

Whether ρ is fixed at its guess.

mIsFixed bool

Whether m is fixed at its guess.

vegaWeighted bool

Whether the errors are weighted by the strikes' Black vegas.

endCriteria EndCriteria

The end criteria, or null for QuantLib's EndCriteria(60000, 100, 1e-8, 1e-8, 1e-8).

optMethod OptimizationMethod

The optimizer, or null for QuantLib's LevenbergMarquardt(1e-8, 1e-8, 1e-8).

errorAccept double

The error at or below which a fit is accepted and the restarts stop.

useMaxError bool

Whether a fit is scored by its maximum error, not its root-mean-square error.

maxGuesses int

The most minimizations; 0 runs one, as 1 does.

Exceptions

ArgumentOutOfRangeException

maxGuesses is negative.

ArgumentException

The sizes differ, there is no strike, the time isn't positive, the guesses fail CheckSviParameters(double, double, double, double, double, double), the volatilities are all zero with vega weights, or the optimizer refuses the problem.

NanoQLException

The optimizer fails.

Properties

A

Gets the fitted a.

public double A { get; }

Property Value

double

B

Gets the fitted b.

public double B { get; }

Property Value

double

EndCriteria

Gets the end criteria of the minimization the fit kept; None where it ran none.

public EndCriteriaType EndCriteria { get; }

Property Value

EndCriteriaType

Expiry

Gets the time to expiry.

public double Expiry { get; }

Property Value

double

Forward

Gets the forward.

public double Forward { get; }

Property Value

double

M

Gets the fitted m.

public double M { get; }

Property Value

double

MaxError

Gets the largest error of the fit, unweighted.

public double MaxError { get; }

Property Value

double

Rho

Gets the fitted ρ.

public double Rho { get; }

Property Value

double

RmsError

Gets the root-mean-square error of the fit, weighted by InterpolationWeights().

public double RmsError { get; }

Property Value

double

Sigma

Gets the fitted σ.

public double Sigma { get; }

Property Value

double

Methods

DerivativeCore(double)

The first derivative at a point, after the range check.

protected override double DerivativeCore(double x)

Parameters

x double

The point.

Returns

double

The derivative.

Exceptions

NanoQLException

Always: an XABR interpolation has no derivative.

InterpolationWeights()

The strikes' weights in the fit's errors, normalized.

public ImmutableArray<double> InterpolationWeights()

Returns

ImmutableArray<double>

The weights, one per strike.

PrimitiveCore(double)

The primitive at a point, after the range check.

protected override double PrimitiveCore(double x)

Parameters

x double

The point.

Returns

double

The primitive.

Exceptions

NanoQLException

Always: an XABR interpolation has no primitive.

SecondDerivativeCore(double)

The second derivative at a point, after the range check.

protected override double SecondDerivativeCore(double x)

Parameters

x double

The point.

Returns

double

The second derivative.

Exceptions

NanoQLException

Always: an XABR interpolation has no second derivative.

ValueCore(double)

The interpolated value at a point, after the range check.

protected override double ValueCore(double x)

Parameters

x double

The point.

Returns

double

The value.