backtest-kit-redis-mongo-docker supports three execution modes —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
backtest, paper, and live — each targeting a different phase of the strategy development lifecycle. Mode selection is controlled by CLI flags passed to the Node.js process, combined with a mandatory --entry guard that prevents accidental execution. Understanding how each mode initialises the MongoDB and Redis connections, handles candle data, and dispatches orders is essential before deploying a strategy.
The --entry Guard
Every entry point (backtest.ts, live.ts, and paper.ts) begins with the same two-line guard:
--entry flag (or its Docker equivalent ENTRY=1) is not present, the function returns immediately without connecting to MongoDB or Redis and without starting any strategy loop. This design prevents a strategy bundle from executing unintentionally when it is loaded as a library or inspected in a REPL.
Backtest Mode
Backtest mode replays a fixed historical window of OHLCV candles stored in MongoDB, running the strategy against past data to evaluate performance.Guard checks
Both
--entry and --backtest must be set. The entry point returns immediately if either is missing.Service initialisation
ioc.mongoService.waitForInit() and ioc.redisService.waitForInit() establish confirmed connections to MongoDB and Redis before any data access occurs.waitForReady(true)
Passing
true signals backtest mode to the readiness layer, which may apply different pre-conditions (e.g. skipping live feed subscriptions).warmCandles()
Fetches the full historical OHLCV dataset from the exchange for the specified symbol, date range, and interval, then persists it to MongoDB. Subsequent runs reuse the cached data — set
NO_FLUSH=1 to skip the Redis flush and speed up repeated backtests.Running Backtest Locally
Running Backtest in Docker
Live Mode
Live mode connects to a real exchange and processes incoming market data in real time, executing actual orders according to the strategy logic.Live mode intentionally omits
warmCandles(). Historical candle data is not needed because the exchange provides a real-time feed. MongoDB and Redis are still initialised to persist trade records and cache active order IDs.waitForReady(false)
Passing
false signals live mode. The readiness layer may perform additional checks such as confirming exchange connectivity and API key validity.Running Live Locally
Paper Mode
Paper mode mirrors live mode in every technical respect — real-time market data, full MongoDB and Redis initialisation, and the samewaitForReady(false) readiness signal — but order execution is simulated. No real funds are used.
Running Paper Locally
The --ui Flag and Web Dashboard
Passing UI=1 (Docker) or enabling the UI flag starts the web dashboard on port 60050. The dashboard provides a visual overview of strategy state, open positions, and historical performance.
Mode Comparison
| Aspect | Backtest | Paper | Live |
|---|---|---|---|
| CLI flag | --backtest | --paper | --live |
waitForReady arg | true | false | false |
warmCandles() called | Yes | No | No |
| Data source | MongoDB (historical) | Real-time feed | Real-time feed |
| Order execution | Simulated (replay) | Simulated | Real |
frameName required | Yes | No | No |
| Financial risk | None | None | Real funds |
Local vs Docker Execution
| Aspect | Local (host Node.js) | Docker |
|---|---|---|
| Command | npm run start -- --entry --backtest | npm run start:docker |
| Infrastructure | Start each service separately | docker-compose up (all services) |
| Hot reload | Yes (rebuild manually with npm run build) | No (requires image rebuild) |
| Debug | --inspect-brk available (start:debug) | Use docker logs backtest-kit-redis-mongo-docker |
| Redis/Mongo host | 127.0.0.1 / localhost | host.docker.internal |
| REPL access | npm run start:repl | Not available |
Debugging a Running Strategy
Local debug (inspect)
chrome://inspect in Google Chrome and attach to the Node.js process. Execution pauses at the first line, allowing you to set breakpoints before any strategy code runs.
Docker logs
VERBOSE=1 to your .env to increase log verbosity and surface indicator values, order decisions, and cache hit/miss statistics.