Module lattice
Expand description
The Hull-White trinomial lattice, written once against Scalar.
This is the general trinomial lattice — per-step Δt from an exact-dates
TimeGrid, variance-matched node spacing Δx_{i+1} = √(3·v²_i),
mean-centered branching with a precomputed branch table, and per-slice
displacements α_i fitted by Arrow-Debreu forward induction to reprice the
curve — and the geometry is active. Spacing and branch probabilities are
not passive f64 with vega taken by bump-recalibration; mean reversion and volatility arrive as market inputs in
the pricing mode, so ∂PV/∂σ and ∂PV/∂a fall out of the ordinary risk pass and
Jet2 reaches σ-gamma through this same body. The passive instantiation is
plain f64 arithmetic.
The one discrete ingredient — the branch re-centering index k — is an
index, not a value: it is computed from passive magnitudes (value())
and stays an integer, while the smooth remainder u that feeds the
probabilities is computed in the mode. Derivatives are exact away from
re-centering boundaries, a measure-zero kink set that a bump scheme steps
over silently.
Structs§
- Hull
White Lattice - The Hull-White trinomial lattice at one mode. Geometry, displacements and
rollback values are all
R; only node indices are integers. - Step
Credit - An issuer’s credit on a lattice’s steps: for step
i(sliceitoi + 1), the survival over itS(tᵢ₊₁)/S(tᵢ)and the recovery a default in it pays at its end,R·F(tᵢ)·(1 − S(tᵢ₊₁)/S(tᵢ))on the face alive at its start. Branch probabilities sum to one, so the recovery needs none. - Time
Grid - The lattice time grid: slice dates and their year fractions from valuation.
Constants§
- DEFAULT_
STEPS_ PER_ YEAR - A sensible default lattice resolution: within a few ×
10⁻³of analytic prices by ~70 steps/year on convergence runs; 50 balances price and accuracy for production use.
Traits§
- Discretized
Asset - A product valued by backward induction on a
HullWhiteLattice. The lattice rolls it back; the asset injects its cashflows and exercise at each slice, in the pricing mode.
Functions§
- compounded_
oas - Quotes a continuously compounded spread at a periodic frequency:
s_m = m·(e^{s/m} − 1)withmthe periods per year. The engine’s canonical spread (the OAS the lattice discounts with) is continuous; this conversion is presentation only. - drift_
convexity 🔒 - The drift convexity
C(t)the displacement carries over the forward,α(t) = f(0, t) + C(t):(σ²/2a²)(1 − e^{−at})²for a flat volatility (½σ²t²asa → 0), the term’s ownC(t)otherwise. - step_
variance 🔒 - The conditional variance of
xover one step fromt0tot1:σ²(1−e^{−2a·dt})/(2a)for a flat volatility, degenerating toσ²·dtasa → 0(the branch selected on the passive value); under a term, the term’s ownV(t0, t1), so a piece boundary inside the step is integrated over it rather than snapped to a slice. The arithmetic runs in the mode. - yf 🔒
- Act/365F year fraction — the lattice’s time metric.