Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-monorepo-parallel/llms.txt
Use this file to discover all available pages before exploring further.
@pro/main is the entry point hub for the monorepo. Each runtime mode — backtest, live, paper, session — is a self-contained file that gates on a specific CLI flag and early-returns if that flag is absent. Adding a new mode means adding one flag, one file, and one re-export: the Rollup config picks everything up automatically via the index.ts entry point.
The gate pattern
Every mode file inpackages/main/src/main/ follows the same structure: define an async main() function, check the required flags at the top, early-return if either is absent, then proceed with mode logic. Here is backtest.ts in full:
if/else nesting, no shared state between modes.
Flag — add the CLI option to getArgs()
Open
packages/main/src/helpers/getArgs.ts and add your new flag to the options object. The full current options object is:getArgs is wrapped with singleshot from functools-kit, so parseArgs runs exactly once regardless of how many mode files call getArgs(). The new flag is available to all mode files after this change.File — create the mode file
Create Keep the file self-contained. Import only what the analytics mode needs — do not share mutable state with other mode files.
packages/main/src/main/analytics.ts. Apply the same gate pattern as backtest.ts — check values.entry first, then check values.analytics:Export — add a side-effect import to index.ts
Open These are side-effect imports — they cause each mode file’s top-level
packages/main/src/index.ts and add an import for the new mode file. The current file is:main() call to execute when the bundle is loaded. The gate guards in each file ensure only the matching modes actually run.Build — regenerate the @pro/main bundle
Run the workspace build to pick up the new mode file via Rollup:The Rollup config uses
packages/main/src/index.ts as its entry point, so it automatically includes analytics.ts because index.ts now imports it. No Rollup configuration changes are needed.Current index.ts and mode inventory
For reference, the currentpackages/main/src/index.ts imports four modes as side effects:
getArgs() and a file under packages/main/src/main/. The table below shows the existing modes:
| Flag | File | Purpose |
|---|---|---|
--entry --backtest | backtest.ts | Parallel runner across CC_SYMBOL_LIST via Backtest.background() |
--entry --live | live.ts | Live trading mode against a real exchange |
--entry --paper | paper.ts | Paper trading mode (simulated fills, live data) |
--entry --session | session.ts | Telegram MTProto session auth (QR code) |
All mode files must use early-return guards at the top of
main() — not if/else nesting. This keeps each file independently readable: you can open analytics.ts and immediately see its guard conditions and its full logic without tracing control flow from an outer if block.