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 (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.
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 bysrc/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.
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.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.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.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.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
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.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.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
Override the trading symbol (e.g.
BTCUSDT). When set, this value replaces
whatever symbol is hard-coded in the strategy entry-point.Override the strategy name identifier used for database context keying.
Override the exchange name identifier (e.g. the registered CCXT adapter name).
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
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.Set to
1 to enable Telegram notifications for signal events. Requires the
Telegram bot credentials to be configured inside the strategy bundle.Set to
1 to enable verbose logging. Equivalent to the --verbose CLI flag.
Useful for debugging adapter calls and Redis cache hit/miss ratios.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.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:
Local vs. Docker Quick Reference
| Variable | Running Node on host | Running strategy in Docker |
|---|---|---|
CC_REDIS_HOST | 127.0.0.1 | host.docker.internal |
CC_POSTGRES_CONNECTION_STRING host part | localhost | host.docker.internal |
ENTRY | CLI --entry flag | ENTRY=1 in env |
MODE | CLI --backtest / --live / --paper | MODE=backtest in env |
How TypeORM synchronize works
How TypeORM synchronize works
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 TABLEon next boot.
synchronize
and generate a migration with typeorm migration:generate instead.