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
xReadOnlySpan<double>The strikes, sorted.
yReadOnlySpan<double>The lognormal volatilities, one per strike.
tdoubleThe time to expiry, positive.
forwarddoubleThe forward.
adouble?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.
bdouble?b's guess, or null for 2/(1+|ρ|).
sigmadouble?σ's guess, or null for 0.1.
rhodouble?ρ's guess, or null for −0.4.
mdouble?m's guess, or null for 0.
aIsFixedboolWhether a is fixed at its guess; a parameter not given is free.
bIsFixedboolWhether b is fixed at its guess.
sigmaIsFixedboolWhether σ is fixed at its guess.
rhoIsFixedboolWhether ρ is fixed at its guess.
mIsFixedboolWhether m is fixed at its guess.
vegaWeightedboolWhether the errors are weighted by the strikes' Black vegas.
endCriteriaEndCriteriaThe end criteria, or null for QuantLib's
EndCriteria(60000, 100, 1e-8, 1e-8, 1e-8).optMethodOptimizationMethodThe optimizer, or null for QuantLib's
LevenbergMarquardt(1e-8, 1e-8, 1e-8).errorAcceptdoubleThe error at or below which a fit is accepted and the restarts stop.
useMaxErrorboolWhether a fit is scored by its maximum error, not its root-mean-square error.
maxGuessesintThe most minimizations; 0 runs one, as 1 does.
Exceptions
- ArgumentOutOfRangeException
maxGuessesis 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
B
Gets the fitted b.
public double B { get; }
Property Value
EndCriteria
Gets the end criteria of the minimization the fit kept; None where it ran none.
public EndCriteriaType EndCriteria { get; }
Property Value
Expiry
Gets the time to expiry.
public double Expiry { get; }
Property Value
Forward
Gets the forward.
public double Forward { get; }
Property Value
M
Gets the fitted m.
public double M { get; }
Property Value
MaxError
Gets the largest error of the fit, unweighted.
public double MaxError { get; }
Property Value
Rho
Gets the fitted ρ.
public double Rho { get; }
Property Value
RmsError
Gets the root-mean-square error of the fit, weighted by InterpolationWeights().
public double RmsError { get; }
Property Value
Sigma
Gets the fitted σ.
public double Sigma { get; }
Property Value
Methods
DerivativeCore(double)
The first derivative at a point, after the range check.
protected override double DerivativeCore(double x)
Parameters
xdoubleThe 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
xdoubleThe 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
xdoubleThe 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
xdoubleThe point.
Returns
- double
The value.