DERIBIT LOB MODEL
Real-time limit order book analysis and paper-trading system for Deribit. Streams live order-book snapshots and trades via WebSocket, runs four competing microstructure strategies side-by-side, and displays a live terminal dashboard comparing their performance.
Go to Repo Read Blog
THE IDEA
Most alpha in liquid crypto markets lives in the microstructure (queue imbalances, order flow, and price-impact dynamics that play out over milliseconds to seconds). This project streams live Deribit order-book snapshots via WebSocket, runs three academic microstructure models in parallel, and wraps them in a composite signal with explicit confidence gating and asymmetric risk management.
The result is a live paper-trading engine that logs every decision (signal values, confidence scores, skip/entry/exit rationale) to a real-time terminal dashboard powered by Rich.
STRATEGIES (MICROSTRUCTURE)
Three standalone microstructure strategies run independently, each rooted in a canonical academic model:
| Strategy | Paper | Signal |
|---|---|---|
| Cont-de Larrard | SIAM J. Financial Math, 2013 | LOB queue imbalance at best bid/ask |
| Kyle | Econometrica, 1985 | Price-impact coefficient λ from net order flow |
| OFI | J. Financial Econometrics, 2014 | Event-by-event order flow imbalance z-score |
COMPOSITE ALPHA
The fourth strategy fuses all three microstructure signals plus an Ornstein-Uhlenbeck mean-reversion anchor into a single composite score. Every entry is gated through a multi-layer confidence filter:
- Confidence check: requires 3 of 4 sub-signals to agree, a favorable vol regime, and no recent price jumps.
- Asymmetric SL/TP: stop-loss = 5× ATR, take-profit = 20× ATR, a 1:4 risk-reward ratio.
- 30s cooldown: prevents overtrading; quality over quantity.
The model logs its full reasoning to a live thought-process panel on the dashboard, making every skip and entry fully auditable in real time.
DASHBOARD LAYOUT
The terminal dashboard refreshes twice per second and organises information into five panels:
- Strategy table: signal, position, trade count, realized / unrealized / total PnL for all four strategies.
- PnL sparklines: rolling history per strategy, rendered as ASCII bar charts.
- Signal breakdown: horizontal bars for each Composite Alpha sub-signal plus a confidence meter.
- Thought process: scrolling log of Composite Alpha decisions with timestamps.
- Recent trades: last 10 fills across all strategies with side, price, size, position, and PnL delta.
ADDITIONAL MODELS
Three more models are included but inactive by default. They can be enabled in run_model.py:
- Jump Diffusion: Merton (1976), drift plus Poisson jump estimation.
- OU Mean Reversion: Ornstein-Uhlenbeck mean-reverting process.
- Heston Vol: Heston (1993), momentum scaled by stochastic vol regime.