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