Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-postgres-pgpool-docker/llms.txt

Use this file to discover all available pages before exploring further.

Every runtime behaviour of the persistence layer is controlled by environment variables — there are no config files to edit. Two groups of variables exist: connection variables read by the TypeScript adapter layer (src/config/params.ts), and container variables consumed by @backtest-kit/cli when running the strategy inside Docker. Both groups can be supplied together in a single .env file at the project root. The schema is created automatically on first connect via TypeORM synchronize: true, so there is no manual migration step — all tables, unique indexes, and jsonb columns appear the moment the app boots against an empty database.

Connection Variables

These five variables are read by src/config/params.ts and passed directly to ioredis and the TypeORM DataSource. They are the only settings needed when running Node on the host (non-Docker) with the database containers running separately.
CC_REDIS_HOST
string
default:"127.0.0.1"
Hostname or IP address of the Redis server. Use 127.0.0.1 when Redis is running on the host machine. When running the strategy inside Docker, change this to host.docker.internal so the container can reach the host network through the extra_hosts gateway defined in docker-compose.yaml.
CC_REDIS_PORT
number
default:"6379"
TCP port that Redis listens on. The bundled docker/redis/docker-compose.yaml publishes port 6379 to the host, so the default value works without changes in both local and Docker deployments.
CC_REDIS_USER
string
default:"default"
Redis ACL username. Redis 6+ supports multiple users; the built-in superuser is always named default. Leave this unchanged unless you have created a dedicated ACL user in your Redis configuration.
CC_REDIS_PASSWORD
string
default:"mysecurepassword"
Password passed to Redis via the AUTH command. The bundled Redis compose file starts the server with --requirepass mysecurepassword, so the default matches out of the box. Change both values together when hardening for production.
CC_POSTGRES_CONNECTION_STRING
string
Full libpq-style connection URL consumed by the TypeORM DataSource. The format is postgres://<user>:<password>@<host>:<port>/<database>. When running inside Docker, replace localhost with host.docker.internal. Point this at the Pgpool-II port (5432) rather than directly at a replica to ensure writes always reach the primary.
The .env.example at the project root already contains the Docker-friendly values (host.docker.internal) — copy it to .env when running the strategy container and the defaults will work without further edits.

Container Variables

These variables are consumed by @backtest-kit/cli inside the tripolskypetr/backtest-kit Docker image. They are passed through the environment: block of the main docker-compose.yaml and override the equivalent CLI flags.

Execution Control

MODE
string
Selects the run mode for the strategy container. Must be one of backtest, live, or paper. Maps directly to the --backtest, --live, and --paper CLI flags. There is no default — the container will not start a strategy run unless MODE is explicitly set.
ENTRY
string
Set to 1 to actually execute the strategy. Mirrors the --entry CLI flag. Omitting this variable (or setting it to any value other than 1) leaves the container running but idle, which is useful for inspecting the filesystem or running one-off commands inside the container without triggering a live trade.
STRATEGY_FILE
string
default:"./build/index.cjs"
Path to the compiled strategy bundle that the CLI should load, resolved relative to /workspace inside the container (the project root is bind-mounted there). Change this if your build output is placed in a non-standard location.

Strategy Context Overrides

SYMBOL
string
Override the trading symbol (e.g. BTCUSDT). When set, this value replaces whatever symbol is hard-coded in the strategy entry-point.
STRATEGY
string
Override the strategy name identifier used for database context keying.
EXCHANGE
string
Override the exchange name identifier (e.g. the registered CCXT adapter name).
FRAME
string
Override the frame name that scopes the session and recent-signal lookups.
The four context overrides (SYMBOL, STRATEGY, EXCHANGE, FRAME) are optional. If omitted, the values baked into the compiled strategy bundle at build time are used.

Feature Flags

UI
string
Set to 1 to enable the backtest-kit web UI on port :60050. The main docker-compose.yaml publishes that port to the host, so you can open http://localhost:60050 in a browser once the container is healthy. The healthcheck also polls this endpoint.
TELEGRAM
string
Set to 1 to enable Telegram notifications for signal events. Requires the Telegram bot credentials to be configured inside the strategy bundle.
VERBOSE
string
Set to 1 to enable verbose logging. Equivalent to the --verbose CLI flag. Useful for debugging adapter calls and Redis cache hit/miss ratios.
NO_CACHE
string
Set to 1 to disable the Redis O(1) ID cache. All reads fall back to full PostgreSQL SELECT queries. Use this to rule out stale-cache issues during debugging, not in normal operation.
NO_FLUSH
string
Set to 1 to skip the flush-on-start routine. By default the CLI clears in-progress state on startup; setting this flag preserves existing database rows across restarts, which is useful when resuming a long backtest run.

.env.example Reference

The repository ships a ready-to-use example file. Copy it to .env before running the Docker compose stack:
cp .env.example .env
# .env.example — Docker-friendly defaults
# Replace host.docker.internal with 127.0.0.1 when running Node directly on the host.

CC_REDIS_HOST=host.docker.internal
CC_POSTGRES_CONNECTION_STRING=postgres://backtest:mysecurepassword@host.docker.internal:5432/backtest-pro
The example deliberately omits CC_REDIS_PORT, CC_REDIS_USER, and CC_REDIS_PASSWORD because the in-code defaults already match the bundled Redis compose file. Add them explicitly only when connecting to a Redis instance with different credentials or a non-standard port.
Never commit a .env file with real credentials to version control. The repository’s .gitignore excludes .env but not .env.example — keep production secrets out of the example file as well.

Local vs. Docker Quick Reference

VariableRunning Node on hostRunning strategy in Docker
CC_REDIS_HOST127.0.0.1host.docker.internal
CC_POSTGRES_CONNECTION_STRING host partlocalhosthost.docker.internal
ENTRYCLI --entry flagENTRY=1 in env
MODECLI --backtest / --live / --paperMODE=backtest in env
The TypeORM DataSource is initialised with synchronize: true and logging: false. On every cold start, TypeORM inspects the live database schema and runs CREATE TABLE IF NOT EXISTS plus CREATE UNIQUE INDEX IF NOT EXISTS statements for any entities that are missing. This means:
  • First run against an empty database: all 16 tables are created automatically.
  • Subsequent runs: no DDL is executed; startup is fast.
  • Schema changes in development: adding a column to an entity schema file is enough — TypeORM will ALTER TABLE on next boot.
For production environments where DDL must be gated, disable synchronize and generate a migration with typeorm migration:generate instead.

Build docs developers (and LLMs) love