Skip to main content

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.

This guide walks you through cloning the project, starting the MongoDB and Redis infrastructure containers, and executing a backtest against the January 2026 TRX/USDT 1-minute candle dataset. The entire flow — from a clean machine to a running backtest with a live web dashboard — takes under five minutes.
Every run mode (--backtest, --paper, --live) requires the --entry flag to be present on the command line. Without --entry, the process exits immediately so the compiled bundle can be safely imported as a library without triggering side effects. The --ui flag enables the web dashboard on port 60050.

Steps

1

Verify prerequisites

Confirm the following tools are available on your machine before continuing.
ToolMinimum versionCheck command
Node.js18.xnode --version
npm9.xnpm --version
Docker24.xdocker --version
docker-compose2.xdocker compose version
Docker must be running and your user must have permission to manage containers without sudo.
2

Clone the repository and install dependencies

Clone the project from GitHub and install all Node.js dependencies in one go.
git clone https://github.com/tripolskypetr/backtest-kit-redis-mongo-docker.git
cd backtest-kit-redis-mongo-docker
npm install
The install step pulls backtest-kit, @backtest-kit/cli, mongoose, ioredis, di-factory, and functools-kit from the npm registry.
3

Configure environment variables

Copy the provided example file and open it in your editor.
cp .env.example .env
The default values target services running on the Docker host network and work without modification if you start MongoDB and Redis using the bundled compose files in the next two steps.
CC_REDIS_HOST=host.docker.internal
CC_MONGO_CONNECTION_STRING=mongodb://host.docker.internal:27017/backtest-kit?wtimeoutMS=15000
CC_REDIS_HOST — Hostname or IP address of the Redis server. When running under Docker, host.docker.internal resolves to the host machine, allowing the container to reach a Redis instance started with the bundled docker/redis/docker-compose.yaml.CC_MONGO_CONNECTION_STRING — Full MongoDB connection URI including the database name (backtest-kit) and a write-timeout hint (wtimeoutMS=15000). Replace host.docker.internal with a remote hostname if you are targeting an existing MongoDB deployment.
Additional Redis credentials (CC_REDIS_PORT, CC_REDIS_USER, CC_REDIS_PASSWORD) default to 6379, default, and mysecurepassword respectively. Override them in .env if your Redis instance uses different settings.
4

Start MongoDB

Launch the MongoDB community server container in detached mode.
docker-compose -f docker/mongodb/docker-compose.yaml up -d
This starts mongodb/mongodb-community-server:8.0.4-ubi8 on port 27017 and persists data to docker/mongodb/mongo_data on the host. The container is configured with restart: always so it survives host reboots.Verify the container is healthy:
docker ps --filter name=mongodb
5

Start Redis

Launch the Redis container in detached mode.
docker-compose -f docker/redis/docker-compose.yaml up -d
This starts redis:7.4.1 on port 6379 with password authentication (mysecurepassword) and persists the RDB snapshot to docker/redis/redis_data on the host.Verify the container is healthy:
docker ps --filter name=redis
The default Redis password is mysecurepassword. Change the REDIS_PASSWORD value in docker/redis/docker-compose.yaml and the corresponding CC_REDIS_PASSWORD value in your .env file before exposing Redis to a non-local network.
6

Run your first backtest

Build the TypeScript source and start the backtest runner with the web dashboard enabled.
npm run start -- --entry --backtest --ui ./build/index.cjs
The npm run start script runs rollup -c to produce ./build/index.cjs, then hands off to @backtest-kit/cli. The flags break down as follows:
FlagEffect
--entryRequired. Activates the entry-point guard so main() actually executes
--backtestSelects backtest mode; triggers warmCandles and Backtest.background
--uiEnables the web dashboard on port 60050
./build/index.cjsPath to the compiled strategy bundle passed to the CLI
The runner will:
  1. Wait for MongoDB and Redis to confirm their connections via waitForInit()
  2. Wait for backtest-kit internal services to signal readiness via waitForReady(true)
  3. Warm the January 2026 TRX/USDT 1-minute candle dataset into MongoDB
  4. Execute Backtest.background("TRXUSDT", { ... }) and stream results to MongoDB in real time
7

Open the web dashboard

Once the runner logs Backtest started, open your browser to the dashboard.
http://localhost:60050
The dashboard provides a live view of open signals, partial fills, risk events, equity curves, and raw logs — all sourced directly from MongoDB via the running adapter layer.
Port 60050 is the default for the backtest-kit web UI. If that port is already in use, stop the conflicting process or map a different host port by setting the ports field in docker-compose.yaml.

Paper Trading Mode

Paper mode runs the strategy against the live exchange feed without placing real orders. All signals, risk events, and state snapshots are persisted to MongoDB identically to live mode, making paper runs a reliable pre-deployment validation step.
npm run start -- --entry --paper --ui ./build/index.cjs
The runner calls waitForReady(false) in paper mode (no historical warm-up) and starts Live.background immediately after the services initialise.

Live Trading Mode

Live mode connects to the configured exchange and places real orders. Ensure your API credentials are set in .env and that the strategy has passed a full paper-trading validation cycle before switching to this mode.
npm run start -- --entry --live --ui ./build/index.cjs
Live mode places real orders on the exchange. Double-check your API key permissions and position sizing parameters before running. MongoDB state is authoritative across restarts — a clean --no-flush flag will retain all open positions and signals from the previous session.

Build docs developers (and LLMs) love