Table of Contents

Class BlackScholesLattice<T>

Namespace
NanoQL.Methods
Assembly
NanoQL.dll

The Black-Scholes lattice on a binomial tree: the tree's nodes and probabilities, discounted at a flat rate over a uniform grid.

public class BlackScholesLattice<T> : TreeLattice1D where T : Tree

Type Parameters

T

The binomial tree.

Inheritance
BlackScholesLattice<T>
Derived
Inherited Members

Remarks

Immutable once built (the playbook's lattice row). Its step back is QuantLib's, the tree's first-node probabilities applied to every node: (pd·v[j] + pu·v[j + 1])·discount.

Unsealed, an extension point, as QuantLib's is: the Tsiveriotis-Fernandes lattice derives from it and reads the protected probabilities.

Constructors

BlackScholesLattice(T, double, double, int)

Initializes a new instance of the BlackScholesLattice<T> class.

public BlackScholesLattice(T tree, double riskFreeRate, double end, int steps)

Parameters

tree T

The tree.

riskFreeRate double

The flat, continuously compounded risk-free rate.

end double

The grid's last time.

steps int

The grid's number of steps.

Exceptions

ArgumentNullException

tree is null.

ArgumentOutOfRangeException

steps is negative.

Fields

pd

QuantLib's pd_: the tree's first node's probability of its down branch.

protected readonly double pd

Field Value

double

pu

QuantLib's pu_: the tree's first node's probability of its up branch.

protected readonly double pu

Field Value

double

Properties

Dt

Gets the step's length.

public double Dt { get; }

Property Value

double

RiskFreeRate

Gets the flat risk-free rate.

public double RiskFreeRate { get; }

Property Value

double

Methods

Descendant(int, int, int)

The index, at the next step, of a node's descendant along a branch.

public override int Descendant(int i, int index, int branch)

Parameters

i int

The step's index on the grid.

index int

The node's index at the step.

branch int

The branch.

Returns

int

The descendant's index.

Discount(int, int)

The discount factor over the step that starts at a node.

public override double Discount(int i, int index)

Parameters

i int

The step's index on the grid.

index int

The node's index at the step.

Returns

double

The discount factor.

Probability(int, int, int)

The probability of a node's branch.

public override double Probability(int i, int index, int branch)

Parameters

i int

The step's index on the grid.

index int

The node's index at the step.

branch int

The branch.

Returns

double

The probability.

Size(int)

The number of nodes at a step.

public override int Size(int i)

Parameters

i int

The step's index on the grid.

Returns

int

The number of nodes.

Stepback(int, ReadOnlySpan<double>, Span<double>)

Rolls values one step back: for each node, the probability-weighted sum of its descendants' values, then the node's discount.

public override void Stepback(int i, ReadOnlySpan<double> values, Span<double> newValues)

Parameters

i int

The step's index on the grid.

values ReadOnlySpan<double>

The values at step i + 1.

newValues Span<double>

The values at step i, written here: Size(int)(i) of them.

Exceptions

ArgumentOutOfRangeException

i isn't a step before the grid's last, where QuantLib reads past its end.

ArgumentException

values holds fewer values than step i + 1's nodes, or newValues fewer than step i's, where QuantLib reads and writes past their ends.

ArgumentOutOfRangeException

i is negative, a step QuantLib's unsigned index can't be.

ArgumentException

values holds fewer values than step i + 1's nodes, or newValues fewer than step i's, where QuantLib reads and writes past their ends.

Underlying(int, int)

The underlying variable's value at a node.

public override double Underlying(int i, int index)

Parameters

i int

The step's index on the grid.

index int

The node's index at the step.

Returns

double

The value.