pub struct TrinomialLattice {
pub dt: f64,
pub dx: f64,
/* private fields */
}Expand description
A recombining trinomial lattice over the integer state grid
x_j = j * dx (the caller maps j to its own state, e.g.
r(i, j) = alpha_i + j * dx for a fitted short-rate tree).
Built from a per-node branching closure, so edge-switching trees
(Hull-White clamping) and plain diffusions use the same engine. The
per-layer index ranges follow from reachability. Discounting is
per node — df(layer, j) — because for fixed income the short
rate lives on the node; equity-style trees pass a constant.
Fields§
§dt: f64§dx: f64Implementations§
Source§impl TrinomialLattice
impl TrinomialLattice
Sourcepub fn build(
n: usize,
dt: f64,
dx: f64,
branching: &dyn Fn(usize, i32) -> TrinomialBranch,
) -> Result<TrinomialLattice, RustyQLibError>
pub fn build( n: usize, dt: f64, dx: f64, branching: &dyn Fn(usize, i32) -> TrinomialBranch, ) -> Result<TrinomialLattice, RustyQLibError>
Build n steps of the lattice from the branching rule.
Probabilities are validated per node; targets may shift by at most
one index per step (|target - j| <= 1), which keeps the tree
recombining.
pub fn steps(&self) -> usize
Sourcepub fn layer_range(&self, i: usize) -> (i32, i32)
pub fn layer_range(&self, i: usize) -> (i32, i32)
Node index range (j_min, j_max) of a layer.
Sourcepub fn price(
&self,
node_df: &dyn Fn(usize, i32) -> f64,
terminal: &dyn Fn(i32) -> f64,
exercise: Option<&dyn Fn(usize, i32, f64) -> f64>,
) -> f64
pub fn price( &self, node_df: &dyn Fn(usize, i32) -> f64, terminal: &dyn Fn(i32) -> f64, exercise: Option<&dyn Fn(usize, i32, f64) -> f64>, ) -> f64
Backward induction. node_df(i, j) is the one-step discount at
the node (state-dependent: e^{-r(i,j) dt} on a short-rate
tree); terminal(j) values the final layer; exercise (when
given) maps (layer, j, continuation) to the node value.
Sourcepub fn arrow_debreu(&self, node_df: &dyn Fn(usize, i32) -> f64) -> Vec<Vec<f64>>
pub fn arrow_debreu(&self, node_df: &dyn Fn(usize, i32) -> f64) -> Vec<Vec<f64>>
Arrow-Debreu state prices by forward induction: Q[i][j - j_min[i]]
is the value today of receiving 1 at node (i, j). The workhorse of
short-rate curve fitting — Hull-White’s alpha_i shifts solve
sum_j Q[i][j] e^{-(alpha_i + j dx) dt} = P(0, t_{i+1}) layer by
layer. sum_j Q[n][j] is the tree’s discount factor to t_n.
Trait Implementations§
Source§impl Clone for TrinomialLattice
impl Clone for TrinomialLattice
Source§fn clone(&self) -> TrinomialLattice
fn clone(&self) -> TrinomialLattice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more