@backtest-kit/cli 9.6.0 → 9.7.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.
Files changed (34) hide show
  1. package/README.md +1854 -1738
  2. package/build/index.cjs +268 -204
  3. package/build/index.mjs +268 -204
  4. package/config/notification.config.mjs +13 -13
  5. package/config/symbol.config.mjs +460 -460
  6. package/docker/.env.example +2 -2
  7. package/docker/README.md +1 -0
  8. package/docker/content/feb_2026/feb_2026.strategy.ts +11 -11
  9. package/docker/content/feb_2026/modules/backtest.module.ts +83 -83
  10. package/docker/docker-compose.yaml +46 -46
  11. package/docker/package.json +38 -38
  12. package/docker/tsconfig.json +36 -36
  13. package/package.json +126 -126
  14. package/template/average-buy.mustache +22 -22
  15. package/template/breakeven.mustache +21 -21
  16. package/template/cancel-scheduled.mustache +14 -14
  17. package/template/cancelled.mustache +21 -21
  18. package/template/close-pending.mustache +16 -16
  19. package/template/closed.mustache +23 -23
  20. package/template/opened.mustache +22 -22
  21. package/template/partial-loss.mustache +22 -22
  22. package/template/partial-profit.mustache +22 -22
  23. package/template/project/README.md +1 -0
  24. package/template/project/config/symbol.config.ts +460 -460
  25. package/template/project/package.mustache +28 -28
  26. package/template/risk.mustache +19 -19
  27. package/template/scheduled.mustache +22 -22
  28. package/template/signal-close.mustache +22 -22
  29. package/template/signal-info.mustache +20 -20
  30. package/template/signal-open.mustache +22 -22
  31. package/template/source/CLAUDE.md +160 -160
  32. package/template/trailing-stop.mustache +21 -21
  33. package/template/trailing-take.mustache +21 -21
  34. package/types.d.ts +1 -6
