@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.cjs CHANGED
@@ -892,6 +892,7 @@ class BacktestMainService {
892
892
  this.frontendProviderService = inject(TYPES.frontendProviderService);
893
893
  this.telegramProviderService = inject(TYPES.telegramProviderService);
894
894
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
895
+ this.configConnectionService = inject(TYPES.configConnectionService);
895
896
  this.run = functoolsKit.singleshot(async (payload) => {
896
897
  this.loggerService.log("backtestMainService run", {
897
898
  payload,
@@ -904,9 +905,14 @@ class BacktestMainService {
904
905
  this.frontendProviderService.connect();
905
906
  this.telegramProviderService.connect();
906
907
  }
908
+ {
909
+ const cwd = process.cwd();
910
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
911
+ }
912
+ await this.configConnectionService.loadConfig("setup.config");
907
913
  {
908
914
  await this.resolveService.attachJavascript(payload.entryPoint);
909
- await this.moduleConnectionService.loadModule("./backtest.module");
915
+ await this.moduleConnectionService.loadModule("backtest.module");
910
916
  }
911
917
  {
912
918
  this.exchangeSchemaService.addSchema();
@@ -1007,6 +1013,7 @@ class WalkerMainService {
1007
1013
  this.symbolSchemaService = inject(TYPES.symbolSchemaService);
1008
1014
  this.cacheLogicService = inject(TYPES.cacheLogicService);
1009
1015
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
1016
+ this.configConnectionService = inject(TYPES.configConnectionService);
1010
1017
  this.run = functoolsKit.singleshot(async (payload) => {
1011
1018
  this.loggerService.log("walkerMainService run", { payload });
1012
1019
  {
@@ -1042,7 +1049,12 @@ class WalkerMainService {
1042
1049
  BacktestKit.Cache.resetCounter();
1043
1050
  BacktestKit.Interval.resetCounter();
1044
1051
  }
1045
- await this.moduleConnectionService.loadModule("./walker.module");
1052
+ {
1053
+ const cwd = process.cwd();
1054
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1055
+ }
1056
+ await this.configConnectionService.loadConfig("setup.config");
1057
+ await this.moduleConnectionService.loadModule("walker.module");
1046
1058
  {
1047
1059
  this.exchangeSchemaService.addSchema();
1048
1060
  this.symbolSchemaService.addSchema();
@@ -1224,6 +1236,7 @@ class LiveMainService {
1224
1236
  this.frontendProviderService = inject(TYPES.frontendProviderService);
1225
1237
  this.telegramProviderService = inject(TYPES.telegramProviderService);
1226
1238
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
1239
+ this.configConnectionService = inject(TYPES.configConnectionService);
1227
1240
  this.run = functoolsKit.singleshot(async (payload) => {
1228
1241
  this.loggerService.log("liveMainService run", {
1229
1242
  payload,
@@ -1236,9 +1249,14 @@ class LiveMainService {
1236
1249
  this.frontendProviderService.connect();
1237
1250
  this.telegramProviderService.connect();
1238
1251
  }
1252
+ {
1253
+ const cwd = process.cwd();
1254
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1255
+ }
1256
+ await this.configConnectionService.loadConfig("setup.config");
1239
1257
  {
1240
1258
  await this.resolveService.attachJavascript(payload.entryPoint);
1241
- await this.moduleConnectionService.loadModule("./live.module");
1259
+ await this.moduleConnectionService.loadModule("live.module");
1242
1260
  }
1243
1261
  {
1244
1262
  this.exchangeSchemaService.addSchema();
@@ -1306,6 +1324,7 @@ class PaperMainService {
1306
1324
  this.frontendProviderService = inject(TYPES.frontendProviderService);
1307
1325
  this.telegramProviderService = inject(TYPES.telegramProviderService);
1308
1326
  this.moduleConnectionService = inject(TYPES.moduleConnectionService);
1327
+ this.configConnectionService = inject(TYPES.configConnectionService);
1309
1328
  this.run = functoolsKit.singleshot(async (payload) => {
1310
1329
  this.loggerService.log("paperMainService init");
1311
1330
  {
@@ -1316,9 +1335,14 @@ class PaperMainService {
1316
1335
  this.frontendProviderService.connect();
1317
1336
  this.telegramProviderService.connect();
1318
1337
  }
1338
+ {
1339
+ const cwd = process.cwd();
1340
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
1341
+ }
1342
+ await this.configConnectionService.loadConfig("setup.config");
1319
1343
  {
1320
1344
  await this.resolveService.attachJavascript(payload.entryPoint);
1321
- await this.moduleConnectionService.loadModule("./paper.module");
1345
+ await this.moduleConnectionService.loadModule("paper.module");
1322
1346
  }
1323
1347
  {
1324
1348
  this.exchangeSchemaService.addSchema();
@@ -2578,7 +2602,7 @@ class BabelService {
2578
2602
  const IMPORT_ALIAS = {};
2579
2603
 
2580
2604
  const USE_ESMODULE_DEFAULT = false;
2581
- const IMPORT_PATHS_EXCLUDE = new Set(["dump", "logs", "modules", "node_modules"]);
2605
+ const IMPORT_PATHS_EXCLUDE = new Set(["dump", "logs", "modules", "config", "node_modules"]);
2582
2606
  const TRANSPILE_FN = functoolsKit.memoize(([path]) => `${path}`, (path, code, self, require) => {
2583
2607
  const __filename = self.__filename;
2584
2608
  const __dirname = self.__dirname;
@@ -2803,10 +2827,10 @@ globalThis.BacktestKitSignals = BacktestKitSignals__namespace;
2803
2827
 
2804
2828
  const GET_ALIAS_EXPORTS_FN = (self) => {
2805
2829
  const instance = self.getInstance(self.resolveService.OVERRIDE_CONFIG_DIR);
2806
- if (!instance.check("alias.module")) {
2830
+ if (!instance.check("alias.config")) {
2807
2831
  return null;
2808
2832
  }
2809
- const exports = instance.import("alias.module");
2833
+ const exports = instance.import("alias.config");
2810
2834
  return "default" in exports
2811
2835
  ? exports.default
2812
2836
  : exports;
@@ -3038,10 +3062,10 @@ init();
3038
3062
 
3039
3063
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3040
3064
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3041
- const HELP_TEXT$1 = `
3042
- Example:
3043
-
3044
- node ${ENTRY_PATH$1} --help
3065
+ const HELP_TEXT$1 = `
3066
+ Example:
3067
+
3068
+ node ${ENTRY_PATH$1} --help
3045
3069
  `.trimStart();
3046
3070
  const main$g = async () => {
3047
3071
  if (!getEntry((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))) {
@@ -3051,7 +3075,7 @@ const main$g = async () => {
3051
3075
  if (MODES.some((mode) => values[mode])) {
3052
3076
  return;
3053
3077
  }
3054
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
3078
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n`);
3055
3079
  process.stdout.write("\n");
3056
3080
  process.stdout.write(`Run with --help to see available commands.\n`);
3057
3081
  process.stdout.write("\n");
@@ -3241,10 +3265,10 @@ const main$b = async () => {
3241
3265
  main$b();
3242
3266
 
3243
3267
  const MODE_MODULE = {
3244
- backtest: "./backtest.module",
3245
- live: "./live.module",
3246
- paper: "./paper.module",
3247
- walker: "./walker.module",
3268
+ backtest: "backtest.module",
3269
+ live: "live.module",
3270
+ paper: "paper.module",
3271
+ walker: "walker.module",
3248
3272
  };
3249
3273
  const resolveMode = (values) => {
3250
3274
  const enabled = ["backtest", "live", "paper", "walker"].filter((mode) => Boolean(values[mode]));
@@ -3343,6 +3367,11 @@ const main$a = async () => {
3343
3367
  Setup.enable();
3344
3368
  cli.frontendProviderService.connect();
3345
3369
  cli.telegramProviderService.connect();
3370
+ {
3371
+ const cwd = process.cwd();
3372
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3373
+ }
3374
+ await cli.configConnectionService.loadConfig("setup.config");
3346
3375
  await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
3347
3376
  listenFinish();
3348
3377
  createGracefulShutdown(mode)();
@@ -3427,7 +3456,12 @@ const main$7 = async () => {
3427
3456
  return;
3428
3457
  }
3429
3458
  const source = await cli.resolveService.attachPine(entryPoint);
3430
- await cli.moduleConnectionService.loadModule("./pine.module");
3459
+ {
3460
+ const cwd = process.cwd();
3461
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3462
+ }
3463
+ await cli.configConnectionService.loadConfig("setup.config");
3464
+ await cli.moduleConnectionService.loadModule("pine.module");
3431
3465
  {
3432
3466
  await cli.exchangeSchemaService.addSchema();
3433
3467
  await cli.symbolSchemaService.addSchema();
@@ -3508,7 +3542,12 @@ const main$6 = async () => {
3508
3542
  await cli.configService.waitForInit();
3509
3543
  Setup.enable();
3510
3544
  }
3511
- await cli.moduleConnectionService.loadModule("./editor.module");
3545
+ {
3546
+ const cwd = process.cwd();
3547
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3548
+ }
3549
+ await cli.configConnectionService.loadConfig("setup.config");
3550
+ await cli.moduleConnectionService.loadModule("editor.module");
3512
3551
  {
3513
3552
  await cli.exchangeSchemaService.addSchema();
3514
3553
  }
@@ -3537,7 +3576,12 @@ const main$5 = async () => {
3537
3576
  if (!values.dump) {
3538
3577
  return;
3539
3578
  }
3540
- await cli.moduleConnectionService.loadModule("./dump.module");
3579
+ {
3580
+ const cwd = process.cwd();
3581
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3582
+ }
3583
+ await cli.configConnectionService.loadConfig("setup.config");
3584
+ await cli.moduleConnectionService.loadModule("dump.module");
3541
3585
  {
3542
3586
  await cli.exchangeSchemaService.addSchema();
3543
3587
  await cli.symbolSchemaService.addSchema();
@@ -3600,7 +3644,12 @@ const main$4 = async () => {
3600
3644
  if (!values.pnldebug) {
3601
3645
  return;
3602
3646
  }
3603
- await cli.moduleConnectionService.loadModule("./pnldebug.module");
3647
+ {
3648
+ const cwd = process.cwd();
3649
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3650
+ }
3651
+ await cli.configConnectionService.loadConfig("setup.config");
3652
+ await cli.moduleConnectionService.loadModule("pnldebug.module");
3604
3653
  {
3605
3654
  await cli.exchangeSchemaService.addSchema();
3606
3655
  await cli.symbolSchemaService.addSchema();
@@ -3868,183 +3917,183 @@ const main$2 = async () => {
3868
3917
  main$2();
3869
3918
 
3870
3919
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
3871
- const HELP_TEXT = `
3872
- Usage:
3873
- node index.mjs --<mode> [flags] [entry-point]
3874
-
3875
- Modes:
3876
-
3877
- --backtest <entry> Run strategy against historical candle data
3878
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3879
- --paper <entry> Paper trading (live prices, no real orders)
3880
- --live <entry> Live trading with real orders
3881
- --pine <entry> Execute a local .pine indicator file
3882
- --editor Open the Pine Script visual editor in the browser
3883
- --dump Fetch and save raw OHLCV candles
3884
- --pnldebug Simulate PnL per minute for a given entry price and direction
3885
- --brokerdebug Fire a single broker commit against the live broker adapter
3886
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3887
- --init Scaffold a new project in the current directory
3888
- --docker Scaffold a Docker workspace for running strategies in a container
3889
- --help Print this help message
3890
-
3891
- Backtest flags:
3892
-
3893
- --symbol <string> Trading pair (default: BTCUSDT)
3894
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
3895
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3896
- --frame <string> Frame name from addFrameSchema (default: first registered)
3897
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3898
- --noCache Skip candle cache warming before the run
3899
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
3900
- --verbose Log every candle fetch to stdout
3901
- --ui Start web dashboard at http://localhost:60050
3902
- --telegram Send trade notifications to Telegram
3903
-
3904
- Walker flags (--walker):
3905
-
3906
- --symbol <string> Trading pair (default: BTCUSDT)
3907
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3908
- --noCache Skip candle cache warming before the run
3909
- --noFlush Skip removing report/log/markdown/agent folders before walker run
3910
- --verbose Log every candle fetch to stdout
3911
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3912
- --json Save results as JSON to ./dump/<output>.json
3913
- --markdown Save report as Markdown to ./dump/<output>.md
3914
-
3915
- Each positional argument is a strategy entry point. All strategy files are loaded without
3916
- changing process.cwd() — .env is read from the working directory only.
3917
- addWalkerSchema is called automatically using the registered exchange and frame.
3918
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3919
-
3920
- Module file ./modules/walker.module is loaded automatically if it exists.
3921
-
3922
- Paper / Live flags:
3923
-
3924
- --symbol <string> Trading pair (default: BTCUSDT)
3925
- --strategy <string> Strategy name (default: first registered)
3926
- --exchange <string> Exchange name (default: first registered)
3927
- --verbose Log every candle fetch to stdout
3928
- --ui Start web dashboard
3929
- --telegram Send Telegram notifications
3930
-
3931
- PineScript flags (--pine):
3932
-
3933
- --symbol <string> Trading pair (default: BTCUSDT)
3934
- --timeframe <string> Candle interval (default: 15m)
3935
- --limit <string> Number of candles to fetch (default: 250)
3936
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3937
- --exchange <string> Exchange name (default: first registered)
3938
- --output <string> Output file base name without extension
3939
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
3940
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3941
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3942
-
3943
- Only plot() calls with display=display.data_window produce output columns.
3944
- Module file ./modules/pine.module is loaded automatically if it exists.
3945
-
3946
- Candle dump flags (--dump):
3947
-
3948
- --symbol <string> Trading pair (default: BTCUSDT)
3949
- --timeframe <string> Candle interval (default: 15m)
3950
- --limit <string> Number of candles (default: 250)
3951
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3952
- --exchange <string> Exchange name (default: first registered)
3953
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3954
- --json Save as JSON array to ./dump/<output>.json
3955
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3956
-
3957
- Module file ./modules/dump.module is loaded automatically if it exists.
3958
-
3959
- PnL debug flags (--pnldebug):
3960
-
3961
- --symbol <string> Trading pair (default: BTCUSDT)
3962
- --priceopen <number> Entry price (required)
3963
- --direction <string> Position direction: long or short (default: long)
3964
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
3965
- --minutes <string> Number of 1m candles to simulate (default: 60)
3966
- --exchange <string> Exchange name (default: first registered)
3967
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3968
- --json Save as JSON array to ./dump/<output>.json
3969
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3970
- --markdown Save as Markdown table to ./dump/<output>.md
3971
-
3972
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
3973
-
3974
- Broker debug flags (--brokerdebug):
3975
-
3976
- --symbol <string> Trading pair (default: BTCUSDT)
3977
- --exchange <string> Exchange name (default: first registered)
3978
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3979
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3980
- (default: signal-open)
3981
-
3982
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3983
- the selected broker commit with synthetic payload values derived from current price.
3984
-
3985
- Flush flags (--flush):
3986
-
3987
- One or more positional entry points. For each entry point the following
3988
- subdirectories are removed from <entry-dir>/dump/:
3989
-
3990
- report log markdown agent
3991
-
3992
- Init flags (--init):
3993
-
3994
- --output <string> Target directory name (default: backtest-kit-project)
3995
-
3996
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3997
-
3998
- Docker flags (--docker):
3999
-
4000
- --output <string> Target directory name (default: backtest-kit-docker)
4001
-
4002
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4003
- tsconfig.json, and a sample strategy under content/. Run npm install then
4004
- docker compose up to start the container.
4005
-
4006
- Module hooks (loaded automatically by each mode):
4007
-
4008
- modules/backtest.module --backtest Broker adapter for backtest
4009
- modules/walker.module --walker Broker adapter for walker comparison
4010
- modules/paper.module --paper Broker adapter for paper trading
4011
- modules/live.module --live Broker adapter for live trading
4012
- modules/pine.module --pine Exchange schema for PineScript runs
4013
- modules/editor.module --editor Exchange schema for the visual Pine editor
4014
- modules/dump.module --dump Exchange schema for candle dumps
4015
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4016
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4017
-
4018
- --flush has no associated module. It only removes dump subdirectories.
4019
-
4020
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4021
-
4022
- Environment variables:
4023
-
4024
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4025
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4026
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4027
- CC_WWWROOT_PORT UI server port (default: 60050)
4028
-
4029
- Examples:
4030
-
4031
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4032
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4033
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4034
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4035
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4036
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4037
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4038
- node ${ENTRY_PATH} --editor
4039
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4040
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4041
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4042
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4043
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4044
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4045
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4046
- node ${ENTRY_PATH} --init --output my-trading-bot
4047
- node ${ENTRY_PATH} --docker --output my-docker-workspace
3920
+ const HELP_TEXT = `
3921
+ Usage:
3922
+ node index.mjs --<mode> [flags] [entry-point]
3923
+
3924
+ Modes:
3925
+
3926
+ --backtest <entry> Run strategy against historical candle data
3927
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3928
+ --paper <entry> Paper trading (live prices, no real orders)
3929
+ --live <entry> Live trading with real orders
3930
+ --pine <entry> Execute a local .pine indicator file
3931
+ --editor Open the Pine Script visual editor in the browser
3932
+ --dump Fetch and save raw OHLCV candles
3933
+ --pnldebug Simulate PnL per minute for a given entry price and direction
3934
+ --brokerdebug Fire a single broker commit against the live broker adapter
3935
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3936
+ --init Scaffold a new project in the current directory
3937
+ --docker Scaffold a Docker workspace for running strategies in a container
3938
+ --help Print this help message
3939
+
3940
+ Backtest flags:
3941
+
3942
+ --symbol <string> Trading pair (default: BTCUSDT)
3943
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
3944
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3945
+ --frame <string> Frame name from addFrameSchema (default: first registered)
3946
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3947
+ --noCache Skip candle cache warming before the run
3948
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
3949
+ --verbose Log every candle fetch to stdout
3950
+ --ui Start web dashboard at http://localhost:60050
3951
+ --telegram Send trade notifications to Telegram
3952
+
3953
+ Walker flags (--walker):
3954
+
3955
+ --symbol <string> Trading pair (default: BTCUSDT)
3956
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3957
+ --noCache Skip candle cache warming before the run
3958
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
3959
+ --verbose Log every candle fetch to stdout
3960
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3961
+ --json Save results as JSON to ./dump/<output>.json
3962
+ --markdown Save report as Markdown to ./dump/<output>.md
3963
+
3964
+ Each positional argument is a strategy entry point. All strategy files are loaded without
3965
+ changing process.cwd() — .env is read from the working directory only.
3966
+ addWalkerSchema is called automatically using the registered exchange and frame.
3967
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3968
+
3969
+ Module file ./modules/walker.module is loaded automatically if it exists.
3970
+
3971
+ Paper / Live flags:
3972
+
3973
+ --symbol <string> Trading pair (default: BTCUSDT)
3974
+ --strategy <string> Strategy name (default: first registered)
3975
+ --exchange <string> Exchange name (default: first registered)
3976
+ --verbose Log every candle fetch to stdout
3977
+ --ui Start web dashboard
3978
+ --telegram Send Telegram notifications
3979
+
3980
+ PineScript flags (--pine):
3981
+
3982
+ --symbol <string> Trading pair (default: BTCUSDT)
3983
+ --timeframe <string> Candle interval (default: 15m)
3984
+ --limit <string> Number of candles to fetch (default: 250)
3985
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3986
+ --exchange <string> Exchange name (default: first registered)
3987
+ --output <string> Output file base name without extension
3988
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
3989
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3990
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3991
+
3992
+ Only plot() calls with display=display.data_window produce output columns.
3993
+ Module file ./modules/pine.module is loaded automatically if it exists.
3994
+
3995
+ Candle dump flags (--dump):
3996
+
3997
+ --symbol <string> Trading pair (default: BTCUSDT)
3998
+ --timeframe <string> Candle interval (default: 15m)
3999
+ --limit <string> Number of candles (default: 250)
4000
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4001
+ --exchange <string> Exchange name (default: first registered)
4002
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4003
+ --json Save as JSON array to ./dump/<output>.json
4004
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4005
+
4006
+ Module file ./modules/dump.module is loaded automatically if it exists.
4007
+
4008
+ PnL debug flags (--pnldebug):
4009
+
4010
+ --symbol <string> Trading pair (default: BTCUSDT)
4011
+ --priceopen <number> Entry price (required)
4012
+ --direction <string> Position direction: long or short (default: long)
4013
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4014
+ --minutes <string> Number of 1m candles to simulate (default: 60)
4015
+ --exchange <string> Exchange name (default: first registered)
4016
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4017
+ --json Save as JSON array to ./dump/<output>.json
4018
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4019
+ --markdown Save as Markdown table to ./dump/<output>.md
4020
+
4021
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
4022
+
4023
+ Broker debug flags (--brokerdebug):
4024
+
4025
+ --symbol <string> Trading pair (default: BTCUSDT)
4026
+ --exchange <string> Exchange name (default: first registered)
4027
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4028
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4029
+ (default: signal-open)
4030
+
4031
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4032
+ the selected broker commit with synthetic payload values derived from current price.
4033
+
4034
+ Flush flags (--flush):
4035
+
4036
+ One or more positional entry points. For each entry point the following
4037
+ subdirectories are removed from <entry-dir>/dump/:
4038
+
4039
+ report log markdown agent
4040
+
4041
+ Init flags (--init):
4042
+
4043
+ --output <string> Target directory name (default: backtest-kit-project)
4044
+
4045
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4046
+
4047
+ Docker flags (--docker):
4048
+
4049
+ --output <string> Target directory name (default: backtest-kit-docker)
4050
+
4051
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4052
+ tsconfig.json, and a sample strategy under content/. Run npm install then
4053
+ docker compose up to start the container.
4054
+
4055
+ Module hooks (loaded automatically by each mode):
4056
+
4057
+ modules/backtest.module --backtest Broker adapter for backtest
4058
+ modules/walker.module --walker Broker adapter for walker comparison
4059
+ modules/paper.module --paper Broker adapter for paper trading
4060
+ modules/live.module --live Broker adapter for live trading
4061
+ modules/pine.module --pine Exchange schema for PineScript runs
4062
+ modules/editor.module --editor Exchange schema for the visual Pine editor
4063
+ modules/dump.module --dump Exchange schema for candle dumps
4064
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4065
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4066
+
4067
+ --flush has no associated module. It only removes dump subdirectories.
4068
+
4069
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4070
+
4071
+ Environment variables:
4072
+
4073
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4074
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4075
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4076
+ CC_WWWROOT_PORT UI server port (default: 60050)
4077
+
4078
+ Examples:
4079
+
4080
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4081
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4082
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4083
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4084
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4085
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4086
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4087
+ node ${ENTRY_PATH} --editor
4088
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4089
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4090
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4091
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4092
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4093
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4094
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4095
+ node ${ENTRY_PATH} --init --output my-trading-bot
4096
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4048
4097
  `.trimStart();
4049
4098
  const main$1 = async () => {
4050
4099
  if (!getEntry((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))) {
@@ -4054,7 +4103,7 @@ const main$1 = async () => {
4054
4103
  if (!values.help) {
4055
4104
  return;
4056
4105
  }
4057
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n\n`);
4106
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n\n`);
4058
4107
  process.stdout.write(HELP_TEXT);
4059
4108
  process.exit(0);
4060
4109
  };
@@ -4068,7 +4117,7 @@ const main = async () => {
4068
4117
  if (!values.version) {
4069
4118
  return;
4070
4119
  }
4071
- process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
4120
+ process.stdout.write(`@backtest-kit/cli ${"9.3.0"}\n`);
4072
4121
  process.exit(0);
4073
4122
  };
4074
4123
  main();