@backtest-kit/cli 9.7.0 → 9.8.1

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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import * as BacktestKit from 'backtest-kit';
3
- import { setConfig, Notification, Recent, Storage, Markdown, Report, Dump, State, Memory, MarkdownWriter, ReportWriter, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistIntervalAdapter, PersistMemoryAdapter, PersistRecentAdapter, PersistStateAdapter, PersistSessionAdapter, Log, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, RecentLive, RecentBacktest, SessionLive, SessionBacktest, MemoryLive, MemoryBacktest, StateLive, StateBacktest, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, System, Cache, Interval, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, listenSignalNotify, Exchange } from 'backtest-kit';
3
+ import { setConfig, Notification, Recent, Storage, Markdown, Report, Dump, State, Memory, MarkdownWriter, ReportWriter, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistIntervalAdapter, PersistMemoryAdapter, PersistRecentAdapter, PersistStateAdapter, PersistSessionAdapter, Log, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, RecentLive, RecentBacktest, Broker, SessionLive, SessionBacktest, MemoryLive, MemoryBacktest, StateLive, StateBacktest, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, System, Cache, Interval, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, listenSignalNotify, Exchange } from 'backtest-kit';
4
4
  import { getErrorMessage, errorData, singleshot, str, BehaviorSubject, compose, createAwaiter, execpool, queued, sleep, randomString, TIMEOUT_SYMBOL, typo, retry, trycatch, memoize, isObject } from 'functools-kit';
5
5
  import fs, { constants, realpathSync } from 'fs';
6
6
  import * as stackTrace from 'stack-trace';
@@ -358,6 +358,9 @@ class SetupUtils {
358
358
  RecentLive.clear();
359
359
  RecentBacktest.clear();
360
360
  }
361
+ {
362
+ Broker.clear();
363
+ }
361
364
  };
362
365
  this.update = () => {
363
366
  cli.loggerService.debug("SetupUtils update");
@@ -2622,14 +2625,29 @@ class BabelService {
2622
2625
  }
2623
2626
  }
2624
2627
 
2625
- const require = createRequire(import.meta.url);
2626
2628
  const ModuleWithCache = Module;
2629
+ const LOOKUP_PATHS = ModuleWithCache._nodeModulePaths(process.cwd());
2630
+ const VIRTUAL_MAP = new Map();
2631
+ {
2632
+ const originalResolveFilename = ModuleWithCache._resolveFilename;
2633
+ ModuleWithCache._resolveFilename = function (request, parent, isMain, options) {
2634
+ const virtualKey = VIRTUAL_MAP.get(request);
2635
+ if (virtualKey) {
2636
+ return virtualKey;
2637
+ }
2638
+ return originalResolveFilename.call(this, request, parent, isMain, options);
2639
+ };
2640
+ }
2627
2641
  function overrideModule(moduleName, newExports) {
2628
2642
  const cache = ModuleWithCache._cache;
2629
- const key = require.resolve(moduleName);
2643
+ const resolved = ModuleWithCache._findPath(moduleName, LOOKUP_PATHS, false);
2644
+ const key = resolved || moduleName;
2645
+ VIRTUAL_MAP.set(moduleName, key);
2630
2646
  if (!cache[key]) {
2631
2647
  cache[key] = new ModuleWithCache(key);
2632
2648
  cache[key].loaded = true;
2649
+ cache[key].filename = key;
2650
+ cache[key].paths = [];
2633
2651
  }
2634
2652
  cache[key].exports = newExports;
2635
2653
  }
@@ -3163,10 +3181,10 @@ init();
3163
3181
 
