Class BlackScholesLattice<T>
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
TThe 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
treeTThe tree.
riskFreeRatedoubleThe flat, continuously compounded risk-free rate.
enddoubleThe grid's last time.
stepsintThe grid's number of steps.
Exceptions
- ArgumentNullException
treeis null.- ArgumentOutOfRangeException
stepsis negative.
Fields
pd
QuantLib's pd_: the tree's first node's probability of its down branch.
protected readonly double pd
Field Value
pu
QuantLib's pu_: the tree's first node's probability of its up branch.
protected readonly double pu
Field Value
Properties
Dt
Gets the step's length.
public double Dt { get; }
Property Value
RiskFreeRate
Gets the flat risk-free rate.
public double RiskFreeRate { get; }
Property Value
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
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
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
Returns
- double
The probability.
Size(int)
The number of nodes at a step.
public override int Size(int i)
Parameters
iintThe 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
iintThe step's index on the grid.
valuesReadOnlySpan<double>The values at step
i+ 1.newValuesSpan<double>The values at step
i, written here: Size(int)(i) of them.
Exceptions
- ArgumentOutOfRangeException
iisn't a step before the grid's last, where QuantLib reads past its end.- ArgumentException
valuesholds fewer values than stepi+ 1's nodes, ornewValuesfewer than stepi's, where QuantLib reads and writes past their ends.- ArgumentOutOfRangeException
iis negative, a step QuantLib's unsigned index can't be.- ArgumentException
valuesholds fewer values than stepi+ 1's nodes, ornewValuesfewer than stepi'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
Returns
- double
The value.