A research-grade market-making strategy implementation exploring order-flow-based signals and inventory-skewed quoting, backtested against historical L2 market data. Built on top of liquid-book (order book + matching infra) so this repo can focus entirely on the trading logic.
Research/backtesting only. Not connected to any live exchange, and not a claim of live trading performance. All results below are backtest results on historical/synthetic data, clearly labeled as such.
Status: early development. The "Backtest Results" section stays empty until a real backtest has actually run — see
docs/description.mdfor the current plan and status.
Note on Infrastructure: The underlying exchange mechanics, order matching, and latency simulation for this strategy are powered by my custom C++/Java/Rust matching engine, liquid-book.
Separates the alpha/research question ("does this signal + quoting logic produce positive risk-adjusted PnL on historical data?") from the systems question (how fast can it run) — which lives in liquid-book. Keeping them apart makes both stories cleaner: this repo can be judged on statistical rigor and backtest methodology, not implementation speed.
This repo depends on liquid-book for the order book and simulated exchange (as a git submodule or linked library — see Build section). It does not reimplement book/matching logic.
Quantifies net supply/demand shifts by tracking changes in price and size at the best bid and ask across consecutive book updates. Positive OFI → buying pressure; negative → selling pressure.
A volume-weighted mid-price incorporating top-of-book queue depth:
When V_ask >> V_bid, the micro-price shifts toward the ask, suggesting the mid is more likely to move upward — the imbalance in resting size implies imbalance in near-term pressure.
Inventory-aware two-sided quoting: reservation price skews away from current inventory (sell more aggressively when long, buy more aggressively when short), and spread widens with volatility. Classic market-making framework — implemented here as a baseline to compare signal-augmented variants against, not treated as novel on its own.
include/
├── signals/ # OFI, Micro-Price calculators
└── strategy/ # Avellaneda-Stoikov quoting logic
src/
├── strategy.cpp
└── backtest_runner.cpp
notebooks/ # Exploratory analysis, signal validation (Python)
data/ # Historical/synthetic L2 data (or symlink/fetch script)
docs/
└── description.md # Detailed dev + research plan (start here)
- C++20 compiler (matches
liquid-book) liquid-bookbuilt and available (submodule:git submodule update --init)- Python 3.10+ with
pandas,numpy,matplotlibfor the analysis notebooks (signal validation and backtest reporting happen in Python; execution logic stays in C++)
git submodule update --init --recursive
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)./build/backtest_runner --data data/sample_l2.csv --strategy avellaneda_stoikov(Empty until a real backtest has run — see docs/description.md for methodology. Results here will include: Sharpe ratio, information coefficient (IC) of each signal, max drawdown, PnL curve, and — critically — the data date range and whether it's in-sample or out-of-sample. A backtest without an explicit train/test split is not a credible result.)
- HMM regime classification (trending / mean-reverting / volatile) to condition strategy parameters
- ML tick-direction prediction (LightGBM/XGBoost) on microstructural features
- Multi-level weighted micro-price (top-K levels, exponential decay)
- Trade arrival rate signal (EWMA intensity estimation)
MIT — see LICENSE.