@backtest-kit/cli 8.0.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.mjs CHANGED
@@ -561,6 +561,14 @@ const getArgs = singleshot(() => {
561
561
  type: "string",
562
562
  default: "",
563
563
  },
564
+ brokerdebug: {
565
+ type: "boolean",
566
+ default: false,
567
+ },
568
+ commit: {
569
+ type: "string",
570
+ default: "",
571
+ },
564
572
  init: {
565
573
  type: "boolean",
566
574
  default: false,
@@ -2970,12 +2978,12 @@ const cli = {
2970
2978
  };
2971
2979
  init();
2972
2980
 
2973
- const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "flush", "init", "help", "version"];
2981
+ const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "help", "version"];
2974
2982
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
2975
- const HELP_TEXT$1 = `
2976
- Example:
2977
-
2978
- node ${ENTRY_PATH$1} --help
2983
+ const HELP_TEXT$1 = `
2984
+ Example:
2985
+
2986
+ node ${ENTRY_PATH$1} --help
2979
2987
  `.trimStart();
2980
2988
  const main$e = async () => {
2981
2989
  if (!getEntry(import.meta.url)) {
@@ -2985,7 +2993,7 @@ const main$e = async () => {
2985
2993
  if (MODES.some((mode) => values[mode])) {
2986
2994
  return;
2987
2995
  }
2988
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n`);
2996
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
2989
2997
  process.stdout.write("\n");
2990
2998
  process.stdout.write(`Run with --help to see available commands.\n`);
2991
2999
  process.stdout.write("\n");
