solver

The optimization layer. Solves Hamilton-Jacobi-Bellman equations for optimal control problems, with a focus on market making.

What is currently available

Numerical solvers

Finite Difference Policy Iteration (numeric/):

  • Discretizes the HJB PDE on a grid over state variables (inventory, variance, intensity).
  • Uses policy iteration: alternate between solving the linear system for the value function and optimizing the control.
  • Custom sparse linear algebra (linalg/): CSR matrices, SOR solver, eigenvalue decomposition.
  • Configurable grid resolution, boundary conditions, and convergence tolerance.

BSDE Least-Squares Monte Carlo (numeric/bsde/):

  • Backward stochastic differential equation approach.
  • Forward simulation of state trajectories via SimulationRunner.
  • Backward regression of value function using polynomial basis functions.
  • Dimension-agnostic: works for N-dimensional models via const generics (tested up to N=3 with Heston-Hawkes).
  • Basis function scaling: 6 features for N=2, 10 for N=3, 15 for N=4 (degree-2 polynomials).

Analytical solutions

Avellaneda-Stoikov (analytical/):

  • Closed-form bid/ask quotes for the canonical market making model.
  • Used as a baseline to validate numerical methods.

Models (models/)

Pre-built optimal control models:

ModelState dimensionsDescription
Avellaneda-Stoikov1 (inventory)Constant arrival intensity, terminal penalty
Hawkes2 (inventory, intensity)Self-exciting arrival intensity
Heston2 (inventory, variance)Stochastic volatility
Heston-Hawkes3 (inventory, variance, intensity)Full multi-factor model

Lookup tables (lookup/)

Caches pre-computed grid evaluations for fast interpolation. Used by the engine to evaluate HJB-derived strategies at sub-grid resolution in real-time during backtesting.

Linear algebra (linalg/)

Custom sparse matrix and solver implementations:

  • CSR (Compressed Sparse Row) matrix format.
  • SOR (Successive Over-Relaxation) iterative solver.
  • Eigenvalue decomposition.
  • Intel MKL-backed dense linear algebra via lapack.

What is not yet available

  • GPU-accelerated linear solvers.
  • ADI (Alternating Direction Implicit) splitting for higher-dimensional finite difference grids.
  • Additional model types (OU-based, rough volatility, multi-asset).
  • Direct integration of solved value functions into the engine as Strategy implementations (infrastructure not yet wired).