package/build/index.cjs CHANGED
@@ -910,9 +910,15 @@ class BacktestMainService {
910
910
  this.loggerService.log("backtestMainService run", {
911
911
  payload,
912
912
  });
913
+ await this.configConnectionService.loadConfig("setup.config");
913
914
  {
914
- await this.configConnectionService.loadConfig("setup.config");
915
- await this.configConnectionService.loadConfig("loader.config");
915
+ const loader = await this.configConnectionService.loadConfig("loader.config");
916
+ if (typeof loader === "function") {
917
+ await loader();
918
+ }
919
+ if (typeof loader?.loader === "function") {
920
+ await loader.loader();
921
+ }
916
922
  }
917
923
  {
918
924
  await this.configService.waitForInit();
@@ -1032,9 +1038,15 @@ class WalkerMainService {
1032
1038
  this.configConnectionService = inject(TYPES.configConnectionService);
1033
1039
  this.run = functoolsKit.singleshot(async (payload) => {
1034
1040
  this.loggerService.log("walkerMainService run", { payload });
1041
+ await this.configConnectionService.loadConfig("setup.config");
1035
1042
  {
1036
- await this.configConnectionService.loadConfig("setup.config");
1037
- await this.configConnectionService.loadConfig("loader.config");
1043
+ const loader = await this.configConnectionService.loadConfig("loader.config");
1044
+ if (typeof loader === "function") {
1045
+ await loader();
1046
+ }
1047
+ if (typeof loader?.loader === "function") {
1048
+ await loader.loader();
1049
+ }
1038
1050
  }
1039
1051
  {
1040
1052
  await this.configService.waitForInit();
@@ -1260,9 +1272,15 @@ class LiveMainService {
1260
1272
  this.loggerService.log("liveMainService run", {
1261
1273
  payload,
1262
1274
  });
1275
+ await this.configConnectionService.loadConfig("setup.config");
1263
1276
  {
1264
- await this.configConnectionService.loadConfig("setup.config");
1265
- await this.configConnectionService.loadConfig("loader.config");
1277
+ const loader = await this.configConnectionService.loadConfig("loader.config");
1278
+ if (typeof loader === "function") {
1279
+ await loader();
1280
+ }
1281
+ if (typeof loader?.loader === "function") {
1282
+ await loader.loader();
1283
+ }
1266
1284
  }
1267
1285
  {
1268
1286
  await this.configService.waitForInit();
@@ -1349,9 +1367,15 @@ class PaperMainService {
1349
1367
  this.configConnectionService = inject(TYPES.configConnectionService);
1350
1368
  this.run = functoolsKit.singleshot(async (payload) => {
1351
1369
  this.loggerService.log("paperMainService init");
1370
+ await this.configConnectionService.loadConfig("setup.config");
1352
1371
  {
1353
- await this.configConnectionService.loadConfig("setup.config");
1354
- await this.configConnectionService.loadConfig("loader.config");
1372
+ const loader = await this.configConnectionService.loadConfig("loader.config");
1373
+ if (typeof loader === "function") {
1374
+ await loader();
1375
+ }
1376
+ if (typeof loader?.loader === "function") {
1377
+ await loader.loader();
1378
+ }
1355
1379
  }
1356
1380
  {
1357
1381
  await this.configService.waitForInit();
@@ -2913,8 +2937,14 @@ const GET_ALIAS_EXPORTS_FN = (self) => {
2913
2937
  continue;
2914
2938
  }
2915
2939
  const instance = self.getInstance(baseDir);
2916
- const exports = instance.import(filePath);
2917
- return "default" in exports ? exports.default : exports;
2940
+ const alias = instance.import(filePath);
2941
+ if (!alias) {
2942
+ return null;
2943
+ }
2944
+ if ("default" in alias) {
2945
+ return alias.default;
2946
+ }
2947
+ return alias;
2918
2948
  }
2919
2949
  return null;
2920
2950
  };
@@ -3013,6 +3043,10 @@ class ConfigConnectionService {
3013
3043
  const config = await LOAD_CONFIG_CONFIG_FN(fileName, this);
3014
3044
  if (!config) {
3015
3045
  this.loadConfig.clear(fileName);
3046
+ return null;
3047
+ }
3048
+ if ("default" in config) {
3049
+ return config.default;
3016
3050
  }
3017
3051
  return config;
3018
3052
  });
@@ -3158,10 +3192,10 @@ init();
3158
3192
 
3159
3193
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3160
3194
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3161
- const HELP_TEXT$1 = `
3162
- Example:
3163
-
3164
- node ${ENTRY_PATH$1} --help
3195
+ const HELP_TEXT$1 = `
3196
+ Example:
3197
+
3198
+ node ${ENTRY_PATH$1} --help
3165
3199
  `.trimStart();
3166
3200
  const main$g = async () => {
3167
3201
  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)))) {
@@ -3171,7 +3205,7 @@ const main$g = async () => {
3171
3205
  if (MODES.some((mode) => values[mode])) {
3172
3206
  return;
3173
3207
  }
3174
- process.stdout.write(`@backtest-kit/cli ${"9.6.0"}\n`);
3208
+ process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n`);
3175
3209
  process.stdout.write("\n");
3176
3210
  process.stdout.write(`Run with --help to see available commands.\n`);
3177
3211
  process.stdout.write("\n");
@@ -3462,9 +3496,15 @@ const main$a = async () => {
3462
3496
  }
3463
3497
  await flush(entryPoint);
3464
3498
  }
3499
+ await cli.configConnectionService.loadConfig("setup.config");
3465
3500
  {
3466
- await cli.configConnectionService.loadConfig("setup.config");
3467
- await cli.configConnectionService.loadConfig("loader.config");
3501
+ const loader = await cli.configConnectionService.loadConfig("loader.config");
3502
+ if (typeof loader === "function") {
3503
+ await loader();
3504
+ }
3505
+ if (typeof loader?.loader === "function") {
3506
+ await loader.loader();
3507
+ }
3468
3508
  }
3469
3509
  {
3470
3510
  await cli.configService.waitForInit();
@@ -3566,9 +3606,15 @@ const main$7 = async () => {
3566
3606
  const cwd = process.cwd();
3567
3607
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3568
3608
  }
3609
+ await cli.configConnectionService.loadConfig("setup.config");
3569
3610
  {
3570
- await cli.configConnectionService.loadConfig("setup.config");
3571
- await cli.configConnectionService.loadConfig("loader.config");
3611
+ const loader = await cli.configConnectionService.loadConfig("loader.config");
3612
+ if (typeof loader === "function") {
3613
+ await loader();
3614
+ }
3615
+ if (typeof loader?.loader === "function") {
3616
+ await loader.loader();
3617
+ }
3572
3618
  }
3573
3619
  await cli.moduleConnectionService.loadModule("pine.module");
3574
3620
  {
@@ -3647,9 +3693,15 @@ const main$6 = async () => {
3647
3693
  console.warn("--editor and --pine are mutually exclusive. Use one at a time.");
3648
3694
  process.exit(1);
3649
3695
  }
3696
+ await cli.configConnectionService.loadConfig("setup.config");
3650
3697
  {
3651
- await cli.configConnectionService.loadConfig("setup.config");
3652
- await cli.configConnectionService.loadConfig("loader.config");
3698
+ const loader = await cli.configConnectionService.loadConfig("loader.config");
3699
+ if (typeof loader === "function") {
3700
+ await loader();
3701
+ }
3702
+ if (typeof loader?.loader === "function") {
3703
+ await loader.loader();
3704
+ }
3653
3705
  }
3654
3706
  {
3655
3707
  await cli.configService.waitForInit();
@@ -3692,9 +3744,15 @@ const main$5 = async () => {
3692
3744
  const cwd = process.cwd();
3693
3745
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3694
3746
  }
3747
+ await cli.configConnectionService.loadConfig("setup.config");
3695
3748
  {
3696
- await cli.configConnectionService.loadConfig("setup.config");
3697
- await cli.configConnectionService.loadConfig("loader.config");
3749
+ const loader = await cli.configConnectionService.loadConfig("loader.config");
3750
+ if (typeof loader === "function") {
3751
+ await loader();
3752
+ }
3753
+ if (typeof loader?.loader === "function") {
3754
+ await loader.loader();
3755
+ }
3698
3756
  }
3699
3757
  await cli.moduleConnectionService.loadModule("dump.module");
3700
3758
  {
@@ -3763,9 +3821,15 @@ const main$4 = async () => {
3763
3821
  const cwd = process.cwd();
3764
3822
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3765
3823
  }
3824
+ await cli.configConnectionService.loadConfig("setup.config");
3766
3825
  {
3767
- await cli.configConnectionService.loadConfig("setup.config");
3768
- await cli.configConnectionService.loadConfig("loader.config");
3826
+ const loader = await cli.configConnectionService.loadConfig("loader.config");
3827
+ if (typeof loader === "function") {
3828
+ await loader();
3829
+ }
3830
+ if (typeof loader?.loader === "function") {
3831
+ await loader.loader();
3832
+ }
3769
3833
  }
3770
3834
  await cli.moduleConnectionService.loadModule("pnldebug.module");
3771
3835
  {
@@ -4035,183 +4099,183 @@ const main$2 = async () => {
4035
4099
  main$2();
4036
4100
 
4037
4101
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
4038
- const HELP_TEXT = `
4039
- Usage:
4040
- node index.mjs --<mode> [flags] [entry-point]
4041
-
4042
- Modes:
4043
-
4044
- --backtest <entry> Run strategy against historical candle data
4045
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4046
- --paper <entry> Paper trading (live prices, no real orders)
4047
- --live <entry> Live trading with real orders
4048
- --pine <entry> Execute a local .pine indicator file
4049
- --editor Open the Pine Script visual editor in the browser
4050
- --dump Fetch and save raw OHLCV candles
4051
- --pnldebug Simulate PnL per minute for a given entry price and direction
4052
- --brokerdebug Fire a single broker commit against the live broker adapter
4053
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4054
- --init Scaffold a new project in the current directory
4055
- --docker Scaffold a Docker workspace for running strategies in a container
4056
- --help Print this help message
4057
-
4058
- Backtest flags:
4059
-
4060
- --symbol <string> Trading pair (default: BTCUSDT)
4061
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
4062
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4063
- --frame <string> Frame name from addFrameSchema (default: first registered)
4064
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4065
- --noCache Skip candle cache warming before the run
4066
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
4067
- --verbose Log every candle fetch to stdout
4068
- --ui Start web dashboard at http://localhost:60050
4069
- --telegram Send trade notifications to Telegram
4070
-
4071
- Walker flags (--walker):
4072
-
4073
- --symbol <string> Trading pair (default: BTCUSDT)
4074
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4075
- --noCache Skip candle cache warming before the run
4076
- --noFlush Skip removing report/log/markdown/agent folders before walker run
4077
- --verbose Log every candle fetch to stdout
4078
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4079
- --json Save results as JSON to ./dump/<output>.json
4080
- --markdown Save report as Markdown to ./dump/<output>.md
4081
-
4082
- Each positional argument is a strategy entry point. All strategy files are loaded without
4083
- changing process.cwd() — .env is read from the working directory only.
4084
- addWalkerSchema is called automatically using the registered exchange and frame.
4085
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4086
-
4087
- Module file ./modules/walker.module is loaded automatically if it exists.
4088
-
4089
- Paper / Live flags:
4090
-
4091
- --symbol <string> Trading pair (default: BTCUSDT)
4092
- --strategy <string> Strategy name (default: first registered)
4093
- --exchange <string> Exchange name (default: first registered)
4094
- --verbose Log every candle fetch to stdout
4095
- --ui Start web dashboard
4096
- --telegram Send Telegram notifications
4097
-
4098
- PineScript flags (--pine):
4099
-
4100
- --symbol <string> Trading pair (default: BTCUSDT)
4101
- --timeframe <string> Candle interval (default: 15m)
4102
- --limit <string> Number of candles to fetch (default: 250)
4103
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4104
- --exchange <string> Exchange name (default: first registered)
4105
- --output <string> Output file base name without extension
4106
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
4107
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4108
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4109
-
4110
- Only plot() calls with display=display.data_window produce output columns.
4111
- Module file ./modules/pine.module is loaded automatically if it exists.
4112
-
4113
- Candle dump flags (--dump):
4114
-
4115
- --symbol <string> Trading pair (default: BTCUSDT)
4116
- --timeframe <string> Candle interval (default: 15m)
4117
- --limit <string> Number of candles (default: 250)
4118
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4119
- --exchange <string> Exchange name (default: first registered)
4120
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4121
- --json Save as JSON array to ./dump/<output>.json
4122
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4123
-
4124
- Module file ./modules/dump.module is loaded automatically if it exists.
4125
-
4126
- PnL debug flags (--pnldebug):
4127
-
4128
- --symbol <string> Trading pair (default: BTCUSDT)
4129
- --priceopen <number> Entry price (required)
4130
- --direction <string> Position direction: long or short (default: long)
4131
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4132
- --minutes <string> Number of 1m candles to simulate (default: 60)
4133
- --exchange <string> Exchange name (default: first registered)
4134
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4135
- --json Save as JSON array to ./dump/<output>.json
4136
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4137
- --markdown Save as Markdown table to ./dump/<output>.md
4138
-
4139
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
4140
-
4141
- Broker debug flags (--brokerdebug):
4142
-
4143
- --symbol <string> Trading pair (default: BTCUSDT)
4144
- --exchange <string> Exchange name (default: first registered)
4145
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4146
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4147
- (default: signal-open)
4148
-
4149
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4150
- the selected broker commit with synthetic payload values derived from current price.
4151
-
4152
- Flush flags (--flush):
4153
-
4154
- One or more positional entry points. For each entry point the following
4155
- subdirectories are removed from <entry-dir>/dump/:
4156
-
4157
- report log markdown agent
4158
-
4159
- Init flags (--init):
4160
-
4161
- --output <string> Target directory name (default: backtest-kit-project)
4162
-
4163
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4164
-
4165
- Docker flags (--docker):
4166
-
4167
- --output <string> Target directory name (default: backtest-kit-docker)
4168
-
4169
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4170
- tsconfig.json, and a sample strategy under content/. Run npm install then
4171
- docker compose up to start the container.
4172
-
4173
- Module hooks (loaded automatically by each mode):
4174
-
4175
- modules/backtest.module --backtest Broker adapter for backtest
4176
- modules/walker.module --walker Broker adapter for walker comparison
4177
- modules/paper.module --paper Broker adapter for paper trading
4178
- modules/live.module --live Broker adapter for live trading
4179
- modules/pine.module --pine Exchange schema for PineScript runs
4180
- modules/editor.module --editor Exchange schema for the visual Pine editor
4181
- modules/dump.module --dump Exchange schema for candle dumps
4182
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4183
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4184
-
4185
- --flush has no associated module. It only removes dump subdirectories.
4186
-
4187
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4188
-
4189
- Environment variables:
4190
-
4191
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4192
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4193
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4194
- CC_WWWROOT_PORT UI server port (default: 60050)
4195
-
4196
- Examples:
4197
-
4198
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4199
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4200
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4201
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4202
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4203
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4204
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4205
- node ${ENTRY_PATH} --editor
4206
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4207
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4208
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4209
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4210
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4211
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4212
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4213
- node ${ENTRY_PATH} --init --output my-trading-bot
4214
- node ${ENTRY_PATH} --docker --output my-docker-workspace
4102
+ const HELP_TEXT = `
4103
+ Usage:
4104
+ node index.mjs --<mode> [flags] [entry-point]
4105
+
4106
+ Modes:
4107
+
4108
+ --backtest <entry> Run strategy against historical candle data
4109
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4110
+ --paper <entry> Paper trading (live prices, no real orders)
4111
+ --live <entry> Live trading with real orders
4112
+ --pine <entry> Execute a local .pine indicator file
4113
+ --editor Open the Pine Script visual editor in the browser
4114
+ --dump Fetch and save raw OHLCV candles
4115
+ --pnldebug Simulate PnL per minute for a given entry price and direction
4116
+ --brokerdebug Fire a single broker commit against the live broker adapter
4117
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4118
+ --init Scaffold a new project in the current directory
4119
+ --docker Scaffold a Docker workspace for running strategies in a container
4120
+ --help Print this help message
4121
+
4122
+ Backtest flags:
4123
+
4124
+ --symbol <string> Trading pair (default: BTCUSDT)
4125
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
4126
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4127
+ --frame <string> Frame name from addFrameSchema (default: first registered)
4128
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4129
+ --noCache Skip candle cache warming before the run
4130
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
4131
+ --verbose Log every candle fetch to stdout
4132
+ --ui Start web dashboard at http://localhost:60050
4133
+ --telegram Send trade notifications to Telegram
4134
+
4135
+ Walker flags (--walker):
4136
+
4137
+ --symbol <string> Trading pair (default: BTCUSDT)
4138
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4139
+ --noCache Skip candle cache warming before the run
4140
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
4141
+ --verbose Log every candle fetch to stdout
4142
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4143
+ --json Save results as JSON to ./dump/<output>.json
4144
+ --markdown Save report as Markdown to ./dump/<output>.md
4145
+
4146
+ Each positional argument is a strategy entry point. All strategy files are loaded without
4147
+ changing process.cwd() — .env is read from the working directory only.
4148
+ addWalkerSchema is called automatically using the registered exchange and frame.
4149
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4150
+
4151
+ Module file ./modules/walker.module is loaded automatically if it exists.
4152
+
4153
+ Paper / Live flags:
4154
+
4155
+ --symbol <string> Trading pair (default: BTCUSDT)
4156
+ --strategy <string> Strategy name (default: first registered)
4157
+ --exchange <string> Exchange name (default: first registered)
4158
+ --verbose Log every candle fetch to stdout
4159
+ --ui Start web dashboard
4160
+ --telegram Send Telegram notifications
4161
+
4162
+ PineScript flags (--pine):
4163
+
4164
+ --symbol <string> Trading pair (default: BTCUSDT)
4165
+ --timeframe <string> Candle interval (default: 15m)
4166
+ --limit <string> Number of candles to fetch (default: 250)
4167
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4168
+ --exchange <string> Exchange name (default: first registered)
4169
+ --output <string> Output file base name without extension
4170
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
4171
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4172
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4173
+
4174
+ Only plot() calls with display=display.data_window produce output columns.
4175
+ Module file ./modules/pine.module is loaded automatically if it exists.
4176
+
4177
+ Candle dump flags (--dump):
4178
+
4179
+ --symbol <string> Trading pair (default: BTCUSDT)
4180
+ --timeframe <string> Candle interval (default: 15m)
4181
+ --limit <string> Number of candles (default: 250)
4182
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4183
+ --exchange <string> Exchange name (default: first registered)
4184
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4185
+ --json Save as JSON array to ./dump/<output>.json
4186
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4187
+
4188
+ Module file ./modules/dump.module is loaded automatically if it exists.
4189
+
4190
+ PnL debug flags (--pnldebug):
4191
+
4192
+ --symbol <string> Trading pair (default: BTCUSDT)
4193
+ --priceopen <number> Entry price (required)
4194
+ --direction <string> Position direction: long or short (default: long)
4195
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4196
+ --minutes <string> Number of 1m candles to simulate (default: 60)
4197
+ --exchange <string> Exchange name (default: first registered)
4198
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4199
+ --json Save as JSON array to ./dump/<output>.json
4200
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4201
+ --markdown Save as Markdown table to ./dump/<output>.md
4202
+
4203
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
4204
+
4205
+ Broker debug flags (--brokerdebug):
4206
+
4207
+ --symbol <string> Trading pair (default: BTCUSDT)
4208
+ --exchange <string> Exchange name (default: first registered)
4209
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4210
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4211
+ (default: signal-open)
4212
+
4213
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4214
+ the selected broker commit with synthetic payload values derived from current price.
4215
+
4216
+ Flush flags (--flush):
4217
+
4218
+ One or more positional entry points. For each entry point the following
4219
+ subdirectories are removed from <entry-dir>/dump/:
4220
+
4221
+ report log markdown agent
4222
+
4223
+ Init flags (--init):
4224
+
4225
+ --output <string> Target directory name (default: backtest-kit-project)
4226
+
4227
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4228
+
4229
+ Docker flags (--docker):
4230
+
4231
+ --output <string> Target directory name (default: backtest-kit-docker)
4232
+
4233
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4234
+ tsconfig.json, and a sample strategy under content/. Run npm install then
4235
+ docker compose up to start the container.
4236
+
4237
+ Module hooks (loaded automatically by each mode):
4238
+
4239
+ modules/backtest.module --backtest Broker adapter for backtest
4240
+ modules/walker.module --walker Broker adapter for walker comparison
4241
+ modules/paper.module --paper Broker adapter for paper trading
4242
+ modules/live.module --live Broker adapter for live trading
4243
+ modules/pine.module --pine Exchange schema for PineScript runs
4244
+ modules/editor.module --editor Exchange schema for the visual Pine editor
4245
+ modules/dump.module --dump Exchange schema for candle dumps
4246
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4247
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4248
+
4249
+ --flush has no associated module. It only removes dump subdirectories.
4250
+
4251
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4252
+
4253
+ Environment variables:
4254
+
4255
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4256
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4257
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4258
+ CC_WWWROOT_PORT UI server port (default: 60050)
4259
+
4260
+ Examples:
4261
+
4262
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4263
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4264
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4265
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4266
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4267
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4268
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4269
+ node ${ENTRY_PATH} --editor
4270
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4271
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4272
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4273
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4274
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4275
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4276
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4277
+ node ${ENTRY_PATH} --init --output my-trading-bot
4278
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4215
4279
  `.trimStart();
4216
4280
  const main$1 = async () => {
4217
4281
  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)))) {
@@ -4221,7 +4285,7 @@ const main$1 = async () => {
4221
4285
  if (!values.help) {
4222
4286
  return;
4223
4287
  }
4224
- process.stdout.write(`@backtest-kit/cli ${"9.6.0"}\n\n`);
4288
+ process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n\n`);
4225
4289
  process.stdout.write(HELP_TEXT);
4226
4290
  process.exit(0);
4227
4291
  };
@@ -4235,7 +4299,7 @@ const main = async () => {
4235
4299
  if (!values.version) {
4236
4300
  return;
4237
4301
  }
4238
- process.stdout.write(`@backtest-kit/cli ${"9.6.0"}\n`);
4302
+ process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n`);
4239
4303
  process.exit(0);
4240
4304
  };
4241
4305
  main();