Class AbcdCalibration
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The abcd instantaneous volatility fitted to Black volatilities by their maturities: the root-mean-square error of the abcd Black volatilities, minimized over a, b, c and d through QuantLib's transformation (c, d and a + d positive), the fixed parameters at their guesses.
public sealed class AbcdCalibration
- Inheritance
-
AbcdCalibration
- Inherited Members
Remarks
Immutable: Compute() returns the fitted calibration, where QuantLib's compute() changes the
object; before it the parameters are the guesses, and the weights 1/n.
One of QuantLib's refusals is narrowed: QuantLib's transformation leaves b free, so its optimizer can step to a trial point the abcd function's validation refuses, and the fit throws. Here such a trial point's residuals are 1.0 each, a guard that keeps every fit QuantLib completes bit for bit, since none of them reaches such a point. A fit on which the guard acted is returned where it ends inside the valid region and refused with QuantLib's text, its first invalid trial point's, where it ends against the zero floor: its lowest instantaneous volatility below 1% of the smallest Black volatility given, as for data whose total variance shrinks, which no valid curve fits.
One of QuantLib's defects is fixed: its transformation gives a as a positive a + d less d, so with a fixed and d free it fixes a + d, and the fit moves a by what it moves d. Here a fixed keeps its guess, and d stays above max(0, −a), the same region; every other choice of fixed parameters is QuantLib's.
Constructors
AbcdCalibration(IEnumerable<double>, IEnumerable<double>, double, double, double, double, bool, bool, bool, bool, bool, EndCriteria?, OptimizationMethod?)
Initializes a new instance of the AbcdCalibration class, not yet fitted.
public AbcdCalibration(IEnumerable<double> t, IEnumerable<double> blackVols, double aGuess = -0.06, double bGuess = 0.17, double cGuess = 0.54, double dGuess = 0.17, bool aIsFixed = false, bool bIsFixed = false, bool cIsFixed = false, bool dIsFixed = false, bool vegaWeighted = false, EndCriteria? endCriteria = null, OptimizationMethod? method = null)
Parameters
tIEnumerable<double>The maturities.
blackVolsIEnumerable<double>The Black volatilities, one per maturity.
aGuessdoublea's guess.
bGuessdoubleb's guess.
cGuessdoublec's guess, positive.
dGuessdoubled's guess, non-negative.
aIsFixedboolWhether a is fixed at its guess.
bIsFixedboolWhether b is fixed at its guess.
cIsFixedboolWhether c is fixed at its guess.
dIsFixedboolWhether d is fixed at its guess.
vegaWeightedboolWhether the errors are weighted by the at-the-money vegas.
endCriteriaEndCriteriaThe end criteria, or null for QuantLib's
EndCriteria(10000, 1000, 1e-8, 0.3e-4, 0.3e-4).methodOptimizationMethodThe optimizer, or null for QuantLib's
LevenbergMarquardt(1e-8, 1e-8, 1e-8, false).
Exceptions
- ArgumentNullException
torblackVolsis null.- ArgumentException
The guesses fail Validate(double, double, double, double), or the sizes differ.
Properties
A
Gets a: the guess, or the fit.
public double A { get; }
Property Value
AIsFixed
Gets a value indicating whether a is fixed.
public bool AIsFixed { get; }
Property Value
B
Gets b: the guess, or the fit.
public double B { get; }
Property Value
BIsFixed
Gets a value indicating whether b is fixed.
public bool BIsFixed { get; }
Property Value
C
Gets c: the guess, or the fit.
public double C { get; }
Property Value
CIsFixed
Gets a value indicating whether c is fixed.
public bool CIsFixed { get; }
Property Value
D
Gets d: the guess, or the fit.
public double D { get; }
Property Value
DIsFixed
Gets a value indicating whether d is fixed.
public bool DIsFixed { get; }
Property Value
EndCriteria
public EndCriteriaType EndCriteria { get; }
Property Value
Transformation
Gets the parameters' transformation the fit used, or null before a fit, QuantLib's empty pointer.
public ParametersTransformation? Transformation { get; }
Property Value
Methods
Compute()
The fit, from the guesses: QuantLib's compute(), the receiver unchanged.
public AbcdCalibration Compute()
Returns
- AbcdCalibration
The fitted calibration.
Exceptions
- NanoQLException
The optimizer fails, or the fit ends against the zero floor after reaching a trial point QuantLib's validation refuses, with that refusal's text.
Error()
The weighted root-mean-square error, √(n·Σwᵢeᵢ²/(n − 1)).
public double Error()
Returns
- double
The error.
Errors()
The weighted errors, eᵢ·√wᵢ.
public Vector Errors()
Returns
- Vector
The errors.
K(IEnumerable<double>, IEnumerable<double>)
The adjustment factors that match the Black volatilities: each volatility over the fitted one.
public ImmutableArray<double> K(IEnumerable<double> t, IEnumerable<double> blackVols)
Parameters
tIEnumerable<double>The maturities.
blackVolsIEnumerable<double>The Black volatilities, one per maturity.
Returns
- ImmutableArray<double>
The factors.
Exceptions
- ArgumentNullException
An argument is null.
- ArgumentException
The sizes differ.
MaxError()
The largest absolute error.
public double MaxError()
Returns
- double
The error.
Value(double)
The fitted abcd Black volatility at a maturity.
public double Value(double x)
Parameters
xdoubleThe maturity.
Returns
- double
The volatility.
Exceptions
- ArgumentException
The parameters fail Validate(double, double, double, double), or the maturity is negative.