Class SpreadFittingMethod
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The spread fitting method: a spread curve fitted on top of a discounting curve, by an underlying parametric method, so that the fitted discount is the method's times the discounting curve's.
public sealed class SpreadFittingMethod : FittedBondDiscountCurveFittingMethod
- Inheritance
-
SpreadFittingMethod
- Inherited Members
Remarks
The method takes the underlying method's constraint at zero, weights, optimization method and L2 penalties, and its own cut-off times; the underlying method's own cut-offs apply to its part. When the discounting curve has another reference date than the fitted curve, its discount is rebased to the fitted curve's reference date. A discounting curve that changes is a new curve: QuantLib's method follows its handle.
QuantLib reads the discounting curve at the fitted curve's time (nonlinearfittingmethods.cpp:414-416), which
the discounting curve counts from its own reference date on its own day counter: dated 30 days earlier, the fitted
discount misses the rebased discounting curve by up to 3.1e-3, and by up to 1.05e-2 on Act/360. Here the
discounting curve is read at the instant the fitted curve's time denotes; where the two curves share their
reference date and day counter it is QuantLib's read and bits. A documented divergence.
Constructors
SpreadFittingMethod(FittedBondDiscountCurveFittingMethod, YieldTermStructure, double, double)
Initializes a new instance of the SpreadFittingMethod class.
public SpreadFittingMethod(FittedBondDiscountCurveFittingMethod method, YieldTermStructure discountCurve, double minCutoffTime = 0, double maxCutoffTime = 1.7976931348623157E+308)
Parameters
methodFittedBondDiscountCurveFittingMethodThe underlying parametric method.
discountCurveYieldTermStructureThe discounting curve the spread is fitted on top of.
minCutoffTimedoubleThe time before which the discount extrapolates with a flat forward rate.
maxCutoffTimedoubleThe time after which the discount extrapolates with a flat forward rate.
Exceptions
- ArgumentNullException
methodordiscountCurveis null, QuantLib's "Fitting method is empty" and "Discounting curve cannot be empty".
Properties
Size
Gets the total number of coefficients to fit, or solve for.
public override int Size { get; }
Property Value
Remarks
The underlying method's.
Methods
DiscountFunction(ReadOnlySpan<double>, double)
The discount function the curve is fitted to, at given parameters.
protected override double DiscountFunction(ReadOnlySpan<double> x, double t)
Parameters
xReadOnlySpan<double>The parameters, Size of them.
tdoubleThe time.
Returns
- double
The discount factor.
Init()
Sets the fit up on the curve's copy before it runs: the yield conventions and the bonds' weights, and the checks
of the weights, the penalties and the guess. QuantLib's init(); a method that overrides it calls it.
protected override void Init()
Exceptions
- ArgumentException
The weights don't cover every bond, the penalties don't cover every parameter, or penalties are given without a guess.
- NanoQLException
The discounting curve can't give its discount at the fitted curve's reference date.