BSDE Solver
Backward Stochastic Differential Equation solver using least-squares Monte Carlo for high-dimensional HJB problems.
Approach
- Forward simulation: simulate N state trajectories from t=0 to T
using
SimulationRunner. - Backward regression: starting from the known terminal condition at T, step backward. At each time step, regress the continuation value onto polynomial basis functions of the state variables.
- Control optimization: at each regression point, evaluate the control (bid/ask intensities) that maximizes the Hamiltonian.
Example
#![allow(unused)] fn main() { use solver::numeric::bsde::BsdeSolver; use solver::models::heston_hawkes::HestonHawkesModel; use solver::numeric::basis::PolynomialBasis; // Heston-Hawkes: N=3 model (inventory, variance, intensity) let model = HestonHawkesModel::new(/* ... */); let basis = PolynomialBasis::new(2, PolynomialType::Power); let solver = BsdeSolver::new(10_000, 100, // paths, time steps solver::numeric::bsde::InitializationMode::Local(5.0)); let solution = solver.solve(&model, [0.0, 0.04, 0.5], 1.0, &basis); // solution contains bid/ask intensities and value function }
Dimension-agnostic design
The solver uses Rust const generics and is fully generic over the state dimension N. The same code works for:
| N | Model | Description |
|---|---|---|
| 1 | Avellaneda-Stoikov | Inventory only |
| 2 | Heston / Hawkes | Inventory + variance or intensity |
| 3 | Heston-Hawkes | Inventory + variance + intensity |
The polynomial basis function count grows as O(N^2) for degree-2 polynomials:
| N | Features |
|---|---|
| 2 | 6 |
| 3 | 10 |
| 4 | 15 |
Configuration
- Number of paths and time steps.
- Basis function type (polynomial, scaled).
- Regularization parameter for the regression.
- Convergence tolerance.
When to use
BSDE is preferred when:
- The state dimension is 3 or higher.
- Grid-based methods would be intractable.
- You can tolerate Monte Carlo noise in the solution.
- You need to scale to models with more factors in the future.