Running a live trading bot in Docker gives you zero-downtime operation, automatic restarts on crashes, and a clean separation between your strategy code and the host machine. Backtest Kit’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
@backtest-kit/cli --docker flag scaffolds a self-contained workspace — complete with a docker-compose.yaml, a strategy entry point, and a healthcheck endpoint — so you can go from a local backtest to a containerized live bot without writing any infrastructure code yourself.
Quick Setup
Generate the Docker workspace with a single CLI command, then start your bot with the desired symbol and strategy file:--docker flag creates a backtest-kit-docker/ directory (override with --output) containing:
The
docker-compose.yaml includes a healthcheck stanza against http://localhost:60050/api/v1/health/health_check. The container is considered healthy only after the strategy process passes this check, preventing dependent services from starting prematurely.Environment Variables
Three environment variables control the bot’s runtime behaviour:| Variable | Required | Values | Description |
|---|---|---|---|
MODE | Yes | live, backtest, paper | Execution mode. Use paper to validate against live prices without placing real orders. |
SYMBOL | Yes | e.g. TRXUSDT, BTCUSDT | Trading pair passed to the strategy. |
STRATEGY_FILE | Yes | path inside the container | Entry-point TypeScript file for the strategy. |
| Variable | Required | Description |
|---|---|---|
BINANCE_API_KEY | Live mode | Binance API key with trading permissions. |
BINANCE_API_SECRET | Live mode | Binance API secret corresponding to the key. |
.env file:
Auto-Restart on Crash
The generateddocker-compose.yaml includes restart: always, which tells Docker to restart the container automatically whenever the process exits — whether due to a network error, an unhandled exception, or a host reboot:
./dump/ directory (or MongoDB, if configured) before the strategy resumes ticking.
Running Multiple Symbols in Parallel
For multi-symbol deployments,@backtest-kit/cli supports a Multiple Symbol Parallel mode. Use the --entry flag to point the CLI at your own entry file where you call Backtest.background() or Live.background() for each symbol:
Production Persistence with MongoDB and Redis
By default, Backtest Kit persists state to the local./dump/ file tree. In production Docker deployments, file-based storage can be a reliability concern — container restarts may lose data if the volume is not mounted correctly, and concurrent writes under multiple symbols can create race conditions.
The @backtest-kit/mongo package replaces all 15 persistence adapters with MongoDB as the source of truth and Redis as an O(1) lookup cache. Drop a single config/setup.config.ts into your project:
docker-compose.yaml that wires MongoDB, Redis, and the Backtest Kit container together, see the community repository:
backtest-kit-redis-mongo-docker
Production MongoDB + Redis + Docker stack with all 15 persistence adapters implemented, atomic
findOneAndUpdate writes, O(1) Redis cache lookups, and a ready-to-run docker-compose.yaml. Drop-in upgrade for any Backtest Kit project that outgrows file-based storage.