Physics-Informed Neural Operators for Optimal Execution in Stochastic Order-Book Fluids
π’ Release Notice: This repository contains the complete codebase for this project, engineered between September 7, 2025 and October 3, 2026. The work was developed intermittently alongside my OrderFlowContinuum and has been packaged in full for public viewing and use. Relative to my other projects this one is more ambitious in scope β a discrete LOB plus finite-volume continuum layer extended with physics-informed neural operators (FNO/DeepONet), residual losses, and an optimal-execution / SAC control interface β but the honest reason it exists is practical: I built it to deepen my own understanding of continuum order-book models, operator learning, and execution dynamics while day trading, not to ship a trading product or claim an edge.
Author: Nabil Khondaker
Continuum-LOB is a C++20 computational research platform that investigates a coarse-grained continuum representation of limit-order-book (LOB) state variables using mathematical structures inspired by compressible continuum mechanics. The system couples:
- an event-driven discrete LOB simulator,
- kernel-based coarse-graining onto density and velocity fields,
- a conservative finite-volume solver for a stochastic continuum PDE model,
- Fourier Neural Operator (FNO) and DeepONet-style surrogates,
- physics-informed residual losses,
- an optimal-execution environment with baseline strategies,
- Soft Actor-Critic (SAC) style control interfaces,
- verification, conservation tests, and reproducibility tooling.
The continuum analogy is a modeling framework, not a claim that the LOB is literally a NavierβStokes fluid.
Event-Driven LOB
β
Coarse-Graining
β
Continuum Fields (Ο, u, p, Ο)
β
Finite-Volume Solver β high-fidelity reference
β
Dataset Generation
β
FNO / DeepONet β learned solution operator
β
Surrogate Environment
β
Execution / Market-Making Control
β
Sim-to-Sim Validation against FV solver
Can a physics-informed neural operator learn the evolution operator of a stochastic continuum limit-order-book model sufficiently accurately to serve as a low-latency surrogate for optimal execution and market-making control?
Experiments are designed to measure when the surrogate works, where it fails, how error grows with rollout horizon, whether physics losses help, and whether policies trained on the surrogate transfer back to the numerical solver.
Normalized price displacement from a reference mid-price:
x β [-L, L], x < 0 β bid side, x > 0 β ask side
βΟ/βt + β(Οu)/βx = S_Ο
S_Ο represents exogenous limit-order arrivals and cancellations.
β(Οu)/βt + β(ΟuΒ² + p)/βx = βΟ/βx + F_ext + S_u
p = p(Ο)β liquidity-pressure constitutive relation (linear, nonlinear, or saturating)Ο = ΞΌ_eff(Ο, |βu/βx|) βu/βxβ impact / generalized-Newtonian stress analogyF_ext,S_uβ stochastic forcing
These are not fundamental laws of market microstructure. They are structured PDE models chosen to admit conservative finite-volume discretizations and operator learning.
Density is maintained separately as Ο_bid and Ο_ask to avoid collapsing
side information into a single scalar without documentation of information loss.
Requirements: CMake β₯ 3.20, C++20 compiler (GCC 11+, Clang 14+, MSVC 19.3+).
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failureOptional:
cmake -S . -B build -DCONTINUUM_LOB_ENABLE_OPENMP=ONNo mandatory external package manager is required for the core solver, discrete LOB, FNO prototype, or execution environment.
./build/continuum-lob simulate # finite-volume continuum run
./build/continuum-lob discrete # discrete LOB + coarse-graining
./build/continuum-lob fno-demo # FNO forward pass (untrained)
./build/continuum-lob execution # TWAP vs market episode| Layer | Role |
|---|---|
| Discrete LOB | Event-driven book with limit / cancel / market |
| Coarse-graining | Gaussian / compact / triangular / histogram kernels |
| Continuum PDE | Continuity + momentum-like system |
| Finite-volume | Rusanov flux, optional MUSCL, CFL control |
| FNO | Spectral convolution layers, pure C++ prototype |
| Physics loss | Continuity / momentum / conservation residuals |
| Execution env | Inventory, impact, adverse selection, baselines |
| SAC interface | Actor-critic scaffolding and replay buffer hooks |
| Verification | Conservation, mesh/timestep convergence hooks |
Example solver config (configs/solver/minimal.yaml):
mesh:
x_min: -1.0
x_max: 1.0
n_cells: 64
constitutive:
pressure: linear
c: 1.0
mu0: 0.02
solver:
cfl: 0.3
t_final: 0.2
adaptive_dt: truectest --test-dir build --output-on-failureIncluded tests:
- field arithmetic and norms
- mass conservation (zero-flow, zero-source)
- finite-volume advance
- discrete LOB fill + coarse-grain projection
- FNO forward shape / parameter count
- end-to-end pipeline (LOB β continuum β FV β FNO β execution)
- Continuum approximation discards queue discreteness and finite tick structure.
- Coarse-graining bandwidth is a modeling choice; results depend on it.
- Constitutive laws are analogies, not estimated from real markets in this repo.
- Synthetic event generation is not calibrated to any exchange.
- FNO weights ship untrained; training is reproducible but not pre-computed for large models.
- Rollout error of neural operators grows with horizon; long-horizon reliability is not assumed.
- Reinforcement-learning policies may exploit surrogate artifacts; sim-to-sim transfer must be checked.
- No real-market data, live trading, or profitability claims are made.
See docs/limitations/model_risk.md for a structured discussion.
This project is a research and computational modeling framework. Its synthetic market environment, continuum approximation, numerical model, neural surrogate, and control policies are not evidence of real-world profitability or execution performance. Results must not be interpreted as investment advice or as validated trading recommendations.
Nabil Khondaker. Continuum-LOB: Physics-Informed Neural Operators for
Optimal Execution in Stochastic Order-Book Fluids. 2025.
See CITATION.cff.
MIT β see LICENSE.