Skip to main content

Documentation 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.

This guide walks you through cloning the repository, configuring your environment, starting the MongoDB and Redis containers, and running your first backtest against the production persistence layer — all in under five minutes. By the end you will have a live web UI at http://localhost:60050 showing signals, logs, and performance metrics written atomically to MongoDB and cached in Redis.
1

Clone and install

Clone the repository and install dependencies:
git clone https://github.com/tripolskypetr/backtest-kit.git
cd backtest-kit/backtest-kit-redis-mongo-docker
npm install
The project uses Rollup to compile your strategy bundle and @backtest-kit/cli as the runtime entrypoint — both are installed automatically.
2

Configure environment

Copy the example environment file and review the two variables it sets:
cp .env.example .env
Contents of .env.example:
CC_REDIS_HOST=host.docker.internal
CC_MONGO_CONNECTION_STRING=mongodb://host.docker.internal:27017/backtest-kit?wtimeoutMS=15000
VariablePurpose
CC_REDIS_HOSTHostname of the Redis server. host.docker.internal resolves to the Docker host, allowing a containerised strategy to reach Redis running on the host machine.
CC_MONGO_CONNECTION_STRINGFull MongoDB connection string including the database name and a write-timeout. The wtimeoutMS=15000 guard prevents indefinite hangs on slow writes.
If you are running Node directly on the host (not inside Docker), you can omit the .env file entirely — src/config/params.ts applies the following defaults:
VariableDefault
CC_REDIS_HOST127.0.0.1
CC_REDIS_PORT6379
CC_REDIS_USERdefault
CC_REDIS_PASSWORDmysecurepassword
CC_MONGO_CONNECTION_STRINGmongodb://localhost:27017/backtest-pro?wtimeoutMS=15000
3

Start infrastructure

Start MongoDB and Redis as background containers:
docker-compose -f docker/mongodb/docker-compose.yaml up -d
docker-compose -f docker/redis/docker-compose.yaml up -d
This brings up:
  • MongoDB Community Server 8.0.4 (mongodb/mongodb-community-server:8.0.4-ubi8) on port 27017 — data persisted to docker/mongodb/mongo_data/
  • Redis 7.4.1 on port 6379 — password mysecurepassword, data persisted to docker/redis/redis_data/
Both services are configured with restart: always, so they survive host reboots automatically. Verify they are running with docker ps before proceeding.
4

Run a backtest

Build the strategy bundle and launch the backtest runner:
npm run start -- --entry --backtest --ui ./build/index.cjs
Flag and argument reference:
Flag / ArgumentEffect
--entryActivates the runner. Without this flag the process exits immediately (safety guard).
--backtestSelects backtest mode — historical candle data is used.
--uiEnables the web interface on port 60050.
./build/index.cjsPositional argument: path to the compiled strategy bundle (produced by the npm run build step embedded in npm run start).
To run in paper or live mode instead, replace --backtest with --paper or --live:
# Paper mode
npm run start -- --entry --paper --ui ./build/index.cjs

# Live mode
npm run start -- --entry --live --ui ./build/index.cjs
5

Open the web UI

Once the runner has initialised, open the dashboard in your browser:
http://localhost:60050
The web UI (served by @backtest-kit/ui) provides real-time views of signals, strategy logs, and performance metrics — all sourced from the MongoDB + Redis persistence layer you just configured. The healthcheck endpoint at /api/v1/health/health_check can be polled by external monitors to confirm the process is live.

Full Docker Deploy

For a fully containerised setup — strategy, runner, and the @backtest-kit/cli container bundled together — use the root docker-compose.yaml. It reads MODE, ENTRY, UI, and STRATEGY_FILE from environment variables and uses extra_hosts: host.docker.internal:host-gateway so the container can reach MongoDB and Redis on the host.
# Start (builds the strategy bundle first, then launches the stack)
npm run start:docker

# Stop
npm run stop:docker
The MODE variable accepts backtest, paper, or live. ENTRY=1 and UI=1 correspond to the --entry and --ui CLI flags respectively. STRATEGY_FILE points to the compiled bundle — the default is ./build/index.cjs.
Use docker-compose logs -f to follow live output from all containers in the stack. For a single service, add the service name — for example docker-compose logs -f redis — to isolate Redis logs during connection troubleshooting.
This quickstart uses default credentials and a single-node setup suitable for local development. See the Architecture Overview page for a deep dive into atomicity guarantees and the Redis O(1) cache pattern, and the Deployment page for production configuration including custom credentials, replica sets, and Redis Sentinel.

Build docs developers (and LLMs) love