Paper Trading
Paper trading runs Mercury against a live market feed but routes all orders through PaperGateway — a local matching engine. No real money is at risk.
Enable paper trading
cargo run --bin mercury -- run --symbol BTCUSDT --paper --strategy market_maker
How PaperGateway works
- Receives live
BookUpdateevents from the market feed. - When a new order arrives, checks whether it crosses the current best bid/ask.
- If it fills, publishes a synthetic
Fillevent onto theEventBusafter a configurable simulated delay. - Default simulated round-trip latency: 5 ms.
Custom latency
The paper gateway latency is set in code:
#![allow(unused)]
fn main() {
// crates/cli/src/run.rs
let gateway = PaperGateway::with_latency(Duration::from_millis(10));
}
Limitations
- No partial fills — orders either fill completely or not at all.
- No queue position — the paper gateway assumes your order is at the top of the queue.
- Simulated latency is constant; real latency is variable.
These simplifications make paper results optimistic. Use backtesting on recorded data for more realistic simulation.