@backtest-kit/cli 9.1.1 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.mjs CHANGED
@@ -867,6 +867,7 @@ class BacktestMainService {
867
867
  this.frontendProviderService = inject(TYPES.frontendProviderService);
868
868
  this.telegramProviderService = inject(TYPES.telegramProviderService);
869
869
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
870
+ this.configConnectionService = inject(TYPES.configConnectionService);
870
871
  this.run = singleshot(async (payload) => {
871
872
  this.loggerService.log("backtestMainService run", {
872
873
  payload,
@@ -879,9 +880,14 @@ class BacktestMainService {
879
880
  this.frontendProviderService.connect();
880
881
  this.telegramProviderService.connect();
881
882
  }
883
+ {
884
+ const cwd = process.cwd();
885
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
886
+ }
887
+ await this.configConnectionService.loadConfig("setup.config");
882
888
  {
883
889
  await this.resolveService.attachJavascript(payload.entryPoint);
884
- await this.moduleConnectionService.loadModule("./backtest.module");
890
+ await this.moduleConnectionService.loadModule("backtest.module");
885
891
  }
886
892
  {
887
893
  this.exchangeSchemaService.addSchema();
@@ -982,6 +988,7 @@ class WalkerMainService {
982
988
  this.symbolSchemaService = inject(TYPES.symbolSchemaService);
983
989
  this.cacheLogicService = inject(TYPES.cacheLogicService);
984
990
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
991
+ this.configConnectionService = inject(TYPES.configConnectionService);
985
992
  this.run = singleshot(async (payload) => {
986
993
  this.loggerService.log("walkerMainService run", { payload });
987
994
  {
@@ -1017,7 +1024,12 @@ class WalkerMainService {
1017
1024
  Cache.resetCounter();
1018
1025
  Interval.resetCounter();
1019
1026
  }
1020
- await this.moduleConnectionService.loadModule("./walker.module");
1027
+ {
1028
+ const cwd = process.cwd();
1029
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1030
+ }
1031
+ await this.configConnectionService.loadConfig("setup.config");
1032
+ await this.moduleConnectionService.loadModule("walker.module");
1021
1033
  {
1022
1034
  this.exchangeSchemaService.addSchema();
1023
1035
  this.symbolSchemaService.addSchema();
@@ -1199,6 +1211,7 @@ class LiveMainService {
1199
1211
  this.frontendProviderService = inject(TYPES.frontendProviderService);
1200
1212
  this.telegramProviderService = inject(TYPES.telegramProviderService);
1201
1213
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
1214
+ this.configConnectionService = inject(TYPES.configConnectionService);
1202
1215
  this.run = singleshot(async (payload) => {
1203
1216
  this.loggerService.log("liveMainService run", {
1204
1217
  payload,
@@ -1211,9 +1224,14 @@ class LiveMainService {
1211
1224
  this.frontendProviderService.connect();
1212
1225
  this.telegramProviderService.connect();
1213
1226
  }
1227
+ {
1228
+ const cwd = process.cwd();
1229
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1230
+ }
1231
+ await this.configConnectionService.loadConfig("setup.config");
1214
1232
  {
1215
1233
  await this.resolveService.attachJavascript(payload.entryPoint);
1216
- await this.moduleConnectionService.loadModule("./live.module");
1234
+ await this.moduleConnectionService.loadModule("live.module");
1217
1235
  }
1218
1236
  {
1219
1237
  this.exchangeSchemaService.addSchema();
@@ -1281,6 +1299,7 @@ class PaperMainService {
1281
1299
  this.frontendProviderService = inject(TYPES.frontendProviderService);
1282
1300
  this.telegramProviderService = inject(TYPES.telegramProviderService);
1283
1301
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
1302
+ this.configConnectionService = inject(TYPES.configConnectionService);
1284
1303
  this.run = singleshot(async (payload) => {
1285
1304
  this.loggerService.log("paperMainService init");
1286
1305
  {
@@ -1291,9 +1310,14 @@ class PaperMainService {
1291
1310
  this.frontendProviderService.connect();
1292
1311
  this.telegramProviderService.connect();
1293
1312
  }
1313
+ {
1314
+ const cwd = process.cwd();
1315
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1316
+ }
1317
+ await this.configConnectionService.loadConfig("setup.config");
1294
1318
  {
1295
1319
  await this.resolveService.attachJavascript(payload.entryPoint);
1296
- await this.moduleConnectionService.loadModule("./paper.module");
1320
+ await this.moduleConnectionService.loadModule("paper.module");
1297
1321
  }
1298
1322
  {
1299
1323
  this.exchangeSchemaService.addSchema();
@@ -2553,7 +2577,7 @@ class BabelService {
2553
2577
  const IMPORT_ALIAS = {};
2554
2578
 
2555
2579
  const USE_ESMODULE_DEFAULT = false;
2556
- const IMPORT_PATHS_EXCLUDE = new Set(["dump", "logs", "modules", "node_modules"]);
2580
+ const IMPORT_PATHS_EXCLUDE = new Set(["dump", "logs", "modules", "config", "node_modules"]);
2557
2581
  const TRANSPILE_FN = memoize(([path]) => `${path}`, (path, code, self, require) => {
2558
2582
  const __filename = self.__filename;
2559
2583
  const __dirname = self.__dirname;
@@ -2774,10 +2798,10 @@ globalThis.BacktestKitSignals = BacktestKitSignals;
2774
2798
 
2775
2799
  const GET_ALIAS_EXPORTS_FN = (self) => {
2776
2800
  const instance = self.getInstance(self.resolveService.OVERRIDE_CONFIG_DIR);
2777
- if (!instance.check("alias.module")) {
2801
+ if (!instance.check("alias.config")) {
2778
2802
  return null;
2779
2803
  }
2780
- const exports = instance.import("alias.module");
2804
+ const exports = instance.import("alias.config");
2781
2805
  return "default" in exports
2782
2806
  ? exports.default
2783
2807
  : exports;
@@ -3009,10 +3033,10 @@ init();
3009
3033
 
3010
3034
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3011
3035
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3012
- const HELP_TEXT$1 = `
3013
- Example:
3014
-
3015
- node ${ENTRY_PATH$1} --help
3036
+ const HELP_TEXT$1 = `
3037
+ Example:
3038
+
3039
+ node ${ENTRY_PATH$1} --help
3016
3040
  `.trimStart();
3017
3041
  const main$g = async () => {
3018
3042
  if (!getEntry(import.meta.url)) {
@@ -3022,7 +3046,7 @@ const main$g = async () => {
3022
3046
  if (MODES.some((mode) => values[mode])) {
3023
3047
  return;
3024
3048
  }
3025
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
3049
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n`);
3026
3050
  process.stdout.write("\n");
3027
3051
  process.stdout.write(`Run with --help to see available commands.\n`);
3028
3052
  process.stdout.write("\n");
@@ -3212,10 +3236,10 @@ const main$b = async () => {
3212
3236
  main$b();
3213
3237
 
3214
3238
  const MODE_MODULE = {
3215
- backtest: "./backtest.module",
3216
- live: "./live.module",
3217
- paper: "./paper.module",
3218
- walker: "./walker.module",
3239
+ backtest: "backtest.module",
3240
+ live: "live.module",
3241
+ paper: "paper.module",
3242
+ walker: "walker.module",
3219
3243
  };
3220
3244
  const resolveMode = (values) => {
3221
3245
  const enabled = ["backtest", "live", "paper", "walker"].filter((mode) => Boolean(values[mode]));
@@ -3314,6 +3338,11 @@ const main$a = async () => {
3314
3338
  Setup.enable();
3315
3339
  cli.frontendProviderService.connect();
3316
3340
  cli.telegramProviderService.connect();
3341
+ {
3342
+ const cwd = process.cwd();
3343
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3344
+ }
3345
+ await cli.configConnectionService.loadConfig("setup.config");
3317
3346
  await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
3318
3347
  listenFinish();
3319
3348
  createGracefulShutdown(mode)();
@@ -3398,7 +3427,12 @@ const main$7 = async () => {
3398
3427
  return;
3399
3428
  }
3400
3429
  const source = await cli.resolveService.attachPine(entryPoint);
3401
- await cli.moduleConnectionService.loadModule("./pine.module");
3430
+ {
3431
+ const cwd = process.cwd();
3432
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3433
+ }
3434
+ await cli.configConnectionService.loadConfig("setup.config");
3435
+ await cli.moduleConnectionService.loadModule("pine.module");
3402
3436
  {
3403
3437
  await cli.exchangeSchemaService.addSchema();
3404
3438
  await cli.symbolSchemaService.addSchema();
@@ -3479,7 +3513,12 @@ const main$6 = async () => {
3479
3513
  await cli.configService.waitForInit();
3480
3514
  Setup.enable();
3481
3515
  }
3482
- await cli.moduleConnectionService.loadModule("./editor.module");
3516
+ {
3517
+ const cwd = process.cwd();
3518
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3519
+ }
3520
+ await cli.configConnectionService.loadConfig("setup.config");
3521
+ await cli.moduleConnectionService.loadModule("editor.module");
3483
3522
  {
3484
3523
  await cli.exchangeSchemaService.addSchema();
3485
3524
  }
@@ -3508,7 +3547,12 @@ const main$5 = async () => {
3508
3547
  if (!values.dump) {
3509
3548
  return;
3510
3549
  }
3511
- await cli.moduleConnectionService.loadModule("./dump.module");
3550
+ {
3551
+ const cwd = process.cwd();
3552
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3553
+ }
3554
+ await cli.configConnectionService.loadConfig("setup.config");
3555
+ await cli.moduleConnectionService.loadModule("dump.module");
3512
3556
  {
3513
3557
  await cli.exchangeSchemaService.addSchema();
3514
3558
  await cli.symbolSchemaService.addSchema();
@@ -3571,7 +3615,12 @@ const main$4 = async () => {
3571
3615
  if (!values.pnldebug) {
3572
3616
  return;
3573
3617
  }
3574
- await cli.moduleConnectionService.loadModule("./pnldebug.module");
3618
+ {
3619
+ const cwd = process.cwd();
3620
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3621
+ }
3622
+ await cli.configConnectionService.loadConfig("setup.config");
3623
+ await cli.moduleConnectionService.loadModule("pnldebug.module");
3575
3624
  {
3576
3625
  await cli.exchangeSchemaService.addSchema();
3577
3626
  await cli.symbolSchemaService.addSchema();
@@ -3839,183 +3888,183 @@ const main$2 = async () => {
3839
3888
  main$2();
3840
3889
 
3841
3890
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
3842
- const HELP_TEXT = `
3843
- Usage:
3844
- node index.mjs --<mode> [flags] [entry-point]
3845
-
3846
- Modes:
3847
-
3848
- --backtest <entry> Run strategy against historical candle data
3849
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3850
- --paper <entry> Paper trading (live prices, no real orders)
3851
- --live <entry> Live trading with real orders
3852
- --pine <entry> Execute a local .pine indicator file
3853
- --editor Open the Pine Script visual editor in the browser
3854
- --dump Fetch and save raw OHLCV candles
3855
- --pnldebug Simulate PnL per minute for a given entry price and direction
3856
- --brokerdebug Fire a single broker commit against the live broker adapter
3857
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3858
- --init Scaffold a new project in the current directory
3859
- --docker Scaffold a Docker workspace for running strategies in a container
3860
- --help Print this help message
3861
-
3862
- Backtest flags:
3863
-
3864
- --symbol <string> Trading pair (default: BTCUSDT)
3865
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
3866
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3867
- --frame <string> Frame name from addFrameSchema (default: first registered)
3868
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3869
- --noCache Skip candle cache warming before the run
3870
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
3871
- --verbose Log every candle fetch to stdout
3872
- --ui Start web dashboard at http://localhost:60050
3873
- --telegram Send trade notifications to Telegram
3874
-
3875
- Walker flags (--walker):
3876
-
3877
- --symbol <string> Trading pair (default: BTCUSDT)
3878
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3879
- --noCache Skip candle cache warming before the run
3880
- --noFlush Skip removing report/log/markdown/agent folders before walker run
3881
- --verbose Log every candle fetch to stdout
3882
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3883
- --json Save results as JSON to ./dump/<output>.json
3884
- --markdown Save report as Markdown to ./dump/<output>.md
3885
-
3886
- Each positional argument is a strategy entry point. All strategy files are loaded without
3887
- changing process.cwd() — .env is read from the working directory only.
3888
- addWalkerSchema is called automatically using the registered exchange and frame.
3889
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3890
-
3891
- Module file ./modules/walker.module is loaded automatically if it exists.
3892
-
3893
- Paper / Live flags:
3894
-
3895
- --symbol <string> Trading pair (default: BTCUSDT)
3896
- --strategy <string> Strategy name (default: first registered)
3897
- --exchange <string> Exchange name (default: first registered)
3898
- --verbose Log every candle fetch to stdout
3899
- --ui Start web dashboard
3900
- --telegram Send Telegram notifications
3901
-
3902
- PineScript flags (--pine):
3903
-
3904
- --symbol <string> Trading pair (default: BTCUSDT)
3905
- --timeframe <string> Candle interval (default: 15m)
3906
- --limit <string> Number of candles to fetch (default: 250)
3907
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3908
- --exchange <string> Exchange name (default: first registered)
3909
- --output <string> Output file base name without extension
3910
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
3911
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3912
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3913
-
3914
- Only plot() calls with display=display.data_window produce output columns.
3915
- Module file ./modules/pine.module is loaded automatically if it exists.
3916
-
3917
- Candle dump flags (--dump):
3918
-
3919
- --symbol <string> Trading pair (default: BTCUSDT)
3920
- --timeframe <string> Candle interval (default: 15m)
3921
- --limit <string> Number of candles (default: 250)
3922
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3923
- --exchange <string> Exchange name (default: first registered)
3924
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3925
- --json Save as JSON array to ./dump/<output>.json
3926
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3927
-
3928
- Module file ./modules/dump.module is loaded automatically if it exists.
3929
-
3930
- PnL debug flags (--pnldebug):
3931
-
3932
- --symbol <string> Trading pair (default: BTCUSDT)
3933
- --priceopen <number> Entry price (required)
3934
- --direction <string> Position direction: long or short (default: long)
3935
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
3936
- --minutes <string> Number of 1m candles to simulate (default: 60)
3937
- --exchange <string> Exchange name (default: first registered)
3938
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3939
- --json Save as JSON array to ./dump/<output>.json
3940
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3941
- --markdown Save as Markdown table to ./dump/<output>.md
3942
-
3943
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
3944
-
3945
- Broker debug flags (--brokerdebug):
3946
-
3947
- --symbol <string> Trading pair (default: BTCUSDT)
3948
- --exchange <string> Exchange name (default: first registered)
3949
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3950
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3951
- (default: signal-open)
3952
-
3953
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3954
- the selected broker commit with synthetic payload values derived from current price.
3955
-
3956
- Flush flags (--flush):
3957
-
3958
- One or more positional entry points. For each entry point the following
3959
- subdirectories are removed from <entry-dir>/dump/:
3960
-
3961
- report log markdown agent
3962
-
3963
- Init flags (--init):
3964
-
3965
- --output <string> Target directory name (default: backtest-kit-project)
3966
-
3967
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3968
-
3969
- Docker flags (--docker):
3970
-
3971
- --output <string> Target directory name (default: backtest-kit-docker)
3972
-
3973
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
3974
- tsconfig.json, and a sample strategy under content/. Run npm install then
3975
- docker compose up to start the container.
3976
-
3977
- Module hooks (loaded automatically by each mode):
3978
-
3979
- modules/backtest.module --backtest Broker adapter for backtest
3980
- modules/walker.module --walker Broker adapter for walker comparison
3981
- modules/paper.module --paper Broker adapter for paper trading
3982
- modules/live.module --live Broker adapter for live trading
3983
- modules/pine.module --pine Exchange schema for PineScript runs
3984
- modules/editor.module --editor Exchange schema for the visual Pine editor
3985
- modules/dump.module --dump Exchange schema for candle dumps
3986
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3987
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3988
-
3989
- --flush has no associated module. It only removes dump subdirectories.
3990
-
3991
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3992
-
3993
- Environment variables:
3994
-
3995
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3996
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3997
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3998
- CC_WWWROOT_PORT UI server port (default: 60050)
3999
-
4000
- Examples:
4001
-
4002
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4003
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4004
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4005
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4006
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4007
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4008
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4009
- node ${ENTRY_PATH} --editor
4010
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4011
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4012
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4013
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4014
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4015
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4016
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4017
- node ${ENTRY_PATH} --init --output my-trading-bot
4018
- node ${ENTRY_PATH} --docker --output my-docker-workspace
3891
+ const HELP_TEXT = `
3892
+ Usage:
3893
+ node index.mjs --<mode> [flags] [entry-point]
3894
+
3895
+ Modes:
3896
+
3897
+ --backtest <entry> Run strategy against historical candle data
3898
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3899
+ --paper <entry> Paper trading (live prices, no real orders)
3900
+ --live <entry> Live trading with real orders
3901
+ --pine <entry> Execute a local .pine indicator file
3902
+ --editor Open the Pine Script visual editor in the browser
3903
+ --dump Fetch and save raw OHLCV candles
3904
+ --pnldebug Simulate PnL per minute for a given entry price and direction
3905
+ --brokerdebug Fire a single broker commit against the live broker adapter
3906
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3907
+ --init Scaffold a new project in the current directory
3908
+ --docker Scaffold a Docker workspace for running strategies in a container
3909
+ --help Print this help message
3910
+
3911
+ Backtest flags:
3912
+
3913
+ --symbol <string> Trading pair (default: BTCUSDT)
3914
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
3915
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3916
+ --frame <string> Frame name from addFrameSchema (default: first registered)
3917
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3918
+ --noCache Skip candle cache warming before the run
3919
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
3920
+ --verbose Log every candle fetch to stdout
3921
+ --ui Start web dashboard at http://localhost:60050
3922
+ --telegram Send trade notifications to Telegram
3923
+
3924
+ Walker flags (--walker):
3925
+
3926
+ --symbol <string> Trading pair (default: BTCUSDT)
3927
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3928
+ --noCache Skip candle cache warming before the run
3929
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
3930
+ --verbose Log every candle fetch to stdout
3931
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3932
+ --json Save results as JSON to ./dump/<output>.json
3933
+ --markdown Save report as Markdown to ./dump/<output>.md
3934
+
3935
+ Each positional argument is a strategy entry point. All strategy files are loaded without
3936
+ changing process.cwd() — .env is read from the working directory only.
3937
+ addWalkerSchema is called automatically using the registered exchange and frame.
3938
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3939
+
3940
+ Module file ./modules/walker.module is loaded automatically if it exists.
3941
+
3942
+ Paper / Live flags:
3943
+
3944
+ --symbol <string> Trading pair (default: BTCUSDT)
3945
+ --strategy <string> Strategy name (default: first registered)
3946
+ --exchange <string> Exchange name (default: first registered)
3947
+ --verbose Log every candle fetch to stdout
3948
+ --ui Start web dashboard
3949
+ --telegram Send Telegram notifications
3950
+
3951
+ PineScript flags (--pine):
3952
+
3953
+ --symbol <string> Trading pair (default: BTCUSDT)
3954
+ --timeframe <string> Candle interval (default: 15m)
3955
+ --limit <string> Number of candles to fetch (default: 250)
3956
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3957
+ --exchange <string> Exchange name (default: first registered)
3958
+ --output <string> Output file base name without extension
3959
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
3960
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3961
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3962
+
3963
+ Only plot() calls with display=display.data_window produce output columns.
3964
+ Module file ./modules/pine.module is loaded automatically if it exists.
3965
+
3966
+ Candle dump flags (--dump):
3967
+
3968
+ --symbol <string> Trading pair (default: BTCUSDT)
3969
+ --timeframe <string> Candle interval (default: 15m)
3970
+ --limit <string> Number of candles (default: 250)
3971
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3972
+ --exchange <string> Exchange name (default: first registered)
3973
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3974
+ --json Save as JSON array to ./dump/<output>.json
3975
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3976
+
3977
+ Module file ./modules/dump.module is loaded automatically if it exists.
3978
+
3979
+ PnL debug flags (--pnldebug):
3980
+
3981
+ --symbol <string> Trading pair (default: BTCUSDT)
3982
+ --priceopen <number> Entry price (required)
3983
+ --direction <string> Position direction: long or short (default: long)
3984
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
3985
+ --minutes <string> Number of 1m candles to simulate (default: 60)
3986
+ --exchange <string> Exchange name (default: first registered)
3987
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3988
+ --json Save as JSON array to ./dump/<output>.json
3989
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3990
+ --markdown Save as Markdown table to ./dump/<output>.md
3991
+
3992
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
3993
+
3994
+ Broker debug flags (--brokerdebug):
3995
+
3996
+ --symbol <string> Trading pair (default: BTCUSDT)
3997
+ --exchange <string> Exchange name (default: first registered)
3998
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3999
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4000
+ (default: signal-open)
4001
+
4002
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4003
+ the selected broker commit with synthetic payload values derived from current price.
4004
+
4005
+ Flush flags (--flush):
4006
+
4007
+ One or more positional entry points. For each entry point the following
4008
+ subdirectories are removed from <entry-dir>/dump/:
4009
+
4010
+ report log markdown agent
4011
+
4012
+ Init flags (--init):
4013
+
4014
+ --output <string> Target directory name (default: backtest-kit-project)
4015
+
4016
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4017
+
4018
+ Docker flags (--docker):
4019
+
4020
+ --output <string> Target directory name (default: backtest-kit-docker)
4021
+
4022
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4023
+ tsconfig.json, and a sample strategy under content/. Run npm install then
4024
+ docker compose up to start the container.
4025
+
4026
+ Module hooks (loaded automatically by each mode):
4027
+
4028
+ modules/backtest.module --backtest Broker adapter for backtest
4029
+ modules/walker.module --walker Broker adapter for walker comparison
4030
+ modules/paper.module --paper Broker adapter for paper trading
4031
+ modules/live.module --live Broker adapter for live trading
4032
+ modules/pine.module --pine Exchange schema for PineScript runs
4033
+ modules/editor.module --editor Exchange schema for the visual Pine editor
4034
+ modules/dump.module --dump Exchange schema for candle dumps
4035
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4036
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4037
+
4038
+ --flush has no associated module. It only removes dump subdirectories.
4039
+
4040
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4041
+
4042
+ Environment variables:
4043
+
4044
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4045
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4046
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4047
+ CC_WWWROOT_PORT UI server port (default: 60050)
4048
+
4049
+ Examples:
4050
+
4051
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4052
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4053
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4054
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4055
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4056
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4057
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4058
+ node ${ENTRY_PATH} --editor
4059
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4060
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4061
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4062
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4063
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4064
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4065
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4066
+ node ${ENTRY_PATH} --init --output my-trading-bot
4067
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4019
4068
  `.trimStart();
4020
4069
  const main$1 = async () => {
4021
4070
  if (!getEntry(import.meta.url)) {
@@ -4025,7 +4074,7 @@ const main$1 = async () => {
4025
4074
  if (!values.help) {
4026
4075
  return;
4027
4076
  }
4028
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n\n`);
4077
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n\n`);
4029
4078
  process.stdout.write(HELP_TEXT);
4030
4079
  process.exit(0);
4031
4080
  };
@@ -4039,7 +4088,7 @@ const main = async () => {
4039
4088
  if (!values.version) {
4040
4089
  return;
4041
4090
  }
4042
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
4091
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n`);
4043
4092
  process.exit(0);
4044
4093
  };
4045
4094
  main();
@@ -1,13 +1,13 @@
1
- export default {
2
- signal: true,
3
- risk: true,
4
- info: true,
5
- breakeven: true,
6
- common_error: true,
7
- critical_error: true,
8
- validation_error: true,
9
- partial_loss: false,
10
- partial_profit: false,
11
- signal_sync: false,
12
- strategy_commit: true,
13
- };
1
+ export default {
2
+ signal: true,
3
+ risk: true,
4
+ info: true,
5
+ breakeven: true,
6
+ common_error: true,
7
+ critical_error: true,
8
+ validation_error: true,
9
+ partial_loss: false,
10
+ partial_profit: false,
11
+ signal_sync: false,
12
+ strategy_commit: true,
13
+ };