sandbox-quant
Rust-native Binance Spot Testnet trading prototype.
It provides real-time market streaming, strategy-driven order execution, cumulative trade history, and a terminal dashboard for monitoring positions and performance.
Main Features

- Real-time market + strategy loop
- Streams Binance Spot Testnet trades through WebSocket.
- Runs MA crossover logic and executes orders via REST.
- Terminal trading dashboard (ratatui)
- Live chart, position panel, order/signal panel, order history, and system log.
- Fast keyboard control for trading and navigation.
- Historical trade persistence and recovery
- Persists orders/trades to SQLite.
- Automatically backfills missing history and continues with incremental sync.
- Stable cumulative performance stats
- Keeps cumulative
Trades/W/L/PnLfrom resetting on transient API issues. - Uses history-first stats for consistent dashboard values.
- Keeps cumulative
- Strategy and manual-performance breakdown
- Strategy selector shows per-strategy
W/L/T/PnL. - Includes
MANUAL(rest)andTOTALrows for attribution.
- Strategy selector shows per-strategy
- Chart fill markers
- Shows historical
B/Smarkers mapped by symbol/timeframe. - Keeps marker display simple (
B/Sonly).
- Shows historical
- Operational robustness
- Handles Binance time drift errors (
-1021) with time sync + retry. - Reduces high request-weight behavior to avoid rate-limit pressure.
- Handles Binance time drift errors (
Quick Start
- Create environment file:
- Set your Binance Spot Testnet credentials in
.env:
BINANCE_API_KEY=your_testnet_api_key_here
BINANCE_API_SECRET=your_testnet_api_secret_here
- Run:
Runtime Configuration
Edit config/default.toml as needed.
Docs In Browser
Project docs can be viewed in a browser in two ways.
- Published API docs (
docs.rs)
- Markdown docs portal (
mdBook)
- Rust API docs (
rustdoc)
Usage
Main keys:
Q: quitP: pause strategyR: resume strategyB: manual buyS: manual sellT: open symbol selectorY: open strategy selector0/1/H/D/W/M: switch timeframe (1s/1m/1h/1d/1w/1M)
Example flow:
- Start with
cargo run --bin sandbox-quant - Press
Y, choose a strategy with arrows, then Enter - Press
Bfor a manual buy - Verify
B/Smarkers on chart - Open
Yagain to review strategy stats andMANUAL(rest)
Run Capture
Terminal Screenshot
The image below summarizes a real cargo run --bin sandbox-quant session:

Raw Output
Captured run output:
docs/assets/cargo-run-output.txt
Note:
- This is a TUI app. Running in non-interactive output redirection contexts can fail terminal initialization.
- For normal usage, run directly in an interactive terminal.
Project Layout
sandbox-quant/
├── Cargo.toml
├── config/default.toml
├── docs/assets/
│ ├── cargo-run-terminal-snapshot.svg
│ └── cargo-run-output.txt
├── src/
│ ├── main.rs
│ ├── order_manager.rs
│ ├── order_store.rs
│ ├── ui/
│ └── ...
└── TESTING.md