Class Gaussian1dModel
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
yieldTermStructureYieldTermStructureThe model's curve.
Exceptions
- ArgumentNullException
yieldTermStructureis null.
Properties
TermStructure
Gets the curve the model fits.
public YieldTermStructure TermStructure { get; }
Property Value
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
couponOvernightIndexedCouponThe coupon.
referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.ytsYieldTermStructureThe 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
couponis 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
fixingDateThe fixing date.
contextEvaluationContextThe evaluation context: a fixing on or before its date is read from its fixings.
referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.iborIdxIborIndexThe 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
contextoriborIdxis 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
adoubleThe coefficient of x⁴.
bdoubleThe coefficient of x³.
cdoubleThe coefficient of x².
ddoubleThe coefficient of x.
edoubleThe constant.
x0doubleThe lower end.
x1doubleThe 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
adoubleThe coefficient of (x − h)⁴.
bdoubleThe coefficient of (x − h)³.
cdoubleThe coefficient of (x − h)².
ddoubleThe coefficient of (x − h).
edoubleThe constant.
hdoubleThe shift.
x0doubleThe lower end.
x1doubleThe 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
referenceDateDateThe date.
ydoubleThe standardized state; 0 by default.
ytsYieldTermStructureThe 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
tdoubleThe time.
ydoubleThe standardized state; 0 by default.
ytsYieldTermStructureThe 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
tdoubleThe time.
ydoubleThe standardized state.
ytsYieldTermStructureThe 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
processStochasticProcess1DThe process.
Exceptions
- ArgumentNullException
processis 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
fixingDateThe fixing date.
tenorPeriodThe swap's tenor.
contextEvaluationContextThe evaluation context the swap is built under.
referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.swapIdxSwapIndexThe 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
contextorswapIdxis 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
fixingDateThe fixing date.
tenorPeriodThe swap's tenor.
contextEvaluationContextThe evaluation context: a fixing on or before its date is read from its fixings, and the swap is built under it.
referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.swapIdxSwapIndexThe index; required, where QuantLib's default is an empty pointer it refuses.
Returns
- double
The swap rate.
Exceptions
- ArgumentNullException
contextorswapIdxis 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
stdDevsdoubleThe grid's width, in standard deviations.
gridPointsintThe points on each side.
TdoubleThe time of the grid; 1 by default.
tdoubleThe time of the given state; 0 by default.
ydoubleThe standardized state at
t; 0 by default.
Returns
- Vector
A new vector holding the grid.
Exceptions
- ArgumentOutOfRangeException
gridPointsis 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
maturityDateThe maturity.
referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.ytsYieldTermStructureThe 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
TdoubleThe maturity.
tdoubleThe time; 0 by default.
ydoubleThe standardized state at
t; 0 by default.ytsYieldTermStructureThe 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
TdoubleThe maturity.
tdoubleThe time.
ydoubleThe standardized state at
t.ytsYieldTermStructureThe 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
typeOptionTypeCall or put.
expiryDateThe expiry.
valueDateDateThe date the strike is paid at.
maturityDateThe bond's maturity.
strikedoubleThe strike, a price of the bond at
valueDate.referenceDateDate?The date; null, QuantLib's empty date, for the model curve's reference date.
ydoubleThe standardized state at
referenceDate; 0 by default.ytsYieldTermStructureThe curve to read instead of the model's; null, QuantLib's empty handle, by default.
yStdDevsdoubleThe grid's width, in standard deviations; 7 by default.
yGridPointsintThe grid's points on each side; 64 by default.
extrapolatePayoffboolWhether to integrate the payoff past the grid; true by default.
flatPayoffExtrapolationboolWhether 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
typeisn't a member of its type, oryGridPointsis negative.