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.

All runtime behaviour in backtest-kit-redis-mongo-docker is controlled through environment variables. Infrastructure connection settings (Redis host, MongoDB URI, etc.) are read once at startup from src/config/params.ts and defaulted to localhost values suitable for local development. Container runtime variables control the backtest-kit CLI mode, strategy selection, and optional integrations. A .env file at the project root is used by both the CLI toolchain and Docker Compose.

Infrastructure Configuration

The following variables are defined in src/config/params.ts:
declare function parseInt(value: unknown): number;

export const CC_REDIS_HOST = process.env.CC_REDIS_HOST || "127.0.0.1";
export const CC_REDIS_PORT = parseInt(process.env.CC_REDIS_PORT) || 6379;
export const CC_REDIS_USER = process.env.CC_REDIS_USER || "default";
export const CC_REDIS_PASSWORD = process.env.CC_REDIS_PASSWORD || "mysecurepassword";

export const CC_MONGO_CONNECTION_STRING =
  process.env.CC_MONGO_CONNECTION_STRING ||
  "mongodb://localhost:27017/backtest-pro?wtimeoutMS=15000";
CC_REDIS_HOST
string
default:"127.0.0.1"
Hostname or IP address of the Redis server. When running inside Docker and connecting to a Redis instance on the host machine, use host.docker.internal instead of 127.0.0.1.
CC_REDIS_PORT
number
default:"6379"
TCP port on which Redis is listening. The value is parsed with parseInt; non-numeric values fall back to 6379.
CC_REDIS_USER
string
default:"default"
Redis ACL username. The value "default" corresponds to the built-in Redis user that is active when no explicit ACL configuration is present.
CC_REDIS_PASSWORD
string
default:"mysecurepassword"
Redis authentication password. The default value matches the password configured in the reference Docker Compose setup. Change this in production.
CC_MONGO_CONNECTION_STRING
string
Full Mongoose connection URI including database name and query parameters. The wtimeoutMS=15000 parameter sets a 15-second write concern timeout. When connecting from inside a Docker container to a MongoDB instance on the host, replace localhost with host.docker.internal.

.env.example

The project ships an .env.example file showing the values required when the application runs inside Docker and connects to services on the host machine:
CC_REDIS_HOST=host.docker.internal
CC_MONGO_CONNECTION_STRING=mongodb://host.docker.internal:27017/backtest-kit?wtimeoutMS=15000
Copy .env.example to .env and adjust as needed. The dotenv-cli dev dependency loads this file automatically when using npm run start:repl. Docker Compose loads it via the env_file: .env directive. When to use host.docker.internal vs 127.0.0.1:
ScenarioHost value
Running directly on the host (CLI, npm start)127.0.0.1 (default)
Running inside Docker, services on hosthost.docker.internal
All services in the same Docker Compose networkService name (e.g. redis, mongo)

Container Runtime Variables

These variables are forwarded into the container via the environment section of docker-compose.yaml:
environment:
  - MODE
  - STRATEGY_FILE
  - SYMBOL
  - STRATEGY
  - EXCHANGE
  - FRAME
  - UI
  - TELEGRAM
  - VERBOSE
  - NO_CACHE
  - NO_FLUSH
  - ENTRY
VariableDescription
MODEExecution mode — e.g. backtest, live, paper
STRATEGY_FILEPath to the compiled strategy bundle (e.g. ./build/index.cjs)
SYMBOLTrading symbol to run against (e.g. TRXUSDT)
STRATEGYStrategy name identifier
EXCHANGEExchange name identifier
FRAMEFrame name identifier
UISet to 1 to enable the backtest-kit web UI on port 60050
TELEGRAMSet to 1 to enable Telegram notifications
VERBOSESet to 1 for verbose logging output
NO_CACHESet to 1 to disable Redis cache reads on startup
NO_FLUSHSet to 1 to skip flushing Redis keys on startup
ENTRYSet to 1 to trigger the entry script in src/main/

npm Scripts

ScriptCommandDescription
buildrollup -cCompiles TypeScript source to ./build/index.cjs using the Rollup config
startnpm run build && node ./node_modules/@backtest-kit/cli/build/index.mjsBuilds then starts the backtest-kit CLI
start:debugnpm run build && node --inspect-brk ./node_modules/@backtest-kit/cli/build/index.mjsBuilds then starts the CLI with the Node.js inspector paused at the first line — attach a debugger before execution continues
start:repldotenv -e .env -- npm run build && node -e "require('./build/index.cjs')" --interactiveBuilds then opens an interactive Node.js REPL with the bundle pre-loaded and .env applied
start:dockernpm run build && cross-env MODE=backtest ENTRY=1 UI=1 STRATEGY_FILE=./build/index.cjs docker-compose up -dBuilds and launches the full Docker Compose stack in detached mode with backtest mode, entry, and UI enabled
stop:dockerdocker-compose downStops and removes the Docker Compose stack

Docker Compose Service

The docker-compose.yaml defines a single backtest service:
version: '3.8'

services:
  backtest:
    image: tripolskypetr/backtest-kit
    platform: linux/amd64
    extra_hosts:
      - "host.docker.internal:host-gateway"
    container_name: backtest-kit-redis-mongo-docker
    ports:
      - "60050:60050"
    restart: unless-stopped
    volumes:
      - ./:/workspace
    working_dir: /workspace
    environment:
      - MODE
      - STRATEGY_FILE
      - SYMBOL
      - STRATEGY
      - EXCHANGE
      - FRAME
      - UI
      - TELEGRAM
      - VERBOSE
      - NO_CACHE
      - NO_FLUSH
      - ENTRY
    env_file:
      - .env
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:60050/api/v1/health/health_check"]
      interval: 30s
      timeout: 10s
      retries: 3
Key points:
  • extra_hosts — maps host.docker.internal to the host gateway so the container can reach MongoDB and Redis running on the host machine.
  • Port 60050 — the backtest-kit web UI is exposed on this port.
  • Volume mount — the entire project directory is mounted at /workspace so the container runs the locally-built ./build/index.cjs without rebuilding the image.
  • Healthcheck — polls the /api/v1/health/health_check endpoint every 30 seconds.

Build docs developers (and LLMs) love