Table of Contents

Class Gaussian1dModel

Namespace
NanoQL.Models
Assembly
NanoQL.dll

The interface of one-factor interest-rate models whose state is Gaussian: a derived model implements the numeraire and the zero bond for a value of the state variable y, the standardized (zero mean, unit variance) form of the model's state x.

public abstract class Gaussian1dModel : ITermStructureConsistentModel
Inheritance
Gaussian1dModel
Implements
Derived
Inherited Members

Remarks

The variance of the state process given x(t) = x must not depend on x.

Immutable, unsealed: GSR and the Markov-functional model derive from it, as a model of one's own may (an extension point). QuantLib's model is a LazyObject that copies the evaluation date and the historic-fixings flag at its calculation and keeps every swap it builds; here the members that read the date or the flag take the EvaluationContext (ForwardRate, SwapRate, and SwapAnnuity, whose swap is built under it), and what one call computes twice it computes once, through a memo that lives for the call: each engine call builds one and passes it through the internal members, and each public member builds its own, so nothing outlives the call (the playbook's Gaussian1d row).

A derived model of another assembly implements NumeraireImpl(double, double, YieldTermStructure?) and ZerobondImpl(double, double, double, YieldTermStructure?), QuantLib's hooks, and sets its state process with SetStateProcess(StochasticProcess1D) while its constructor runs.

A curve given on another clock than the model's own (another day counter or reference date) is read at the instant QuantLib's argument denotes: by the date QuantLib derives a time from, where it has one, and the numeraire time, which has no date, at the instant it denotes on the model's clock; where the curves share a clock, QuantLib's reads and bits stand. QuantLib reads such a curve at the model curve's times: a documented divergence (Divergences/Gaussian1dMismatchedTimesTests.cs).

Constructors

Gaussian1dModel(YieldTermStructure)

Initializes a new instance of the Gaussian1dModel class.

protected Gaussian1dModel(YieldTermStructure yieldTermStructure)

Parameters

yieldTermStructure YieldTermStructure

The model's curve.

Exceptions

ArgumentNullException

yieldTermStructure is null.

Properties

TermStructure

Gets the curve the model fits.

public YieldTermStructure TermStructure { get; }

Property Value

YieldTermStructure

Methods

CompoundedRate(OvernightIndexedCoupon, Date?, double, YieldTermStructure?)

The compounded rate of an overnight-indexed coupon, at a date and a value of the standardized state: the zero bonds' ratio over its rate period, the part before the date read from the projection curve.

public double CompoundedRate(OvernightIndexedCoupon coupon, Date? referenceDate = null, double y = 0, YieldTermStructure? yts = null)

Parameters

coupon OvernightIndexedCoupon

The coupon.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

yts YieldTermStructure

The projection curve; null, QuantLib's empty handle, for the model's.

Returns

double

The compounded rate over the coupon's rate accrual.

Remarks

Under an observation shift with fixing days, the rate period runs over the coupon's value dates; otherwise over its interest dates.

Exceptions

ArgumentNullException

coupon is null.

ForwardRate(Date, EvaluationContext, Date?, double, IborIndex?)

The forward rate of an Ibor index at a fixing date, at a date and a value of the standardized state.

public double ForwardRate(Date fixing, EvaluationContext context, Date? referenceDate = null, double y = 0, IborIndex? iborIdx = null)

Parameters

fixing Date

The fixing date.

context EvaluationContext

The evaluation context: a fixing on or before its date is read from its fixings.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

iborIdx IborIndex

The index; required, where QuantLib's default is an empty pointer it refuses.

Returns

double

The forward rate.

Remarks

A fixing before the evaluation date, or on it when the context enforces today's historic fixings, is the index's fixing. Otherwise the period ends at the index's maturity date for its value date, as QuantLib's master computes it after the pin (#2848), where QuantLib 1.44 advances the value date by the tenor itself, which differs for an index that overrides its maturity date (Divergences/Gaussian1dForwardRateEndDateTests.cs).

Exceptions

ArgumentNullException

context or iborIdx is null.

GaussianPolynomialIntegral(double, double, double, double, double, double, double)

Computes the integral (2π)^(−1/2)·∫ₐᵇ p(x)·exp(−x²/2) dx with p(x) = ax⁴ + bx³ + cx² + dx + e, from x0 to x1.

public static double GaussianPolynomialIntegral(double a, double b, double c, double d, double e, double x0, double x1)

Parameters

a double

The coefficient of x⁴.

b double

The coefficient of x³.

c double

The coefficient of x².

d double

The coefficient of x.

e double

The constant.

x0 double

The lower end.

x1 double

The upper end.

Returns

double

The integral.

Remarks

QuantLib's std::erf is QuantLib's own ErrorFunction here, which .NET lacks; the C runtime's differs from it by a few ulp on some arguments, so an output that reaches it can differ from QuantLib's in its last places, within the tolerance.

GaussianShiftedPolynomialIntegral(double, double, double, double, double, double, double, double)

Computes the integral (2π)^(−1/2)·∫ₐᵇ p(x)·exp(−x²/2) dx with p(x) = a(x − h)⁴ + b(x − h)³ + c(x − h)² + d(x − h) + e, from x0 to x1.

public static double GaussianShiftedPolynomialIntegral(double a, double b, double c, double d, double e, double h, double x0, double x1)

Parameters

a double

The coefficient of (x − h)⁴.

b double

The coefficient of (x − h)³.

c double

The coefficient of (x − h)².

d double

The coefficient of (x − h).

e double

The constant.

h double

The shift.

x0 double

The lower end.

x1 double

The upper end.

Returns

double

The integral.

Numeraire(Date, double, YieldTermStructure?)

The numeraire at a date, for a value of the standardized state.

public double Numeraire(Date referenceDate, double y = 0, YieldTermStructure? yts = null)

Parameters

referenceDate Date

The date.

y double

The standardized state; 0 by default.

yts YieldTermStructure

The curve to read instead of the model's; null, QuantLib's empty handle, by default.

Returns

double

The numeraire.

Numeraire(double, double, YieldTermStructure?)

The numeraire at a time, for a value of the standardized state.

public double Numeraire(double t, double y = 0, YieldTermStructure? yts = null)

Parameters

t double

The time.

y double

The standardized state; 0 by default.

yts YieldTermStructure

The curve to read instead of the model's; null, QuantLib's empty handle, by default.

Returns

double

The numeraire.

NumeraireImpl(double, double, YieldTermStructure?)

The numeraire at a time, for a value of the standardized state: the hook a derived model implements.

protected abstract double NumeraireImpl(double t, double y, YieldTermStructure? yts)

Parameters

t double

The time.

y double

The standardized state.

yts YieldTermStructure

The curve to read instead of the model's, or null.

Returns

double

The numeraire.

SetStateProcess(StochasticProcess1D)

Sets the model's state process, while a derived constructor runs: QuantLib's stateProcess_.

protected void SetStateProcess(StochasticProcess1D process)

Parameters

process StochasticProcess1D

The process.

Exceptions

ArgumentNullException

process is null.

StateProcess()

The model's state process.

public StochasticProcess1D StateProcess()

Returns

StochasticProcess1D

The process.

Exceptions

NanoQLException

The derived model set no state process.

SwapAnnuity(Date, Period, EvaluationContext, Date?, double, SwapIndex?)

The annuity of a swap index's swap at a fixing date and tenor, at a date and a value of the standardized state.

public double SwapAnnuity(Date fixing, Period tenor, EvaluationContext context, Date? referenceDate = null, double y = 0, SwapIndex? swapIdx = null)

Parameters

fixing Date

The fixing date.

tenor Period

The swap's tenor.

context EvaluationContext

The evaluation context the swap is built under.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

swapIdx SwapIndex

The index; required, where QuantLib's default is an empty pointer it refuses.

Returns

double

The annuity.

Remarks

QuantLib's reads neither the evaluation date nor the flag; its swap is built under the context, which nanoql's swap index needs for the underlying swap's coupons.

Exceptions

ArgumentNullException

context or swapIdx is null.

SwapRate(Date, Period, EvaluationContext, Date?, double, SwapIndex?)

The swap rate of a swap index at a fixing date and tenor, at a date and a value of the standardized state.

public double SwapRate(Date fixing, Period tenor, EvaluationContext context, Date? referenceDate = null, double y = 0, SwapIndex? swapIdx = null)

Parameters

fixing Date

The fixing date.

tenor Period

The swap's tenor.

context EvaluationContext

The evaluation context: a fixing on or before its date is read from its fixings, and the swap is built under it.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

swapIdx SwapIndex

The index; required, where QuantLib's default is an empty pointer it refuses.

Returns

double

The swap rate.

Exceptions

ArgumentNullException

context or swapIdx is null.

YGrid(double, int, double, double, double)

A grid of the standardized state at a time T, given its value at t, covering stdDevs standard deviations in 2·gridPoints + 1 points.

public Vector YGrid(double stdDevs, int gridPoints, double T = 1, double t = 0, double y = 0)

Parameters

stdDevs double

The grid's width, in standard deviations.

gridPoints int

The points on each side.

T double

The time of the grid; 1 by default.

t double

The time of the given state; 0 by default.

y double

The standardized state at t; 0 by default.

Returns

Vector

A new vector holding the grid.

Exceptions

ArgumentOutOfRangeException

gridPoints is negative, where QuantLib's array of 2·n + 1 points can't be allocated.

NanoQLException

The model has no state process.

Zerobond(Date, Date?, double, YieldTermStructure?)

The zero bond maturing at a date, at another date, for a value of the standardized state.

public double Zerobond(Date maturity, Date? referenceDate = null, double y = 0, YieldTermStructure? yts = null)

Parameters

maturity Date

The maturity.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

yts YieldTermStructure

The curve to read instead of the model's; null, QuantLib's empty handle, by default.

Returns

double

The zero bond.

Zerobond(double, double, double, YieldTermStructure?)

The zero bond maturing at a time, at another time, for a value of the standardized state.

public double Zerobond(double T, double t = 0, double y = 0, YieldTermStructure? yts = null)

Parameters

T double

The maturity.

t double

The time; 0 by default.

y double

The standardized state at t; 0 by default.

yts YieldTermStructure

The curve to read instead of the model's; null, QuantLib's empty handle, by default.

Returns

double

The zero bond.

ZerobondImpl(double, double, double, YieldTermStructure?)

The zero bond maturing at a time, at another time, for a value of the standardized state: the hook a derived model implements.

protected abstract double ZerobondImpl(double T, double t, double y, YieldTermStructure? yts)

Parameters

T double

The maturity.

t double

The time.

y double

The standardized state at t.

yts YieldTermStructure

The curve to read instead of the model's, or null.

Returns

double

The zero bond.

ZerobondOption(OptionType, Date, Date, Date, double, Date?, double, YieldTermStructure?, double, int, bool, bool)

The price of an option on a zero bond, at a date and a value of the standardized state, by the integration of the payoff's cubic spline over a grid of the state at the expiry.

public double ZerobondOption(OptionType type, Date expiry, Date valueDate, Date maturity, double strike, Date? referenceDate = null, double y = 0, YieldTermStructure? yts = null, double yStdDevs = 7, int yGridPoints = 64, bool extrapolatePayoff = true, bool flatPayoffExtrapolation = false)

Parameters

type OptionType

Call or put.

expiry Date

The expiry.

valueDate Date

The date the strike is paid at.

maturity Date

The bond's maturity.

strike double

The strike, a price of the bond at valueDate.

referenceDate Date?

The date; null, QuantLib's empty date, for the model curve's reference date.

y double

The standardized state at referenceDate; 0 by default.

yts YieldTermStructure

The curve to read instead of the model's; null, QuantLib's empty handle, by default.

yStdDevs double

The grid's width, in standard deviations; 7 by default.

yGridPoints int

The grid's points on each side; 64 by default.

extrapolatePayoff bool

Whether to integrate the payoff past the grid; true by default.

flatPayoffExtrapolation bool

Whether past the grid the payoff is flat, at its boundary node's value; false by default.

Returns

double

The option's price.

Remarks

With flatPayoffExtrapolation, the right tail integrates the payoff's last node, where QuantLib's integrates its second-last: a documented divergence (Divergences/FlatPayoffExtrapolationTests.cs). The numeraire at the expiry reads a curve on another clock at the expiry's date.

Exceptions

ArgumentOutOfRangeException

type isn't a member of its type, or yGridPoints is negative.