@@ -3603,158 +3611,173 @@ const main$2 = async () => {
3603
3611
  main$2();
3604
3612
 
3605
3613
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
3606
- const HELP_TEXT = `
3607
- Usage:
3608
- node index.mjs --<mode> [flags] [entry-point]
3609
-
3610
- Modes:
3611
-
3612
- --backtest <entry> Run strategy against historical candle data
3613
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3614
- --paper <entry> Paper trading (live prices, no real orders)
3615
- --live <entry> Live trading with real orders
3616
- --pine <entry> Execute a local .pine indicator file
3617
- --editor Open the Pine Script visual editor in the browser
3618
- --dump Fetch and save raw OHLCV candles
3619
- --pnldebug Simulate PnL per minute for a given entry price and direction
3620
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3621
- --init Scaffold a new project in the current directory
3622
- --help Print this help message
3623
-
3624
- Backtest flags:
3625
-
3626
- --symbol <string> Trading pair (default: BTCUSDT)
3627
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
3628
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3629
- --frame <string> Frame name from addFrameSchema (default: first registered)
3630
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3631
- --noCache Skip candle cache warming before the run
3632
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
3633
- --verbose Log every candle fetch to stdout
3634
- --ui Start web dashboard at http://localhost:60050
3635
- --telegram Send trade notifications to Telegram
3636
-
3637
- Walker flags (--walker):
3638
-
3639
- --symbol <string> Trading pair (default: BTCUSDT)
3640
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3641
- --noCache Skip candle cache warming before the run
3642
- --noFlush Skip removing report/log/markdown/agent folders before walker run
3643
- --verbose Log every candle fetch to stdout
3644
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3645
- --json Save results as JSON to ./dump/<output>.json
3646
- --markdown Save report as Markdown to ./dump/<output>.md
3647
-
3648
- Each positional argument is a strategy entry point. All strategy files are loaded without
3649
- changing process.cwd() .env is read from the working directory only.
3650
- addWalkerSchema is called automatically using the registered exchange and frame.
3651
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3652
-
3653
- Module file ./modules/walker.module is loaded automatically if it exists.
3654
-
3655
- Paper / Live flags:
3656
-
3657
- --symbol <string> Trading pair (default: BTCUSDT)
3658
- --strategy <string> Strategy name (default: first registered)
3659
- --exchange <string> Exchange name (default: first registered)
3660
- --verbose Log every candle fetch to stdout
3661
- --ui Start web dashboard
3662
- --telegram Send Telegram notifications
3663
-
3664
- PineScript flags (--pine):
3665
-
3666
- --symbol <string> Trading pair (default: BTCUSDT)
3667
- --timeframe <string> Candle interval (default: 15m)
3668
- --limit <string> Number of candles to fetch (default: 250)
3669
- --when <string> End date ISO 8601 or Unix ms (default: now)
3670
- --exchange <string> Exchange name (default: first registered)
3671
- --output <string> Output file base name without extension
3672
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
3673
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3674
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3675
-
3676
- Only plot() calls with display=display.data_window produce output columns.
3677
- Module file ./modules/pine.module is loaded automatically if it exists.
3678
-
3679
- Candle dump flags (--dump):
3680
-
3681
- --symbol <string> Trading pair (default: BTCUSDT)
3682
- --timeframe <string> Candle interval (default: 15m)
3683
- --limit <string> Number of candles (default: 250)
3684
- --when <string> End date ISO 8601 or Unix ms (default: now)
3685
- --exchange <string> Exchange name (default: first registered)
3686
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3687
- --json Save as JSON array to ./dump/<output>.json
3688
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3689
-
3690
- Module file ./modules/dump.module is loaded automatically if it exists.
3691
-
3692
- PnL debug flags (--pnldebug):
3693
-
3694
- --symbol <string> Trading pair (default: BTCUSDT)
3695
- --priceopen <number> Entry price (required)
3696
- --direction <string> Position direction: long or short (default: long)
3697
- --when <string> Start timestamp ISO 8601 or Unix ms (default: now)
3698
- --minutes <string> Number of 1m candles to simulate (default: 60)
3699
- --exchange <string> Exchange name (default: first registered)
3700
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3701
- --json Save as JSON array to ./dump/<output>.json
3702
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3703
- --markdown Save as Markdown table to ./dump/<output>.md
3704
-
3705
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
3706
-
3707
- Flush flags (--flush):
3708
-
3709
- One or more positional entry points. For each entry point the following
3710
- subdirectories are removed from <entry-dir>/dump/:
3711
-
3712
- report log markdown agent
3713
-
3714
- Init flags (--init):
3715
-
3716
- --output <string> Target directory name (default: backtest-kit-project)
3717
-
3718
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3719
-
3720
- Module hooks (loaded automatically by each mode):
3721
-
3722
- modules/backtest.module --backtest Broker adapter for backtest
3723
- modules/walker.module --walker Broker adapter for walker comparison
3724
- modules/paper.module --paper Broker adapter for paper trading
3725
- modules/live.module --live Broker adapter for live trading
3726
- modules/pine.module --pine Exchange schema for PineScript runs
3727
- modules/editor.module --editor Exchange schema for the visual Pine editor
3728
- modules/dump.module --dump Exchange schema for candle dumps
3729
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3730
-
3731
- --flush has no associated module. It only removes dump subdirectories.
3732
-
3733
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3734
-
3735
- Environment variables:
3736
-
3737
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3738
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3739
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3740
- CC_WWWROOT_PORT UI server port (default: 60050)
3741
-
3742
- Examples:
3743
-
3744
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
3745
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
3746
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
3747
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
3748
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
3749
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
3750
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
3751
- node ${ENTRY_PATH} --editor
3752
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3753
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3754
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
3755
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3756
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3757
- node ${ENTRY_PATH} --init --output my-trading-bot
3614
+ const HELP_TEXT = `
3615
+ Usage:
3616
+ node index.mjs --<mode> [flags] [entry-point]
3617
+
3618
+ Modes:
3619
+
3620
+ --backtest <entry> Run strategy against historical candle data
3621
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3622
+ --paper <entry> Paper trading (live prices, no real orders)
3623
+ --live <entry> Live trading with real orders
3624
+ --pine <entry> Execute a local .pine indicator file
3625
+ --editor Open the Pine Script visual editor in the browser
3626
+ --dump Fetch and save raw OHLCV candles
3627
+ --pnldebug Simulate PnL per minute for a given entry price and direction
3628
+ --brokerdebug Fire a single broker commit against the live broker adapter
3629
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3630
+ --init Scaffold a new project in the current directory
3631
+ --help Print this help message
3632
+
3633
+ Backtest flags:
3634
+
3635
+ --symbol <string> Trading pair (default: BTCUSDT)
3636
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
3637
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3638
+ --frame <string> Frame name from addFrameSchema (default: first registered)
3639
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3640
+ --noCache Skip candle cache warming before the run
3641
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
3642
+ --verbose Log every candle fetch to stdout
3643
+ --ui Start web dashboard at http://localhost:60050
3644
+ --telegram Send trade notifications to Telegram
3645
+
3646
+ Walker flags (--walker):
3647
+
3648
+ --symbol <string> Trading pair (default: BTCUSDT)
3649
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3650
+ --noCache Skip candle cache warming before the run
3651
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
3652
+ --verbose Log every candle fetch to stdout
3653
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3654
+ --json Save results as JSON to ./dump/<output>.json
3655
+ --markdown Save report as Markdown to ./dump/<output>.md
3656
+
3657
+ Each positional argument is a strategy entry point. All strategy files are loaded without
3658
+ changing process.cwd() — .env is read from the working directory only.
3659
+ addWalkerSchema is called automatically using the registered exchange and frame.
3660
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3661
+
3662
+ Module file ./modules/walker.module is loaded automatically if it exists.
3663
+
3664
+ Paper / Live flags:
3665
+
3666
+ --symbol <string> Trading pair (default: BTCUSDT)
3667
+ --strategy <string> Strategy name (default: first registered)
3668
+ --exchange <string> Exchange name (default: first registered)
3669
+ --verbose Log every candle fetch to stdout
3670
+ --ui Start web dashboard
3671
+ --telegram Send Telegram notifications
3672
+
3673
+ PineScript flags (--pine):
3674
+
3675
+ --symbol <string> Trading pair (default: BTCUSDT)
3676
+ --timeframe <string> Candle interval (default: 15m)
3677
+ --limit <string> Number of candles to fetch (default: 250)
3678
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3679
+ --exchange <string> Exchange name (default: first registered)
3680
+ --output <string> Output file base name without extension
3681
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
3682
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3683
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3684
+
3685
+ Only plot() calls with display=display.data_window produce output columns.
3686
+ Module file ./modules/pine.module is loaded automatically if it exists.
3687
+
3688
+ Candle dump flags (--dump):
3689
+
3690
+ --symbol <string> Trading pair (default: BTCUSDT)
3691
+ --timeframe <string> Candle interval (default: 15m)
3692
+ --limit <string> Number of candles (default: 250)
3693
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3694
+ --exchange <string> Exchange name (default: first registered)
3695
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3696
+ --json Save as JSON array to ./dump/<output>.json
3697
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3698
+
3699
+ Module file ./modules/dump.module is loaded automatically if it exists.
3700
+
3701
+ PnL debug flags (--pnldebug):
3702
+
3703
+ --symbol <string> Trading pair (default: BTCUSDT)
3704
+ --priceopen <number> Entry price (required)
3705
+ --direction <string> Position direction: long or short (default: long)
3706
+ --when <string> Start timestamp ISO 8601 or Unix ms (default: now)
3707
+ --minutes <string> Number of 1m candles to simulate (default: 60)
3708
+ --exchange <string> Exchange name (default: first registered)
3709
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3710
+ --json Save as JSON array to ./dump/<output>.json
3711
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3712
+ --markdown Save as Markdown table to ./dump/<output>.md
3713
+
3714
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
3715
+
3716
+ Broker debug flags (--brokerdebug):
3717
+
3718
+ --symbol <string> Trading pair (default: BTCUSDT)
3719
+ --exchange <string> Exchange name (default: first registered)
3720
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3721
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3722
+ (default: signal-open)
3723
+
3724
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3725
+ the selected broker commit with synthetic payload values derived from current price.
3726
+
3727
+ Flush flags (--flush):
3728
+
3729
+ One or more positional entry points. For each entry point the following
3730
+ subdirectories are removed from <entry-dir>/dump/:
3731
+
3732
+ report log markdown agent
3733
+
3734
+ Init flags (--init):
3735
+
3736
+ --output <string> Target directory name (default: backtest-kit-project)
3737
+
3738
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3739
+
3740
+ Module hooks (loaded automatically by each mode):
3741
+
3742
+ modules/backtest.module --backtest Broker adapter for backtest
3743
+ modules/walker.module --walker Broker adapter for walker comparison
3744
+ modules/paper.module --paper Broker adapter for paper trading
3745
+ modules/live.module --live Broker adapter for live trading
3746
+ modules/pine.module --pine Exchange schema for PineScript runs
3747
+ modules/editor.module --editor Exchange schema for the visual Pine editor
3748
+ modules/dump.module --dump Exchange schema for candle dumps
3749
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3750
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3751
+
3752
+ --flush has no associated module. It only removes dump subdirectories.
3753
+
3754
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3755
+
3756
+ Environment variables:
3757
+
3758
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3759
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3760
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3761
+ CC_WWWROOT_PORT UI server port (default: 60050)
3762
+
3763
+ Examples:
3764
+
3765
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
3766
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
3767
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
3768
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
3769
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
3770
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
3771
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
3772
+ node ${ENTRY_PATH} --editor
3773
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3774
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3775
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
3776
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
3777
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
3778
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3779
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3780
+ node ${ENTRY_PATH} --init --output my-trading-bot
3758
3781
  `.trimStart();
3759
3782
  const main$1 = async () => {
3760
3783
  if (!getEntry(import.meta.url)) {
@@ -3764,7 +3787,7 @@ const main$1 = async () => {
3764
3787
  if (!values.help) {
3765
3788
  return;
3766
3789
  }
3767
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n\n`);
3790
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n\n`);
3768
3791
  process.stdout.write(HELP_TEXT);
3769
3792
  process.exit(0);
3770
3793
  };
@@ -3778,7 +3801,7 @@ const main = async () => {
3778
3801
  if (!values.version) {
3779
3802
  return;
3780
3803
  }
3781
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n`);
3804
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
3782
3805
  process.exit(0);
3783
3806
  };
3784
3807
  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
+ };