Struct SwaptionVolCubeZabrModel<TEvaluation>
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The ZABR model of a swaption volatility cube: QuantLib's SwaptionVolCubeZabrModel<Kernel> with its
XabrModelTraits specialization, its smiles fitted by ZabrInterpolation<TEvaluation> and its
sections ZabrSmileSection<TEvaluation>s, five parameters α, β, ν, ρ and γ.
public readonly struct SwaptionVolCubeZabrModel<TEvaluation> : IXabrCubeModel where TEvaluation : struct, IZabrEvaluation
Type Parameters
TEvaluationThe kernel: ZabrShortMaturityLognormal, QuantLib's default, or ZabrShortMaturityNormal.
- Implements
- Inherited Members
Remarks
A stateless trait: its members are static, and every instance, its zero value included, is the same model. Fewer than five guesses or fixed flags are refused, as QuantLib's traits refuse them; more are ignored. ZABR has no shifted form: a section on a shifted at-the-money structure is refused when it is built, at the cube's construction for an at-the-money-calibrated cube and at its first query otherwise, as QuantLib's is.
Explicit Interface Implementations
CreateInterpolation(ReadOnlySpan<double>, ReadOnlySpan<double>, double, double, ReadOnlySpan<double>, ReadOnlySpan<bool>, bool, EndCriteria?, OptimizationMethod?, double, bool, int, double, VolatilityType)
A ZABR smile fitted to discrete volatilities, from the five guesses and fixed flags.
static IXabrInterpolation CreateInterpolation(ReadOnlySpan<double> strikes, ReadOnlySpan<double> volatilities, double t, double forward, ReadOnlySpan<double> parameters, ReadOnlySpan<bool> paramIsFixed, bool vegaWeighted, EndCriteria? endCriteria, OptimizationMethod? optMethod, double errorAccept, bool useMaxError, int maxGuesses, double shift, VolatilityType volatilityType)
Parameters
strikesReadOnlySpan<double>The strikes, sorted.
volatilitiesReadOnlySpan<double>The volatilities, one per strike.
tdoubleThe time to expiry.
forwarddoubleThe forward.
parametersReadOnlySpan<double>The guesses of α, β, ν, ρ and γ, at least five.
paramIsFixedReadOnlySpan<bool>Whether each of α, β, ν, ρ and γ is fixed at its guess, at least five flags.
vegaWeightedboolWhether the errors are weighted by the strikes' Black vegas.
endCriteriaEndCriteriaThe end criteria, or null for the fit's default.
optMethodOptimizationMethodThe optimizer, or null for the fit's default.
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.
shiftdoubleIgnored, as QuantLib ignores it.
volatilityTypeVolatilityTypeIgnored, as QuantLib ignores it.
Returns
- IXabrInterpolation
The fitted ZabrInterpolation<TEvaluation>.
Exceptions
- ArgumentException
There are fewer than five guesses or flags, or the fit refuses its arguments.
- ArgumentOutOfRangeException
maxGuessesis negative.- NanoQLException
The optimizer or the model's integration fails.
CreateSmileSection(double, double, ReadOnlySpan<double>, double, VolatilityType)
The ZABR smile section at given parameters, on an unshifted structure.
static SmileSection CreateSmileSection(double optionTime, double forward, ReadOnlySpan<double> parameters, double shift, VolatilityType volatilityType)
Parameters
optionTimedoubleThe exercise time.
forwarddoubleThe forward.
parametersReadOnlySpan<double>α, β, ν, ρ and γ, in that order.
shiftdoubleThe at-the-money structure's shift, which must be 0.
volatilityTypeVolatilityTypeIgnored, as QuantLib ignores it.
Returns
Exceptions
- ArgumentException
shiftisn't close to 0.- ArgumentException
The section refuses its arguments.
ExtractGamma(IXabrInterpolation)
The fitted γ.
static double ExtractGamma(IXabrInterpolation interpolation)
Parameters
interpolationIXabrInterpolationThe fitted interpolation, one CreateInterpolation(ReadOnlySpan<double>, ReadOnlySpan<double>, double, double, ReadOnlySpan<double>, ReadOnlySpan<bool>, bool, EndCriteria?, OptimizationMethod?, double, bool, int, double, VolatilityType) returned.
Returns
- double
γ.
Exceptions
- ArgumentNullException
interpolationis null.- InvalidCastException
interpolationisn't this model's.
NParams
Gets the model's parameter count: 5.
static int NParams { get; }