Table of Contents

Class LogNormalFwdRateEulerConstrained

Namespace
NanoQL.Models
Assembly
NanoQL.dll

The constrained Euler evolver of a displaced log-normal LIBOR market model, for the Fries-Joshi proxy simulation of Greeks: at each step whose constraint is active, the log forwards are shifted along the constrained rate's covariances so that it lands on its constraint, and the step's weight takes the likelihood ratio of the shift.

[WorkingType]
public sealed class LogNormalFwdRateEulerConstrained : ConstrainedEvolver
Inheritance
LogNormalFwdRateEulerConstrained
Inherited Members

Remarks

A working type, copying each step's pseudo-root at construction.

Two departures from QuantLib (Divergences/ConstrainedEulerCovarianceTests.cs, …DisplacementTests.cs): each step's covariances with its constrained rate are its own pseudo-root's, where QuantLib builds every step's from the pseudo-root of the step SetConstraintType(ReadOnlySpan<int>, ReadOnlySpan<int>) is called at, so a later step's constraint misses (lognormalfwdrateeulerconstrained.cpp:117); and the log constraint is displaced by the constrained rate's displacement, where QuantLib's reads the step's index into the displacements (:146). A step before SetThisConstraint(ReadOnlySpan<double>, ReadOnlySpan<bool>), an active constraint before SetConstraintType(ReadOnlySpan<int>, ReadOnlySpan<int>) and a constrained rate past the rates, which QuantLib reads before or past its vectors, are refused.

The likelihood ratio (a documented divergence; Divergences/ProxyGreekVegaTests.cs): the evolver takes the reference model, the unbumped model whose distribution the proxy simulation keeps, and a constrained step's weight carries the ratio of the two models' transition densities of the constrained rate, which beside QuantLib's ratio of shifted to unshifted Gaussian densities (lognormalfwdrateeulerconstrained.cpp:200-212) holds √(var_reference / var_own) of the rate's step variance. QuantLib's weight misses that factor, right for a forward bump, whose variances are equal, and wrong for a volatility bump: its proxy vegas take the wrong sign. Where the reference is the evolver's own model, QuantLib's weight bit for bit.

Constructors

LogNormalFwdRateEulerConstrained(MarketModel, MarketModel, BrownianGeneratorFactory, ReadOnlySpan<int>, int)

Initializes a new instance of the LogNormalFwdRateEulerConstrained class.

public LogNormalFwdRateEulerConstrained(MarketModel marketModel, MarketModel referenceModel, BrownianGeneratorFactory factory, ReadOnlySpan<int> numeraires, int initialStep = 0)

Parameters

marketModel MarketModel

The model evolved.

referenceModel MarketModel

The reference model whose distribution the weights keep, of the model's rates and steps: the unbumped model of a proxy simulation, or marketModel for QuantLib's weight.

factory BrownianGeneratorFactory

The factory of the Brownian generator.

numeraires ReadOnlySpan<int>

The numeraires, one per step, compatible with the evolution.

initialStep int

The step each path starts from, below the number of steps.

Exceptions

ArgumentException

The numeraires aren't compatible with the evolution, or the reference model's rates or steps aren't the model's.

ArgumentOutOfRangeException

initialStep isn't a step.

Properties

CurrentState

Gets the curve state after the last step: the evolver's own, valid until its next step.

public override CurveState CurrentState { get; }

Property Value

CurveState

CurrentStep

Gets the step the next AdvanceStep() takes.

public override int CurrentStep { get; }

Property Value

int

Numeraires

Gets the numeraires, one per step.

public override ImmutableArray<int> Numeraires { get; }

Property Value

ImmutableArray<int>

Methods

AdvanceStep()

Evolves the rates over the current step.

public override double AdvanceStep()

Returns

double

The step's weight.

Exceptions

NanoQLException

The constraints aren't set yet, or a step's constraint is active before the constraints' type is set.

SetConstraintType(ReadOnlySpan<int>, ReadOnlySpan<int>)

Sets, once, the swap rates each step constrains.

public override void SetConstraintType(ReadOnlySpan<int> startIndexOfSwapRate, ReadOnlySpan<int> endIndexOfSwapRate)

Parameters

startIndexOfSwapRate ReadOnlySpan<int>

Each step's constrained forward rate.

endIndexOfSwapRate ReadOnlySpan<int>

Each step's constrained rate plus one: only forward rates are constrained.

Remarks

Each step's covariances are its own pseudo-root's.

Exceptions

ArgumentException

The sizes aren't the steps', or a step's swap isn't a forward rate.

ArgumentOutOfRangeException

A constrained rate is outside the rates.

SetInitialState(CurveState)

Sets the state each path starts from.

public override void SetInitialState(CurveState cs)

Parameters

cs CurveState

The curve state whose rates each path starts from.

Exceptions

ArgumentException

The state's forwards aren't one per rate.

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

Sets, before each path, the value each step constrains its swap rate to, and which steps are active.

public override void SetThisConstraint(ReadOnlySpan<double> rateConstraints, ReadOnlySpan<bool> isConstraintActive)

Parameters

rateConstraints ReadOnlySpan<double>

Each step's constrained rate's target.

isConstraintActive ReadOnlySpan<bool>

Whether each step's constraint is active.

Remarks

The targets' logs are displaced by the constrained rates' displacements, at each step, where QuantLib's displaces each step's by the displacement of the rate whose index is the step's.

Exceptions

ArgumentException

The sizes aren't the steps'.

StartNewPath()

Starts a new path.

public override double StartNewPath()

Returns

double

The path's weight.