3164
3182
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3165
3183
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3166
- const HELP_TEXT$1 = `
3167
- Example:
3168
-
3169
- node ${ENTRY_PATH$1} --help
3184
+ const HELP_TEXT$1 = `
3185
+ Example:
3186
+
3187
+ node ${ENTRY_PATH$1} --help
3170
3188
  `.trimStart();
3171
3189
  const main$g = async () => {
3172
3190
  if (!getEntry(import.meta.url)) {
@@ -3176,7 +3194,7 @@ const main$g = async () => {
3176
3194
  if (MODES.some((mode) => values[mode])) {
3177
3195
  return;
3178
3196
  }
3179
- process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n`);
3197
+ process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n`);
3180
3198
  process.stdout.write("\n");
3181
3199
  process.stdout.write(`Run with --help to see available commands.\n`);
3182
3200
  process.stdout.write("\n");
@@ -3461,12 +3479,6 @@ const main$a = async () => {
3461
3479
  if (!entryPoints.length) {
3462
3480
  throw new Error("At least one entry point is required");
3463
3481
  }
3464
- for (const entryPoint of entryPoints) {
3465
- if (values.noFlush) {
3466
- continue;
3467
- }
3468
- await flush(entryPoint);
3469
- }
3470
3482
  await cli.configConnectionService.loadConfig("setup.config");
3471
3483
  {
3472
3484
  const loader = await cli.configConnectionService.loadConfig("loader.config");
@@ -3483,10 +3495,23 @@ const main$a = async () => {
3483
3495
  }
3484
3496
  cli.frontendProviderService.connect();
3485
3497
  cli.telegramProviderService.connect();
3498
+ const cwd = process.cwd();
3486
3499
  {
3487
- const cwd = process.cwd();
3488
3500
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
3489
3501
  }
3502
+ if (entryPoints.length === 1) {
3503
+ const absolutePath = path.resolve(entryPoints[0]);
3504
+ const moduleRoot = path.dirname(absolutePath);
3505
+ process.chdir(moduleRoot);
3506
+ cwd !== moduleRoot && Setup.update();
3507
+ dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
3508
+ }
3509
+ for (const entryPoint of entryPoints) {
3510
+ if (values.noFlush) {
3511
+ continue;
3512
+ }
3513
+ await flush(entryPoint);
3514
+ }
3490
3515
  await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
3491
3516
  listenFinish();
3492
3517
  createGracefulShutdown(mode)();
@@ -4070,183 +4095,183 @@ const main$2 = async () => {
4070
4095
  main$2();
4071
4096
 
4072
4097
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
4073
- const HELP_TEXT = `
4074
- Usage:
4075
- node index.mjs --<mode> [flags] [entry-point]
4076
-
4077
- Modes:
4078
-
4079
- --backtest <entry> Run strategy against historical candle data
4080
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4081
- --paper <entry> Paper trading (live prices, no real orders)
4082
- --live <entry> Live trading with real orders
4083
- --pine <entry> Execute a local .pine indicator file
4084
- --editor Open the Pine Script visual editor in the browser
4085
- --dump Fetch and save raw OHLCV candles
4086
- --pnldebug Simulate PnL per minute for a given entry price and direction
4087
- --brokerdebug Fire a single broker commit against the live broker adapter
4088
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4089
- --init Scaffold a new project in the current directory
4090
- --docker Scaffold a Docker workspace for running strategies in a container
4091
- --help Print this help message
4092
-
4093
- Backtest flags:
4094
-
4095
- --symbol <string> Trading pair (default: BTCUSDT)
4096
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
4097
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4098
- --frame <string> Frame name from addFrameSchema (default: first registered)
4099
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4100
- --noCache Skip candle cache warming before the run
4101
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
4102
- --verbose Log every candle fetch to stdout
4103
- --ui Start web dashboard at http://localhost:60050
4104
- --telegram Send trade notifications to Telegram
4105
-
4106
- Walker flags (--walker):
4107
-
4108
- --symbol <string> Trading pair (default: BTCUSDT)
4109
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4110
- --noCache Skip candle cache warming before the run
4111
- --noFlush Skip removing report/log/markdown/agent folders before walker run
4112
- --verbose Log every candle fetch to stdout
4113
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4114
- --json Save results as JSON to ./dump/<output>.json
4115
- --markdown Save report as Markdown to ./dump/<output>.md
4116
-
4117
- Each positional argument is a strategy entry point. All strategy files are loaded without
4118
- changing process.cwd() — .env is read from the working directory only.
4119
- addWalkerSchema is called automatically using the registered exchange and frame.
4120
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4121
-
4122
- Module file ./modules/walker.module is loaded automatically if it exists.
4123
-
4124
- Paper / Live flags:
4125
-
4126
- --symbol <string> Trading pair (default: BTCUSDT)
4127
- --strategy <string> Strategy name (default: first registered)
4128
- --exchange <string> Exchange name (default: first registered)
4129
- --verbose Log every candle fetch to stdout
4130
- --ui Start web dashboard
4131
- --telegram Send Telegram notifications
4132
-
4133
- PineScript flags (--pine):
4134
-
4135
- --symbol <string> Trading pair (default: BTCUSDT)
4136
- --timeframe <string> Candle interval (default: 15m)
4137
- --limit <string> Number of candles to fetch (default: 250)
4138
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4139
- --exchange <string> Exchange name (default: first registered)
4140
- --output <string> Output file base name without extension
4141
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
4142
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4143
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4144
-
4145
- Only plot() calls with display=display.data_window produce output columns.
4146
- Module file ./modules/pine.module is loaded automatically if it exists.
4147
-
4148
- Candle dump flags (--dump):
4149
-
4150
- --symbol <string> Trading pair (default: BTCUSDT)
4151
- --timeframe <string> Candle interval (default: 15m)
4152
- --limit <string> Number of candles (default: 250)
4153
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4154
- --exchange <string> Exchange name (default: first registered)
4155
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4156
- --json Save as JSON array to ./dump/<output>.json
4157
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4158
-
4159
- Module file ./modules/dump.module is loaded automatically if it exists.
4160
-
4161
- PnL debug flags (--pnldebug):
4162
-
4163
- --symbol <string> Trading pair (default: BTCUSDT)
4164
- --priceopen <number> Entry price (required)
4165
- --direction <string> Position direction: long or short (default: long)
4166
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4167
- --minutes <string> Number of 1m candles to simulate (default: 60)
4168
- --exchange <string> Exchange name (default: first registered)
4169
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4170
- --json Save as JSON array to ./dump/<output>.json
4171
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4172
- --markdown Save as Markdown table to ./dump/<output>.md
4173
-
4174
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
4175
-
4176
- Broker debug flags (--brokerdebug):
4177
-
4178
- --symbol <string> Trading pair (default: BTCUSDT)
4179
- --exchange <string> Exchange name (default: first registered)
4180
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4181
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4182
- (default: signal-open)
4183
-
4184
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4185
- the selected broker commit with synthetic payload values derived from current price.
4186
-
4187
- Flush flags (--flush):
4188
-
4189
- One or more positional entry points. For each entry point the following
4190
- subdirectories are removed from <entry-dir>/dump/:
4191
-
4192
- report log markdown agent
4193
-
4194
- Init flags (--init):
4195
-
4196
- --output <string> Target directory name (default: backtest-kit-project)
4197
-
4198
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4199
-
4200
- Docker flags (--docker):
4201
-
4202
- --output <string> Target directory name (default: backtest-kit-docker)
4203
-
4204
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4205
- tsconfig.json, and a sample strategy under content/. Run npm install then
4206
- docker compose up to start the container.
4207
-
4208
- Module hooks (loaded automatically by each mode):
4209
-
4210
- modules/backtest.module --backtest Broker adapter for backtest
4211
- modules/walker.module --walker Broker adapter for walker comparison
4212
- modules/paper.module --paper Broker adapter for paper trading
4213
- modules/live.module --live Broker adapter for live trading
4214
- modules/pine.module --pine Exchange schema for PineScript runs
4215
- modules/editor.module --editor Exchange schema for the visual Pine editor
4216
- modules/dump.module --dump Exchange schema for candle dumps
4217
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4218
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4219
-
4220
- --flush has no associated module. It only removes dump subdirectories.
4221
-
4222
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4223
-
4224
- Environment variables:
4225
-
4226
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4227
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4228
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4229
- CC_WWWROOT_PORT UI server port (default: 60050)
4230
-
4231
- Examples:
4232
-
4233
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4234
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4235
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4236
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4237
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4238
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4239
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4240
- node ${ENTRY_PATH} --editor
4241
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4242
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4243
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4244
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4245
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4246
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4247
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4248
- node ${ENTRY_PATH} --init --output my-trading-bot
4249
- node ${ENTRY_PATH} --docker --output my-docker-workspace
4098
+ const HELP_TEXT = `
4099
+ Usage:
4100
+ node index.mjs --<mode> [flags] [entry-point]
4101
+
4102
+ Modes:
4103
+
4104
+ --backtest <entry> Run strategy against historical candle data
4105
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4106
+ --paper <entry> Paper trading (live prices, no real orders)
4107
+ --live <entry> Live trading with real orders
4108
+ --pine <entry> Execute a local .pine indicator file
4109
+ --editor Open the Pine Script visual editor in the browser
4110
+ --dump Fetch and save raw OHLCV candles
4111
+ --pnldebug Simulate PnL per minute for a given entry price and direction
4112
+ --brokerdebug Fire a single broker commit against the live broker adapter
4113
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4114
+ --init Scaffold a new project in the current directory
4115
+ --docker Scaffold a Docker workspace for running strategies in a container
4116
+ --help Print this help message
4117
+
4118
+ Backtest flags:
4119
+
4120
+ --symbol <string> Trading pair (default: BTCUSDT)
4121
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
4122
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4123
+ --frame <string> Frame name from addFrameSchema (default: first registered)
4124
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4125
+ --noCache Skip candle cache warming before the run
4126
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
4127
+ --verbose Log every candle fetch to stdout
4128
+ --ui Start web dashboard at http://localhost:60050
4129
+ --telegram Send trade notifications to Telegram
4130
+
4131
+ Walker flags (--walker):
4132
+
4133
+ --symbol <string> Trading pair (default: BTCUSDT)
4134
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4135
+ --noCache Skip candle cache warming before the run
4136
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
4137
+ --verbose Log every candle fetch to stdout
4138
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4139
+ --json Save results as JSON to ./dump/<output>.json
4140
+ --markdown Save report as Markdown to ./dump/<output>.md
4141
+
4142
+ Each positional argument is a strategy entry point. All strategy files are loaded without
4143
+ changing process.cwd() — .env is read from the working directory only.
4144
+ addWalkerSchema is called automatically using the registered exchange and frame.
4145
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4146
+
4147
+ Module file ./modules/walker.module is loaded automatically if it exists.
4148
+
4149
+ Paper / Live flags:
4150
+
4151
+ --symbol <string> Trading pair (default: BTCUSDT)
4152
+ --strategy <string> Strategy name (default: first registered)
4153
+ --exchange <string> Exchange name (default: first registered)
4154
+ --verbose Log every candle fetch to stdout
4155
+ --ui Start web dashboard
4156
+ --telegram Send Telegram notifications
4157
+
4158
+ PineScript flags (--pine):
4159
+
4160
+ --symbol <string> Trading pair (default: BTCUSDT)
4161
+ --timeframe <string> Candle interval (default: 15m)
4162
+ --limit <string> Number of candles to fetch (default: 250)
4163
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4164
+ --exchange <string> Exchange name (default: first registered)
4165
+ --output <string> Output file base name without extension
4166
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
4167
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4168
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4169
+
4170
+ Only plot() calls with display=display.data_window produce output columns.
4171
+ Module file ./modules/pine.module is loaded automatically if it exists.
4172
+
4173
+ Candle dump flags (--dump):
4174
+
4175
+ --symbol <string> Trading pair (default: BTCUSDT)
4176
+ --timeframe <string> Candle interval (default: 15m)
4177
+ --limit <string> Number of candles (default: 250)
4178
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4179
+ --exchange <string> Exchange name (default: first registered)
4180
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4181
+ --json Save as JSON array to ./dump/<output>.json
4182
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4183
+
4184
+ Module file ./modules/dump.module is loaded automatically if it exists.
4185
+
4186
+ PnL debug flags (--pnldebug):
4187
+
4188
+ --symbol <string> Trading pair (default: BTCUSDT)
4189
+ --priceopen <number> Entry price (required)
4190
+ --direction <string> Position direction: long or short (default: long)
4191
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4192
+ --minutes <string> Number of 1m candles to simulate (default: 60)
4193
+ --exchange <string> Exchange name (default: first registered)
4194
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4195
+ --json Save as JSON array to ./dump/<output>.json
4196
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4197
+ --markdown Save as Markdown table to ./dump/<output>.md
4198
+
4199
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
4200
+
4201
+ Broker debug flags (--brokerdebug):
4202
+
4203
+ --symbol <string> Trading pair (default: BTCUSDT)
4204
+ --exchange <string> Exchange name (default: first registered)
4205
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4206
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4207
+ (default: signal-open)
4208
+
4209
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4210
+ the selected broker commit with synthetic payload values derived from current price.
4211
+
4212
+ Flush flags (--flush):
4213
+
4214
+ One or more positional entry points. For each entry point the following
4215
+ subdirectories are removed from <entry-dir>/dump/:
4216
+
4217
+ report log markdown agent
4218
+
4219
+ Init flags (--init):
4220
+
4221
+ --output <string> Target directory name (default: backtest-kit-project)
4222
+
4223
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4224
+
4225
+ Docker flags (--docker):
4226
+
4227
+ --output <string> Target directory name (default: backtest-kit-docker)
4228
+
4229
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4230
+ tsconfig.json, and a sample strategy under content/. Run npm install then
4231
+ docker compose up to start the container.
4232
+
4233
+ Module hooks (loaded automatically by each mode):
4234
+
4235
+ modules/backtest.module --backtest Broker adapter for backtest
4236
+ modules/walker.module --walker Broker adapter for walker comparison
4237
+ modules/paper.module --paper Broker adapter for paper trading
4238
+ modules/live.module --live Broker adapter for live trading
4239
+ modules/pine.module --pine Exchange schema for PineScript runs
4240
+ modules/editor.module --editor Exchange schema for the visual Pine editor
4241
+ modules/dump.module --dump Exchange schema for candle dumps
4242
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4243
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4244
+
4245
+ --flush has no associated module. It only removes dump subdirectories.
4246
+
4247
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4248
+
4249
+ Environment variables:
4250
+
4251
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4252
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4253
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4254
+ CC_WWWROOT_PORT UI server port (default: 60050)
4255
+
4256
+ Examples:
4257
+
4258
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4259
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4260
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4261
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4262
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4263
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4264
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4265
+ node ${ENTRY_PATH} --editor
4266
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4267
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4268
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4269
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4270
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4271
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4272
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4273
+ node ${ENTRY_PATH} --init --output my-trading-bot
4274
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4250
4275
  `.trimStart();
4251
4276
  const main$1 = async () => {
4252
4277
  if (!getEntry(import.meta.url)) {
@@ -4256,7 +4281,7 @@ const main$1 = async () => {
4256
4281
  if (!values.help) {
4257
4282
  return;
4258
4283
  }
4259
- process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n\n`);
4284
+ process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n\n`);
4260
4285
  process.stdout.write(HELP_TEXT);
4261
4286
  process.exit(0);
4262
4287
  };
@@ -4270,7 +4295,7 @@ const main = async () => {
4270
4295
  if (!values.version) {
4271
4296
  return;
4272
4297
  }
4273
- process.stdout.write(`@backtest-kit/cli ${"9.7.0"}\n`);
4298
+ process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n`);
4274
4299
  process.exit(0);
4275
4300
  };
4276
4301
  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
+ };