Skip to content

9. Trade on Binance Demo

Binance Spot Demo Mode is a Binance environment with demo balances and its own API keys. The commands on this page are in scripts/docs/tutorial.sh --through demo.

1. Dry run

"$BIN"/tutorial-live --config configs/tutorial-binance-demo.toml --dry-run --duration 60s

--dry-run connects to public market data only, reads no keys and sends no orders. first_mm quotes as it will with keys, and the orders stay on paper. Look for these lines:

Line Means
first_mm: started, quoting on the strategy runs
dry run BTCUSDT: bid ... ask ..., every 5 s the quotes that would rest
status line with md=live and books=1/1 market data is live and the book is built

If the program exits instead, look up its message in Troubleshooting.

2. Keys

Switch to Demo Trading on binance.com, create an API key under API Key Management, and export it in the terminal that runs the session:

export FASTMM_BINANCE_API_KEY=<demo key> FASTMM_BINANCE_API_SECRET=<demo secret>

Binance testnet keys do not work here (Binance Spot Demo Mode). The configuration reads the variables as api_key = "${FASTMM_BINANCE_API_KEY}" (Configuration).

3. The risk limits

The strategy quotes 0.0001 BTC (about 8 USDT) per side and stops adding at 0.0003 BTC. Independently of the strategy, the engine's pre-trade checks in configs/tutorial-binance-demo.toml refuse anything beyond these limits:

[risk] key Value Effect
max_order_qty 0.0002 no order above 0.0002 BTC
max_order_notional 25 no order above 25 USDT
max_position 0.0004 position plus same-side open orders stays within 0.0004 BTC
max_open_orders 2 at most 2 open orders
max_loss 5 the kill switch trips when net PnL reaches -5 USDT (After a kill)
orders_per_sec, burst 2, 4 orders per second, burst

The Demo account charges 10 bps per fill; first_mm quotes 5 bps from the microprice.

4. A five-minute session

Warning. This command places orders with the keys you exported. Use Demo Trading keys, not the keys of a real account (Kill switch and shutdown).

"$BIN"/tutorial-live --config configs/tutorial-binance-demo.toml --duration 5m \
  --journal runs/tutorial/demo.fmj --log runs/tutorial/demo.log

Watch it from a second terminal:

./build/release/bin/fastmm-top --name tutorial-binance-demo

Within a few seconds the status line shows md=live user=live order=live and fastmm-top shows two open orders. Stop the session with Ctrl-C before the five minutes are up.

5. Check the shutdown

The log ends with:

fastmm-live: shutdown took <n> ms (cancel_all ok)
fastmm-live: exit code 0

Ctrl-C tripped the kill switch. cancel_all ok means the venue's cancel-all request succeeded; confirm in the Demo Trading web interface that no order is open (Go-live checklist).

If the line says cancel_all FAILED, cancel by hand and follow When cancel_all failed. The next session also cancels, when it connects, the orders an earlier one left open.

6. Check the PnL

python3 tools/pnl_report.py runs/tutorial/demo.fmj --engine-log runs/tutorial/demo.log

The report lists fills, maker share, volume, fees and inventory. It compares the journal's PnL with the engine's final summary; they agree to within rounding.

To reconcile against the account's balances, take balance snapshots before and after the session (Journals, replay and PnL).

Next: Go-live checklist before a longer session; Run on a testnet or Binance Demo for the other practice environments (Binance USDⓈ-M Demo Trading, the Binance Spot testnet, Bybit and Deribit).