Live BTC/USD market data feed with a simulated market making engine, built on Binance WebSocket streams.
pip install -r requirements.txtPython 3.11+ required.
Interactive web UI with live charts, configurable strategy parameters, and CSV export.
Live demo: https://mm-dashboard-microstructure.streamlit.app/
The demo runs on Binance US (spot only). For Binance spot/futures, run locally. Set the theme to Dark in the Streamlit settings (top-right menu → Settings) for the best experience.
streamlit run streamlit_app.pyOpens at http://localhost:8501. All parameters are adjustable from the sidebar without restarting.
Runs in the terminal. Displays order book, recent trades, spread statistics, simulated fills, markout analytics, and queue diagnostics — all refreshed in real time.
python app.pyOptions:
| Flag | Default | Description |
|---|---|---|
--symbol |
BTCUSDT |
Symbol to stream, e.g. SOLUSDT, ETHUSDT |
--exchange |
binance |
binance or binance_us |
--mm-quote-mode |
top |
Quote placement mode (see below) |
--mm-spread-pct |
0.002 |
Total bid/ask spread in %, e.g. 0.01 |
--mm-bid-level |
1 |
Book level for level mode |
--mm-ask-level |
1 |
Book level for level mode |
--mm-queue-ahead-multiple |
3.0 |
Max queue ahead multiplier for queue_aware mode |
--depth |
5 |
Number of order book levels to display |
--refresh-seconds |
1.0 |
Terminal refresh interval |
Examples:
# SOL/USDT with a 0.01% spread, top-of-book mode
python app.py --symbol SOLUSDT --mm-spread-pct 0.01 --mm-quote-mode top
# BTC with queue-aware mode, max 5x queue ahead
python app.py --mm-quote-mode queue_aware --mm-queue-ahead-multiple 5.0
# Level 2 on both sides
python app.py --mm-quote-mode level --mm-bid-level 2 --mm-ask-level 2| Mode | How it works |
|---|---|
mid |
Posts bid/ask symmetrically around the mid-price. Spread parameter controls the distance. |
top |
Joins the current best bid and best ask. Tightest possible quotes. |
level |
Joins a specific book level (e.g. L2, L3). Controlled by --mm-bid-level / --mm-ask-level. |
microprice |
Like mid but centers on the volume-weighted mid (accounts for bid/ask size imbalance). |
queue_aware |
Finds the most aggressive level where estimated queue ahead ≤ N × quote size. Balances fill probability vs. adverse selection. |
Inventory skew — shifts quotes away from the current position to reduce exposure. Long → quotes move lower to sell; short → quotes move higher to buy.
Imbalance skew — shifts quotes based on top-of-book bid/ask size imbalance. More bids than asks → quote slightly higher.
Volatility spread coeff — widens the quoted spread dynamically during fast markets: effective_spread = base_spread + coeff × short_term_move_bps. Only active in mid and microprice modes.
Volatility gate — suspends quoting entirely when the mid-price moves more than N bps within the volatility window. Set to 0 to disable.
- Max notional exposure: stops quoting if
|position| × mark_priceexceeds the limit (default $1,000,000) - Max loss: halts all trading if total P&L drops below −$100,000 (10% of initial $1M deposit)
Order book — top N bid/ask levels with your simulated quotes highlighted.
Spread statistics — cost of crossing the spread for sizes of 0.1, 1, 5, 10 BTC. Includes current, average, median, min, max, and rolling averages over 1m / 5m / 15m.
Simulated fills — each fill shows side, price, size, and markout at 1s / 5s / 10s after fill. Negative markout = adverse selection (price moved against you after the fill).
Queue diagnostics — tracks how much volume was ahead of your quote in the book and how that correlates with fill probability.
P&L — realized, unrealized, and total. Unrealized uses current mid-price as mark.
CSV export (Streamlit only) — trade log with markout, and full P&L history tick by tick.