Live mode connects to a real exchange and executes the trading strategy against live market data as it arrives. The entry point isDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-redis-postgres-pgpool-docker/llms.txt
Use this file to discover all available pages before exploring further.
src/main/live.ts, which gates execution on the --entry and --live CLI flags. Because the same PostgreSQL and Redis persistence adapters that power backtest mode are used unchanged in live mode, there is no code path to swap out — only the CLI flag and the backtest boolean in context keys differ. Candles are fetched on-demand from the exchange rather than from a pre-warmed cache, and Live.background() replaces Backtest.background().
Entry Point
The full source ofsrc/main/live.ts is shown below. Notice that it imports Live instead of Backtest and warmCandles, and passes false to waitForReady to indicate live (non-backtest) operation.
Live.background() takes fewer arguments than Backtest.background() — there is no frameName because live mode has no predefined time window. The process runs indefinitely, waking on each new candle close.
Key Differences from Backtest Mode
The following aspects change between backtest and live — everything else, including the full adapter stack, the strategy code, and the database schema, remains identical.| Aspect | Backtest Mode | Live Mode |
|---|---|---|
| CLI flag | --backtest | --live |
MODE env var | backtest | live |
waitForReady param | true | false |
| Entry function | Backtest.background() | Live.background() |
| Candle source | PostgreSQL (pre-warmed) | Live exchange on-demand |
warmCandles call | Required | Not present |
| Frame required | Yes (frameName) | No |
backtest in adapters | true | false |
| Order execution | Simulated | Real |
Exchange Module
Live mode uses the sameaddExchangeSchema registration as backtest. The exchange schema is defined in modules/live.module.ts and registers the exchange name "ccxt-exchange" (resolved via ExchangeName.CCXT) backed by CCXT Binance with spot market type, rate limiting enabled, and a 60-second receive window.
getExchange call is memoized with singleshot, so the CCXT Binance instance is created once and reused for the lifetime of the process. Note that getOrderBook explicitly throws if backtest: true is passed — in live mode this guard is never triggered.
Initialization Sequence
CLI flags checked
getArgs() returns early if --entry or --live is not present. The --live, --backtest, and --paper flags are mutually independent booleans; passing --live has no effect on the others.postgresService.waitForInit()
Connects to PostgreSQL via PgBouncer/PgPool with a 15-second timeout. All adapter writes — positions, signals, notifications, sessions — land in the same tables used by backtest mode. The
backtest column value (false) partitions live records from historical ones.redisService.waitForInit()
Connects to Redis for the candle cache and notification bus. In live mode Redis still caches recently fetched candles to reduce exchange API calls across consecutive strategy ticks.
waitForReady(false)
Signals live (non-backtest) mode to backtest-kit internals. The
false argument propagates to the backtest boolean in every adapter context key.Running Live Mode
--ui flag (or UI=1 in Docker) loads the compiled strategy bundle at STRATEGY_FILE. This bundle must export the addStrategySchema call for jan_2026_strategy (or whichever StrategyName is referenced) before Live.background() runs.
Persistence in Live Mode
All 16 backtest-kit persistence adapters operate identically in live mode. There is no mode-specific adapter code — thebacktest boolean embedded in context keys is the only runtime difference.
The key partitioning works as follows:
| Adapter group | Context key includes backtest | Live value |
|---|---|---|
| Storage | Yes | false |
| Notification | Yes | false |
| Session | Yes | false |
| Recent | Yes | false |
backtest=false partition in the database, while historical backtest records are stored under backtest=true. If you need to separate live from paper records at the query level, add a secondary filter on a mode column or use separate database schemas.