TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-monorepo-parallel/llms.txt
Use this file to discover all available pages before exploring further.
packages/main/src/index.ts file re-exports all four entry-point modules in a fixed order — session, backtest, live, paper — so they are all evaluated on every startup. Each module wraps its logic in a local main() async function and guards execution with early-return checks against the parsed CLI flags. Only the module whose flags match proceeds past the guard; the others return immediately without side effects.
@pro/main is loaded by config/loader.config.ts alongside @pro/core before strategy files are executed. This ensures that the globalThis.core DI container is fully populated — all services, Mongo models, and Redis connections ready — before any addStrategySchema, addExchangeSchema, or addFrameSchema call lands.backtest.ts — --backtest --entry
The backtest entry point is the most feature-rich module. It gates on both --entry and --backtest, waits for the full backtest infrastructure (Mongo + Redis) to be ready, optionally pre-warms candle data, then launches one Backtest.background runner per symbol in CC_SYMBOL_LIST.
Guards and startup sequence
Flag gate
Returns immediately if either
--entry or --backtest is absent. Without --entry, the @backtest-kit/cli runner handles the strategy file directly (Mode B, single-symbol).waitForReady(true)
Calls
waitForReady(true), passing true to signal backtest mode. This resolves once Mongo is connected and all schema collections are initialized.Schema validation
Calls
listStrategySchema(), listExchangeSchema(), and listFrameSchema() in sequence. Each returns the array of registered schemas; if the first element is falsy, the module throws rather than proceeding with an incomplete configuration.Optional cache warm-up
If
--cache is set, calls CACHE_CANDLES_FN(), which iterates CC_SYMBOL_LIST and calls cacheCandles({ exchangeName, from, to, interval: '1m', symbol }) for every symbol using the registered frame’s startDate / endDate. This ensures the hot loop never blocks on ccxt HTTP.Full source
live.ts — --live --entry
The live entry point starts real-money trading across all symbols in CC_SYMBOL_LIST. The structure mirrors backtest.ts but omits the frame schema (live trading has no time window) and the cache step.
Guards and startup sequence
waitForReady(false)
Calls
waitForReady(false), passing false to signal live mode. All durable Mongo adapters are used; see config/setup.config.ts for the persistence matrix.Schema validation
Calls
listStrategySchema() and listExchangeSchema(). Throws if either is missing. No frame schema is required for live mode.Full source
paper.ts — --paper --entry
The paper entry point is structurally identical to live.ts. It checks --paper instead of --live, but calls the same Live.background function — paper mode is a runtime-level flag on the @backtest-kit/cli side, not a different code path in @pro/main.
Full source
session.ts — --session
The session module handles one-time Telegram MTProto authentication via QR code. It does not require --entry — it checks only its own flag and runs independently of the trading modes. After a successful QR scan and optional 2FA prompt, it writes the session string to ./session.txt so subsequent --live or --paper runs can authenticate without user interaction.
Startup sequence
TelegramClient setup
Constructs a
TelegramClient with a blank StringSession(''), using CC_TELEGRAM_API_ID and CC_TELEGRAM_API_HASH from config/params.ts. The client is configured with five connection retries and spoofs Windows 10 / Desktop as the device model.QR code display
Calls
client.signInUserWithQrCode(...). The qrCode callback generates a tg://login?token=… URL and renders it in the terminal via qrcode-terminal. The user scans with the Telegram app under Settings → Devices → Link Desktop Device.Optional 2FA prompt
The
password callback opens a readline interface and prompts for the 2FA password if the account has one set.