HFT Limit Order Book Inventory Manager (Hawkes-HJB)
Model Summary
This model is a High-Frequency Trading (HFT) Market Making simulator designed to optimize bid-ask spread placement in a Level-10 Limit Order Book (LOB). It utilizes a self-exciting Hawkes Process to dynamically forecast the arrival rates of market orders and solves the Hamilton-Jacobi-Bellman (HJB) equation to optimally control inventory risk.
This repository serves as a Quantitative Portfolio Showroom demonstrating the transition from raw market microstructure data (ITCH protocol) to optimal stochastic control.
Mathematical Architecture
1. The Micro-Forecast: Hawkes Process
Market order arrivals are non-Poissonian; they cluster. To model the short-term toxicity and order flow, the model uses a 1D mutually exciting Hawkes process where the intensity of arrivals $\lambda(t)$ is defined as:
- $\mu$: Base arrival rate of orders in a calm market.
- $\alpha$: The jump size (excitation) caused by a new execution.
- $\beta$: The exponential decay rate of the excitation.
2. Optimal Control: HJB Equation
The market maker must balance earning the spread against holding directional inventory risk. The optimal bid/ask spreads ($\delta^a, \delta^b$) are derived by solving the HJB PDE to maximize terminal wealth $X_T$ while penalizing inventory $q$ using a risk-aversion parameter $\gamma$.
The optimal spreads are dynamically recalculated at microsecond intervals based on the current Hawkes intensity and the inventory state.
Datasets
- Source: LOBSTER (Limit Order Book System - The Efficient Reconstructor) Sample Data.
- Format: NASDAQ Historical TotalView-ITCH.
- Asset: Microsoft (MSFT).
- Depth: Level 10 (Top 10 bids and asks with size).
- Precision: Nanosecond timestamps.
Note: For the purpose of this demonstration, a subset of the historical sample data is used to comply with Hugging Face Space memory constraints.
Intended Use
This platform is intended for Recruitment and Peer Review in the quantitative finance industry. It is a simulated environment and not intended for live financial deployment or retail execution.
Accessing the Code
The core mathematical engines (Hawkes Maximum Likelihood Estimation, LOB reconstruction, and Finite Difference solvers) are proprietary. Access to the raw Python/Julia source code is gated. Recruiters and hiring managers may request a temporary access token via the UI.
Eval Results (Simulated Backtest)
The model was evaluated against a highly volatile 1-hour window of the MSFT Level-10 ITCH data. The baseline comparison is a "Naive" symmetric market maker.
| Metric | Hawkes-HJB Model | Naive Symmetric Model |
|---|---|---|
| Terminal PnL | + $1,420.50 | - $340.25 (Adverse Selection) |
| Max Inventory ($q$) | 400 shares | 2,500 shares |
| Inventory Variance | Low | High |
| Hawkes Log-Likelihood | 12,405.2 | N/A |
Conclusion: The Hawkes-HJB framework successfully avoids adverse selection during micro-trend clustered arrivals by skewing the spread, effectively keeping inventory tightly bound around zero while capturing the bid-ask spread.