Table of Contents

Class ConvexMonotoneInterpolation

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

The convex-monotone interpolation of instantaneous forward rates from their section averages: QuantLib's ConvexMonotoneInterpolation, Hagan and West's method ("Interpolation Methods for Curve Construction", Applied Mathematical Finance 13(2), 2006) with QuantLib's enhancements.

public sealed class ConvexMonotoneInterpolation : Interpolation
Inheritance
ConvexMonotoneInterpolation
Inherited Members
Extension Methods

Remarks

The y values are the sections' averages, the first ignored: the section from xi−1 to xi averages yi, and the primitive at xi is the sum of the sections' averages times their lengths. A monotonicity of 1 and a quadraticity of 0 is Hagan and West's basic method; a monotonicity below 1 or a quadraticity above 0 gives smoother curves. Forcing positivity keeps the forwards non-negative where the averages are. Past the last node the interpolation is flat at its last value; with a flat final period, the last section is flat at its average, as the local bootstrap builds the curve a section at a time.

Immutable: the section helpers are computed at construction. The derivatives aren't implemented, as in QuantLib.

Three fixes of QuantLib's sections (documented divergences in Divergences/ConvexMonotoneTests.cs): a section's quadratic is split to stay non-negative only where it dips below 0 inside the section, and a discriminant that rounds a hair below 0 is taken as 0, so every section keeps its average and the forwards their continuity; and positivity isn't forced on a section whose average is negative, nor is an end forward beside one floored at 0, so a negative-rate curve keeps its averages. Everywhere else QuantLib's values, bit for bit.

Constructors

ConvexMonotoneInterpolation(ReadOnlySpan<double>, ReadOnlySpan<double>, double, double, bool, bool)

Initializes a new instance of the ConvexMonotoneInterpolation class.

public ConvexMonotoneInterpolation(ReadOnlySpan<double> x, ReadOnlySpan<double> y, double quadraticity, double monotonicity, bool forcePositive, bool flatFinalPeriod = false)

Parameters

x ReadOnlySpan<double>

The x values, which must be sorted.

y ReadOnlySpan<double>

The sections' averages, one per x value, the first ignored.

quadraticity double

The weight of the quadratic form, in [0, 1].

monotonicity double

The monotonicity, in [0, 1].

forcePositive bool

Whether to keep the forwards non-negative.

flatFinalPeriod bool

Whether the last section is flat at its average.

Exceptions

ArgumentException

The sizes differ; there are fewer than two points; or the monotonicity or the quadraticity lies outside [0, 1].

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: the derivative isn't implemented.

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.

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: the second derivative isn't implemented.

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.