Table of Contents

Class G2Process

Namespace
NanoQL.Processes
Assembly
NanoQL.dll

The G2 stochastic process: the two-factor G2++ process with its state shifted so that the two components sum to the short rate, (z₁, z₂) = (x + φ(t), y), x and y the zero-mean Ornstein-Uhlenbeck factors and φ the deterministic offset that fits the initial curve; without a curve, the two zero-mean processes (φ ≡ 0).

public sealed class G2Process : StochasticProcess
Inheritance
G2Process
Inherited Members

Remarks

A path generated on it satisfies r(tᵢ) = z₁ᵢ + z₂ᵢ, its expectation φ(tᵢ). The step's conditional correlation, QuantLib's ρση(1 − e^(−(a+b)Δt))/(a + b) over ½ση√((1 − e^(−2aΔt))(1 − e^(−2bΔt))/(ab)), is written as ρ·f((a+b)Δt)/√(f(2aΔt)·f(2bΔt)), f(x) = (1 − e^(−x))/x, and held in [−1, 1], ρ itself where a = b; φ's terms as G2's: a divergence, QuantLib's √(1 − ρ²) of a correlation an ulp past ±1 being NaN at ρ = ±1 with a = b (Divergences/G2ProcessCorrelationBoundTests.cs), and its terms cancelling at small reversion.

Constructors

G2Process(double, double, double, double, double, YieldTermStructure?)

Initializes a new instance of the G2Process class.

public G2Process(double a, double sigma, double b, double eta, double rho, YieldTermStructure? termStructure = null)

Parameters

a double

The first factor's mean reversion.

sigma double

The first factor's volatility, not negative.

b double

The second factor's mean reversion.

eta double

The second factor's volatility, not negative.

rho double

The factors' correlation.

termStructure YieldTermStructure

The curve the shift fits; null, QuantLib's empty handle, for none.

Exceptions

ArgumentOutOfRangeException

sigma or eta is negative or NaN.

Properties

A

Gets the first factor's mean reversion a.

public double A { get; }

Property Value

double

B

Gets the second factor's mean reversion b.

public double B { get; }

Property Value

double

Eta

Gets the second factor's volatility η.

public double Eta { get; }

Property Value

double

Rho

Gets the factors' correlation ρ.

public double Rho { get; }

Property Value

double

Sigma

Gets the first factor's volatility σ.

public double Sigma { get; }

Property Value

double

Size

Gets the number of dimensions of the process.

public override int Size { get; }

Property Value

int

TermStructure

Gets the curve the shift fits, or null for none.

public YieldTermStructure? TermStructure { get; }

Property Value

YieldTermStructure

X0

Gets the first component's initial value: φ(0) on a curve, 0 without one.

public double X0 { get; }

Property Value

double

Y0

Gets the second component's initial value, 0.

public double Y0 { get; }

Property Value

double

Methods

Covariance(double, Vector, double)

The covariance V(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's covariance.

public override Matrix Covariance(double t0, Vector x0, double dt)

Parameters

t0 double

The start of the interval.

x0 Vector

The state at its start.

dt double

The interval's length.

Returns

Matrix

A new matrix.

Exceptions

NanoQLException

The process has no discretization.

Diffusion(double, Vector)

The diffusion part of the equation, σ(t, x_t).

public override Matrix Diffusion(double t, Vector x)

Parameters

t double

The time.

x Vector

The state.

Returns

Matrix

A new matrix.

Drift(double, Vector)

The drift part of the equation, μ(t, x_t).

public override Vector Drift(double t, Vector x)

Parameters

t double

The time.

x Vector

The state.

Returns

Vector

A new vector.

Exceptions

ArgumentException

x holds fewer values than the state, where QuantLib reads past its end.

Expectation(double, Vector, double)

The expectation E(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's drift applied to x0 by Apply(Vector, Vector).

public override Vector Expectation(double t0, Vector x0, double dt)

Parameters

t0 double

The start of the interval.

x0 Vector

The state at its start.

dt double

The interval's length.

Returns

Vector

A new vector.

Exceptions

NanoQLException

The process has no discretization.

ArgumentException

x0 holds fewer values than the state, where QuantLib reads past its end.

InitialValues()

The initial values of the state variables.

public override Vector InitialValues()

Returns

Vector

A new vector.

Phi(double)

The shift φ(t) = f(t) + ½(σ(1 − e^(−at))/a)² + ½(η(1 − e^(−bt))/b)² + ρ(σ(1 − e^(−at))/a)(η(1 − e^(−bt))/b), f the curve's instantaneous forward.

public double Phi(double t)

Parameters

t double

The time.

Returns

double

φ(t).

Exceptions

NanoQLException

The process has no curve.

ShortRate(double, double, double)

The short rate at the state: z₁ + z₂, the state already including φ(t).

public double ShortRate(double t, double z1, double z2)

Parameters

t double

The time, unused.

z1 double

The first component.

z2 double

The second component.

Returns

double

The short rate.

StdDeviation(double, Vector, double)

The standard deviation S(x_{t0 + Δt} | x_{t0} = x0) of the process after a time interval Δt; by default, the discretization's diffusion.

public override Matrix StdDeviation(double t0, Vector x0, double dt)

Parameters

t0 double

The start of the interval.

x0 Vector

The state at its start.

dt double

The interval's length.

Returns

Matrix

A new matrix.

Exceptions

NanoQLException

The process has no discretization.

ArgumentException

x0 holds fewer values than the state, where QuantLib reads past its end.