@backtest-kit/cli 9.8.3 → 9.8.4

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
@@ -3212,10 +3212,10 @@ init();
3212
3212
 
3213
3213
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3214
3214
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3215
- const HELP_TEXT$1 = `
3216
- Example:
3217
-
3218
- node ${ENTRY_PATH$1} --help
3215
+ const HELP_TEXT$1 = `
3216
+ Example:
3217
+
3218
+ node ${ENTRY_PATH$1} --help
3219
3219
  `.trimStart();
3220
3220
  const main$g = async () => {
3221
3221
  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)))) {
@@ -3225,7 +3225,7 @@ const main$g = async () => {
3225
3225
  if (MODES.some((mode) => values[mode])) {
3226
3226
  return;
3227
3227
  }
3228
- process.stdout.write(`@backtest-kit/cli ${"9.8.3"}\n`);
3228
+ process.stdout.write(`@backtest-kit/cli ${"9.8.4"}\n`);
3229
3229
  process.stdout.write("\n");
3230
3230
  process.stdout.write(`Run with --help to see available commands.\n`);
3231
3231
  process.stdout.write("\n");
@@ -4164,183 +4164,183 @@ const main$2 = async () => {
4164
4164
  main$2();
4165
4165
 
4166
4166
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
4167
- const HELP_TEXT = `
4168
- Usage:
4169
- node index.mjs --<mode> [flags] [entry-point]
4170
-
4171
- Modes:
4172
-
4173
- --backtest <entry> Run strategy against historical candle data
4174
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4175
- --paper <entry> Paper trading (live prices, no real orders)
4176
- --live <entry> Live trading with real orders
4177
- --pine <entry> Execute a local .pine indicator file
4178
- --editor Open the Pine Script visual editor in the browser
4179
- --dump Fetch and save raw OHLCV candles
4180
- --pnldebug Simulate PnL per minute for a given entry price and direction
4181
- --brokerdebug Fire a single broker commit against the live broker adapter
4182
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4183
- --init Scaffold a new project in the current directory
4184
- --docker Scaffold a Docker workspace for running strategies in a container
4185
- --help Print this help message
4186
-
4187
- Backtest flags:
4188
-
4189
- --symbol <string> Trading pair (default: BTCUSDT)
4190
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
4191
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4192
- --frame <string> Frame name from addFrameSchema (default: first registered)
4193
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4194
- --noCache Skip candle cache warming before the run
4195
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
4196
- --verbose Log every candle fetch to stdout
4197
- --ui Start web dashboard at http://localhost:60050
4198
- --telegram Send trade notifications to Telegram
4199
-
4200
- Walker flags (--walker):
4201
-
4202
- --symbol <string> Trading pair (default: BTCUSDT)
4203
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4204
- --noCache Skip candle cache warming before the run
4205
- --noFlush Skip removing report/log/markdown/agent folders before walker run
4206
- --verbose Log every candle fetch to stdout
4207
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4208
- --json Save results as JSON to ./dump/<output>.json
4209
- --markdown Save report as Markdown to ./dump/<output>.md
4210
-
4211
- Each positional argument is a strategy entry point. All strategy files are loaded without
4212
- changing process.cwd() — .env is read from the working directory only.
4213
- addWalkerSchema is called automatically using the registered exchange and frame.
4214
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4215
-
4216
- Module file ./modules/walker.module is loaded automatically if it exists.
4217
-
4218
- Paper / Live flags:
4219
-
4220
- --symbol <string> Trading pair (default: BTCUSDT)
4221
- --strategy <string> Strategy name (default: first registered)
4222
- --exchange <string> Exchange name (default: first registered)
4223
- --verbose Log every candle fetch to stdout
4224
- --ui Start web dashboard
4225
- --telegram Send Telegram notifications
4226
-
4227
- PineScript flags (--pine):
4228
-
4229
- --symbol <string> Trading pair (default: BTCUSDT)
4230
- --timeframe <string> Candle interval (default: 15m)
4231
- --limit <string> Number of candles to fetch (default: 250)
4232
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4233
- --exchange <string> Exchange name (default: first registered)
4234
- --output <string> Output file base name without extension
4235
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
4236
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4237
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4238
-
4239
- Only plot() calls with display=display.data_window produce output columns.
4240
- Module file ./modules/pine.module is loaded automatically if it exists.
4241
-
4242
- Candle dump flags (--dump):
4243
-
4244
- --symbol <string> Trading pair (default: BTCUSDT)
4245
- --timeframe <string> Candle interval (default: 15m)
4246
- --limit <string> Number of candles (default: 250)
4247
- --when <string> End date — ISO 8601 or Unix ms (default: now)
4248
- --exchange <string> Exchange name (default: first registered)
4249
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4250
- --json Save as JSON array to ./dump/<output>.json
4251
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4252
-
4253
- Module file ./modules/dump.module is loaded automatically if it exists.
4254
-
4255
- PnL debug flags (--pnldebug):
4256
-
4257
- --symbol <string> Trading pair (default: BTCUSDT)
4258
- --priceopen <number> Entry price (required)
4259
- --direction <string> Position direction: long or short (default: long)
4260
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4261
- --minutes <string> Number of 1m candles to simulate (default: 60)
4262
- --exchange <string> Exchange name (default: first registered)
4263
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4264
- --json Save as JSON array to ./dump/<output>.json
4265
- --jsonl Save as JSONL to ./dump/<output>.jsonl
4266
- --markdown Save as Markdown table to ./dump/<output>.md
4267
-
4268
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
4269
-
4270
- Broker debug flags (--brokerdebug):
4271
-
4272
- --symbol <string> Trading pair (default: BTCUSDT)
4273
- --exchange <string> Exchange name (default: first registered)
4274
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4275
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4276
- (default: signal-open)
4277
-
4278
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4279
- the selected broker commit with synthetic payload values derived from current price.
4280
-
4281
- Flush flags (--flush):
4282
-
4283
- One or more positional entry points. For each entry point the following
4284
- subdirectories are removed from <entry-dir>/dump/:
4285
-
4286
- report log markdown agent
4287
-
4288
- Init flags (--init):
4289
-
4290
- --output <string> Target directory name (default: backtest-kit-project)
4291
-
4292
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4293
-
4294
- Docker flags (--docker):
4295
-
4296
- --output <string> Target directory name (default: backtest-kit-docker)
4297
-
4298
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4299
- tsconfig.json, and a sample strategy under content/. Run npm install then
4300
- docker compose up to start the container.
4301
-
4302
- Module hooks (loaded automatically by each mode):
4303
-
4304
- modules/backtest.module --backtest Broker adapter for backtest
4305
- modules/walker.module --walker Broker adapter for walker comparison
4306
- modules/paper.module --paper Broker adapter for paper trading
4307
- modules/live.module --live Broker adapter for live trading
4308
- modules/pine.module --pine Exchange schema for PineScript runs
4309
- modules/editor.module --editor Exchange schema for the visual Pine editor
4310
- modules/dump.module --dump Exchange schema for candle dumps
4311
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4312
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4313
-
4314
- --flush has no associated module. It only removes dump subdirectories.
4315
-
4316
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4317
-
4318
- Environment variables:
4319
-
4320
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4321
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4322
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4323
- CC_WWWROOT_PORT UI server port (default: 60050)
4324
-
4325
- Examples:
4326
-
4327
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4328
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4329
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4330
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4331
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4332
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4333
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4334
- node ${ENTRY_PATH} --editor
4335
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4336
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4337
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4338
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4339
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4340
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4341
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4342
- node ${ENTRY_PATH} --init --output my-trading-bot
4343
- node ${ENTRY_PATH} --docker --output my-docker-workspace
4167
+ const HELP_TEXT = `
4168
+ Usage:
4169
+ node index.mjs --<mode> [flags] [entry-point]
4170
+
4171
+ Modes:
4172
+
4173
+ --backtest <entry> Run strategy against historical candle data
4174
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
4175
+ --paper <entry> Paper trading (live prices, no real orders)
4176
+ --live <entry> Live trading with real orders
4177
+ --pine <entry> Execute a local .pine indicator file
4178
+ --editor Open the Pine Script visual editor in the browser
4179
+ --dump Fetch and save raw OHLCV candles
4180
+ --pnldebug Simulate PnL per minute for a given entry price and direction
4181
+ --brokerdebug Fire a single broker commit against the live broker adapter
4182
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
4183
+ --init Scaffold a new project in the current directory
4184
+ --docker Scaffold a Docker workspace for running strategies in a container
4185
+ --help Print this help message
4186
+
4187
+ Backtest flags:
4188
+
4189
+ --symbol <string> Trading pair (default: BTCUSDT)
4190
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
4191
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
4192
+ --frame <string> Frame name from addFrameSchema (default: first registered)
4193
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4194
+ --noCache Skip candle cache warming before the run
4195
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
4196
+ --verbose Log every candle fetch to stdout
4197
+ --ui Start web dashboard at http://localhost:60050
4198
+ --telegram Send trade notifications to Telegram
4199
+
4200
+ Walker flags (--walker):
4201
+
4202
+ --symbol <string> Trading pair (default: BTCUSDT)
4203
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
4204
+ --noCache Skip candle cache warming before the run
4205
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
4206
+ --verbose Log every candle fetch to stdout
4207
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
4208
+ --json Save results as JSON to ./dump/<output>.json
4209
+ --markdown Save report as Markdown to ./dump/<output>.md
4210
+
4211
+ Each positional argument is a strategy entry point. All strategy files are loaded without
4212
+ changing process.cwd() — .env is read from the working directory only.
4213
+ addWalkerSchema is called automatically using the registered exchange and frame.
4214
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
4215
+
4216
+ Module file ./modules/walker.module is loaded automatically if it exists.
4217
+
4218
+ Paper / Live flags:
4219
+
4220
+ --symbol <string> Trading pair (default: BTCUSDT)
4221
+ --strategy <string> Strategy name (default: first registered)
4222
+ --exchange <string> Exchange name (default: first registered)
4223
+ --verbose Log every candle fetch to stdout
4224
+ --ui Start web dashboard
4225
+ --telegram Send Telegram notifications
4226
+
4227
+ PineScript flags (--pine):
4228
+
4229
+ --symbol <string> Trading pair (default: BTCUSDT)
4230
+ --timeframe <string> Candle interval (default: 15m)
4231
+ --limit <string> Number of candles to fetch (default: 250)
4232
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4233
+ --exchange <string> Exchange name (default: first registered)
4234
+ --output <string> Output file base name without extension
4235
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
4236
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
4237
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
4238
+
4239
+ Only plot() calls with display=display.data_window produce output columns.
4240
+ Module file ./modules/pine.module is loaded automatically if it exists.
4241
+
4242
+ Candle dump flags (--dump):
4243
+
4244
+ --symbol <string> Trading pair (default: BTCUSDT)
4245
+ --timeframe <string> Candle interval (default: 15m)
4246
+ --limit <string> Number of candles (default: 250)
4247
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
4248
+ --exchange <string> Exchange name (default: first registered)
4249
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
4250
+ --json Save as JSON array to ./dump/<output>.json
4251
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4252
+
4253
+ Module file ./modules/dump.module is loaded automatically if it exists.
4254
+
4255
+ PnL debug flags (--pnldebug):
4256
+
4257
+ --symbol <string> Trading pair (default: BTCUSDT)
4258
+ --priceopen <number> Entry price (required)
4259
+ --direction <string> Position direction: long or short (default: long)
4260
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
4261
+ --minutes <string> Number of 1m candles to simulate (default: 60)
4262
+ --exchange <string> Exchange name (default: first registered)
4263
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
4264
+ --json Save as JSON array to ./dump/<output>.json
4265
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
4266
+ --markdown Save as Markdown table to ./dump/<output>.md
4267
+
4268
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
4269
+
4270
+ Broker debug flags (--brokerdebug):
4271
+
4272
+ --symbol <string> Trading pair (default: BTCUSDT)
4273
+ --exchange <string> Exchange name (default: first registered)
4274
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
4275
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
4276
+ (default: signal-open)
4277
+
4278
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
4279
+ the selected broker commit with synthetic payload values derived from current price.
4280
+
4281
+ Flush flags (--flush):
4282
+
4283
+ One or more positional entry points. For each entry point the following
4284
+ subdirectories are removed from <entry-dir>/dump/:
4285
+
4286
+ report log markdown agent
4287
+
4288
+ Init flags (--init):
4289
+
4290
+ --output <string> Target directory name (default: backtest-kit-project)
4291
+
4292
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
4293
+
4294
+ Docker flags (--docker):
4295
+
4296
+ --output <string> Target directory name (default: backtest-kit-docker)
4297
+
4298
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
4299
+ tsconfig.json, and a sample strategy under content/. Run npm install then
4300
+ docker compose up to start the container.
4301
+
4302
+ Module hooks (loaded automatically by each mode):
4303
+
4304
+ modules/backtest.module --backtest Broker adapter for backtest
4305
+ modules/walker.module --walker Broker adapter for walker comparison
4306
+ modules/paper.module --paper Broker adapter for paper trading
4307
+ modules/live.module --live Broker adapter for live trading
4308
+ modules/pine.module --pine Exchange schema for PineScript runs
4309
+ modules/editor.module --editor Exchange schema for the visual Pine editor
4310
+ modules/dump.module --dump Exchange schema for candle dumps
4311
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
4312
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
4313
+
4314
+ --flush has no associated module. It only removes dump subdirectories.
4315
+
4316
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
4317
+
4318
+ Environment variables:
4319
+
4320
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
4321
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
4322
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
4323
+ CC_WWWROOT_PORT UI server port (default: 60050)
4324
+
4325
+ Examples:
4326
+
4327
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4328
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4329
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4330
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4331
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4332
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4333
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4334
+ node ${ENTRY_PATH} --editor
4335
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4336
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4337
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4338
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4339
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4340
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4341
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4342
+ node ${ENTRY_PATH} --init --output my-trading-bot
4343
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4344
4344
  `.trimStart();
4345
4345
  const main$1 = async () => {
4346
4346
  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)))) {
@@ -4350,7 +4350,7 @@ const main$1 = async () => {
4350
4350
  if (!values.help) {
4351
4351
  return;
4352
4352
  }
4353
- process.stdout.write(`@backtest-kit/cli ${"9.8.3"}\n\n`);
4353
+ process.stdout.write(`@backtest-kit/cli ${"9.8.4"}\n\n`);
4354
4354
  process.stdout.write(HELP_TEXT);
4355
4355
  process.exit(0);
4356
4356
  };
@@ -4364,7 +4364,7 @@ const main = async () => {
4364
4364
  if (!values.version) {
4365
4365
  return;
4366
4366
  }
4367
- process.stdout.write(`@backtest-kit/cli ${"9.8.3"}\n`);
4367
+ process.stdout.write(`@backtest-kit/cli ${"9.8.4"}\n`);
4368
4368
  process.exit(0);
4369
4369
  };
4370
4370
  main();