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 atDocumentation 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.
http://localhost:60050 showing signals, logs, and performance metrics written atomically to MongoDB and cached in Redis.
Clone and install
Clone the repository and install dependencies:The project uses Rollup to compile your strategy bundle and
@backtest-kit/cli as the runtime entrypoint — both are installed automatically.Configure environment
Copy the example environment file and review the two variables it sets:Contents of
If you are running Node directly on the host (not inside Docker), you can omit the
.env.example:| Variable | Purpose |
|---|---|
CC_REDIS_HOST | Hostname 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_STRING | Full MongoDB connection string including the database name and a write-timeout. The wtimeoutMS=15000 guard prevents indefinite hangs on slow writes. |
.env file entirely — src/config/params.ts applies the following defaults:| Variable | Default |
|---|---|
CC_REDIS_HOST | 127.0.0.1 |
CC_REDIS_PORT | 6379 |
CC_REDIS_USER | default |
CC_REDIS_PASSWORD | mysecurepassword |
CC_MONGO_CONNECTION_STRING | mongodb://localhost:27017/backtest-pro?wtimeoutMS=15000 |
Start infrastructure
Start MongoDB and Redis as background containers:This brings up:
- MongoDB Community Server 8.0.4 (
mongodb/mongodb-community-server:8.0.4-ubi8) on port27017— data persisted todocker/mongodb/mongo_data/ - Redis 7.4.1 on port
6379— passwordmysecurepassword, data persisted todocker/redis/redis_data/
restart: always, so they survive host reboots automatically. Verify they are running with docker ps before proceeding.Run a backtest
Build the strategy bundle and launch the backtest runner:Flag and argument reference:
To run in paper or live mode instead, replace
| Flag / Argument | Effect |
|---|---|
--entry | Activates the runner. Without this flag the process exits immediately (safety guard). |
--backtest | Selects backtest mode — historical candle data is used. |
--ui | Enables the web interface on port 60050. |
./build/index.cjs | Positional argument: path to the compiled strategy bundle (produced by the npm run build step embedded in npm run start). |
--backtest with --paper or --live:Open the web UI
Once the runner has initialised, open the dashboard in your browser: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.
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.
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.