The backtest-kit Redis+MongoDB Docker project supports three distinct execution modes that map directly to the three core operating states of theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
backtest-kit framework. Backtest mode replays historical OHLCV data through your strategy and writes results to MongoDB for analysis. Paper mode connects to a live exchange feed and simulates trade execution without placing real orders, letting you validate strategy behaviour in real market conditions. Live mode connects to a real exchange and submits actual orders. All three modes share the same MongoDB+Redis persistence layer and the same strategy code — only the execution engine and data source differ.
Mode selection works the same way whether you run locally or inside Docker. Locally, you pass CLI flags (--backtest, --paper, --live) together with --entry to the Node process. Inside Docker, you set the MODE environment variable to backtest, paper, or live together with ENTRY=1. Both paths are routed through the same getArgs() helper.
How getArgs() works
src/helpers/getArgs.ts uses Node’s built-in util.parseArgs to parse the process arguments at startup. It is wrapped with singleshot from functools-kit so the parsed result is computed once and memoised for the lifetime of the process.
--entry— Must always be present for any mode to run. Without it, every mode entry point returns immediately. This acts as an intentional safety gate — the process starts cleanly but executes no strategy logic.--backtest— Activates backtest mode.--paper— Activates paper trading mode.--live— Activates live trading mode.
strict: false and allowPositionals: true mean extra flags (such as the strategy file path) are accepted without errors.
- Backtest
- Paper
- Live
Backtest mode replays historical OHLCV candle data through your strategy. The full date range of candles is fetched from the exchange and stored in MongoDB before the strategy begins, preventing redundant exchange API calls and ensuring the simulation runs at maximum speed. Results — signals, positions, risk snapshots, and logs — are written to all 15 MongoDB collections via the standard persist adapters.Entry point: Startup sequence:Docker environment variables:
src/main/backtest.tsvalues.entry && values.backtest— both guards must pass or the function returns immediately.mongoService.waitForInit()andredisService.waitForInit()— await successful connections to both infrastructure services before proceeding.waitForReady(true)— passestrueto signal backtest mode, initialising all 15 persist adapters in their backtest configuration.warmCandles(...)— fetches all 1-minute OHLCV candles for the configured symbol and date range from the exchange and stores them in thecandle-itemsMongoDB collection. Subsequent adapter reads during the simulation are served from this local cache.Backtest.background(symbol, context)— starts the backtest engine asynchronously, replaying candles through the strategy.
warmCandles: prefetching OHLCV data for backtests
Before the backtest simulation begins, backtest-kit’s warmCandles function is called to fetch the entire OHLCV candle history for the configured date range and store it in the candle-items MongoDB collection. This pre-population step is unique to backtest mode — paper and live modes consume candles from the exchange’s real-time stream instead.
| Field | Description |
|---|---|
exchangeName | The exchange adapter to fetch candles from (e.g. ExchangeName.CCXT). |
from | Start of the historical date range (inclusive). |
to | End of the historical date range (inclusive). |
interval | Candle interval string, e.g. "1m", "5m", "1h". |
symbol | Trading pair symbol to fetch, e.g. "TRXUSDT". |
warmCandles completes, every subsequent candle read during the simulation is served from the local MongoDB candle-items collection via the CandleDbService / CandleCacheService stack (O(1) Redis lookup → O(1) Mongo by _id). This eliminates redundant exchange API calls during the backtest replay loop and significantly reduces simulation time for large date ranges.
The web UI is available on port 60050 in all three modes. Set
UI=1 in your environment (or in .env) to enable it, whether running locally or inside Docker. The UI provides a real-time dashboard showing signals, open positions, equity curves, and strategy logs — useful for monitoring paper and live runs as well as inspecting backtest results after the simulation completes.