@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.cjs CHANGED
@@ -586,6 +586,14 @@ const getArgs = functoolsKit.singleshot(() => {
586
586
  type: "string",
587
587
  default: "",
588
588
  },
589
+ brokerdebug: {
590
+ type: "boolean",
591
+ default: false,
592
+ },
593
+ commit: {
594
+ type: "string",
595
+ default: "",
596
+ },
589
597
  init: {
590
598
  type: "boolean",
591
599
  default: false,
@@ -2999,12 +3007,12 @@ const cli = {
2999
3007
  };
3000
3008
  init();
3001
3009
 
3002
- const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "flush", "init", "help", "version"];
3010
+ const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "help", "version"];
3003
3011
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3004
- const HELP_TEXT$1 = `
3005
- Example:
3006
-
3007
- node ${ENTRY_PATH$1} --help
3012
+ const HELP_TEXT$1 = `
3013
+ Example:
3014
+
3015
+ node ${ENTRY_PATH$1} --help
3008
3016
  `.trimStart();
3009
3017
  const main$e = async () => {
3010
3018
  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)))) {
@@ -3014,7 +3022,7 @@ const main$e = async () => {
3014
3022
  if (MODES.some((mode) => values[mode])) {
3015
3023
  return;
3016
3024
  }
3017
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n`);
3025
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
3018
3026
  process.stdout.write("\n");
3019
3027
  process.stdout.write(`Run with --help to see available commands.\n`);
3020
3028
  process.stdout.write("\n");
@@ -3632,158 +3640,173 @@ const main$2 = async () => {
3632
3640
  main$2();
3633
3641
 
3634
3642
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
3635
- const HELP_TEXT = `
3636
- Usage:
3637
- node index.mjs --<mode> [flags] [entry-point]
3638
-
3639
- Modes:
3640
-
3641
- --backtest <entry> Run strategy against historical candle data
3642
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3643
- --paper <entry> Paper trading (live prices, no real orders)
3644
- --live <entry> Live trading with real orders
3645
- --pine <entry> Execute a local .pine indicator file
3646
- --editor Open the Pine Script visual editor in the browser
3647
- --dump Fetch and save raw OHLCV candles
3648
- --pnldebug Simulate PnL per minute for a given entry price and direction
3649
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3650
- --init Scaffold a new project in the current directory
3651
- --help Print this help message
3652
-
3653
- Backtest flags:
3654
-
3655
- --symbol <string> Trading pair (default: BTCUSDT)
3656
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
3657
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3658
- --frame <string> Frame name from addFrameSchema (default: first registered)
3659
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3660
- --noCache Skip candle cache warming before the run
3661
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
3662
- --verbose Log every candle fetch to stdout
3663
- --ui Start web dashboard at http://localhost:60050
3664
- --telegram Send trade notifications to Telegram
3665
-
3666
- Walker flags (--walker):
3667
-
3668
- --symbol <string> Trading pair (default: BTCUSDT)
3669
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3670
- --noCache Skip candle cache warming before the run
3671
- --noFlush Skip removing report/log/markdown/agent folders before walker run
3672
- --verbose Log every candle fetch to stdout
3673
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3674
- --json Save results as JSON to ./dump/<output>.json
3675
- --markdown Save report as Markdown to ./dump/<output>.md
3676
-
3677
- Each positional argument is a strategy entry point. All strategy files are loaded without
3678
- changing process.cwd() .env is read from the working directory only.
3679
- addWalkerSchema is called automatically using the registered exchange and frame.
3680
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3681
-
3682
- Module file ./modules/walker.module is loaded automatically if it exists.
3683
-
3684
- Paper / Live flags:
3685
-
3686
- --symbol <string> Trading pair (default: BTCUSDT)
3687
- --strategy <string> Strategy name (default: first registered)
3688
- --exchange <string> Exchange name (default: first registered)
3689
- --verbose Log every candle fetch to stdout
3690
- --ui Start web dashboard
3691
- --telegram Send Telegram notifications
3692
-
3693
- PineScript flags (--pine):
3694
-
3695
- --symbol <string> Trading pair (default: BTCUSDT)
3696
- --timeframe <string> Candle interval (default: 15m)
3697
- --limit <string> Number of candles to fetch (default: 250)
3698
- --when <string> End date ISO 8601 or Unix ms (default: now)
3699
- --exchange <string> Exchange name (default: first registered)
3700
- --output <string> Output file base name without extension
3701
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
3702
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3703
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3704
-
3705
- Only plot() calls with display=display.data_window produce output columns.
3706
- Module file ./modules/pine.module is loaded automatically if it exists.
3707
-
3708
- Candle dump flags (--dump):
3709
-
3710
- --symbol <string> Trading pair (default: BTCUSDT)
3711
- --timeframe <string> Candle interval (default: 15m)
3712
- --limit <string> Number of candles (default: 250)
3713
- --when <string> End date ISO 8601 or Unix ms (default: now)
3714
- --exchange <string> Exchange name (default: first registered)
3715
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3716
- --json Save as JSON array to ./dump/<output>.json
3717
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3718
-
3719
- Module file ./modules/dump.module is loaded automatically if it exists.
3720
-
3721
- PnL debug flags (--pnldebug):
3722
-
3723
- --symbol <string> Trading pair (default: BTCUSDT)
3724
- --priceopen <number> Entry price (required)
3725
- --direction <string> Position direction: long or short (default: long)
3726
- --when <string> Start timestamp ISO 8601 or Unix ms (default: now)
3727
- --minutes <string> Number of 1m candles to simulate (default: 60)
3728
- --exchange <string> Exchange name (default: first registered)
3729
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3730
- --json Save as JSON array to ./dump/<output>.json
3731
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3732
- --markdown Save as Markdown table to ./dump/<output>.md
3733
-
3734
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
3735
-
3736
- Flush flags (--flush):
3737
-
3738
- One or more positional entry points. For each entry point the following
3739
- subdirectories are removed from <entry-dir>/dump/:
3740
-
3741
- report log markdown agent
3742
-
3743
- Init flags (--init):
3744
-
3745
- --output <string> Target directory name (default: backtest-kit-project)
3746
-
3747
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3748
-
3749
- Module hooks (loaded automatically by each mode):
3750
-
3751
- modules/backtest.module --backtest Broker adapter for backtest
3752
- modules/walker.module --walker Broker adapter for walker comparison
3753
- modules/paper.module --paper Broker adapter for paper trading
3754
- modules/live.module --live Broker adapter for live trading
3755
- modules/pine.module --pine Exchange schema for PineScript runs
3756
- modules/editor.module --editor Exchange schema for the visual Pine editor
3757
- modules/dump.module --dump Exchange schema for candle dumps
3758
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3759
-
3760
- --flush has no associated module. It only removes dump subdirectories.
3761
-
3762
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3763
-
3764
- Environment variables:
3765
-
3766
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3767
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3768
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3769
- CC_WWWROOT_PORT UI server port (default: 60050)
3770
-
3771
- Examples:
3772
-
3773
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
3774
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
3775
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
3776
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
3777
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
3778
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
3779
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
3780
- node ${ENTRY_PATH} --editor
3781
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3782
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3783
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
3784
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3785
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3786
- node ${ENTRY_PATH} --init --output my-trading-bot
3643
+ const HELP_TEXT = `
3644
+ Usage:
3645
+ node index.mjs --<mode> [flags] [entry-point]
3646
+
3647
+ Modes:
3648
+
3649
+ --backtest <entry> Run strategy against historical candle data
3650
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3651
+ --paper <entry> Paper trading (live prices, no real orders)
3652
+ --live <entry> Live trading with real orders
3653
+ --pine <entry> Execute a local .pine indicator file
3654
+ --editor Open the Pine Script visual editor in the browser
3655
+ --dump Fetch and save raw OHLCV candles
3656
+ --pnldebug Simulate PnL per minute for a given entry price and direction
3657
+ --brokerdebug Fire a single broker commit against the live broker adapter
3658
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3659
+ --init Scaffold a new project in the current directory
3660
+ --help Print this help message
3661
+
3662
+ Backtest flags:
3663
+
3664
+ --symbol <string> Trading pair (default: BTCUSDT)
3665
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
3666
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3667
+ --frame <string> Frame name from addFrameSchema (default: first registered)
3668
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3669
+ --noCache Skip candle cache warming before the run
3670
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
3671
+ --verbose Log every candle fetch to stdout
3672
+ --ui Start web dashboard at http://localhost:60050
3673
+ --telegram Send trade notifications to Telegram
3674
+
3675
+ Walker flags (--walker):
3676
+
3677
+ --symbol <string> Trading pair (default: BTCUSDT)
3678
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3679
+ --noCache Skip candle cache warming before the run
3680
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
3681
+ --verbose Log every candle fetch to stdout
3682
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3683
+ --json Save results as JSON to ./dump/<output>.json
3684
+ --markdown Save report as Markdown to ./dump/<output>.md
3685
+
3686
+ Each positional argument is a strategy entry point. All strategy files are loaded without
3687
+ changing process.cwd() — .env is read from the working directory only.
3688
+ addWalkerSchema is called automatically using the registered exchange and frame.
3689
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3690
+
3691
+ Module file ./modules/walker.module is loaded automatically if it exists.
3692
+
3693
+ Paper / Live flags:
3694
+
3695
+ --symbol <string> Trading pair (default: BTCUSDT)
3696
+ --strategy <string> Strategy name (default: first registered)
3697
+ --exchange <string> Exchange name (default: first registered)
3698
+ --verbose Log every candle fetch to stdout
3699
+ --ui Start web dashboard
3700
+ --telegram Send Telegram notifications
3701
+
3702
+ PineScript flags (--pine):
3703
+
3704
+ --symbol <string> Trading pair (default: BTCUSDT)
3705
+ --timeframe <string> Candle interval (default: 15m)
3706
+ --limit <string> Number of candles to fetch (default: 250)
3707
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3708
+ --exchange <string> Exchange name (default: first registered)
3709
+ --output <string> Output file base name without extension
3710
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
3711
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3712
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3713
+
3714
+ Only plot() calls with display=display.data_window produce output columns.
3715
+ Module file ./modules/pine.module is loaded automatically if it exists.
3716
+
3717
+ Candle dump flags (--dump):
3718
+
3719
+ --symbol <string> Trading pair (default: BTCUSDT)
3720
+ --timeframe <string> Candle interval (default: 15m)
3721
+ --limit <string> Number of candles (default: 250)
3722
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3723
+ --exchange <string> Exchange name (default: first registered)
3724
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3725
+ --json Save as JSON array to ./dump/<output>.json
3726
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3727
+
3728
+ Module file ./modules/dump.module is loaded automatically if it exists.
3729
+
3730
+ PnL debug flags (--pnldebug):
3731
+
3732
+ --symbol <string> Trading pair (default: BTCUSDT)
3733
+ --priceopen <number> Entry price (required)
3734
+ --direction <string> Position direction: long or short (default: long)
3735
+ --when <string> Start timestamp ISO 8601 or Unix ms (default: now)
3736
+ --minutes <string> Number of 1m candles to simulate (default: 60)
3737
+ --exchange <string> Exchange name (default: first registered)
3738
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3739
+ --json Save as JSON array to ./dump/<output>.json
3740
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3741
+ --markdown Save as Markdown table to ./dump/<output>.md
3742
+
3743
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
3744
+
3745
+ Broker debug flags (--brokerdebug):
3746
+
3747
+ --symbol <string> Trading pair (default: BTCUSDT)
3748
+ --exchange <string> Exchange name (default: first registered)
3749
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3750
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3751
+ (default: signal-open)
3752
+
3753
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3754
+ the selected broker commit with synthetic payload values derived from current price.
3755
+
3756
+ Flush flags (--flush):
3757
+
3758
+ One or more positional entry points. For each entry point the following
3759
+ subdirectories are removed from <entry-dir>/dump/:
3760
+
3761
+ report log markdown agent
3762
+
3763
+ Init flags (--init):
3764
+
3765
+ --output <string> Target directory name (default: backtest-kit-project)
3766
+
3767
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3768
+
3769
+ Module hooks (loaded automatically by each mode):
3770
+
3771
+ modules/backtest.module --backtest Broker adapter for backtest
3772
+ modules/walker.module --walker Broker adapter for walker comparison
3773
+ modules/paper.module --paper Broker adapter for paper trading
3774
+ modules/live.module --live Broker adapter for live trading
3775
+ modules/pine.module --pine Exchange schema for PineScript runs
3776
+ modules/editor.module --editor Exchange schema for the visual Pine editor
3777
+ modules/dump.module --dump Exchange schema for candle dumps
3778
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3779
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3780
+
3781
+ --flush has no associated module. It only removes dump subdirectories.
3782
+
3783
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3784
+
3785
+ Environment variables:
3786
+
3787
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3788
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3789
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3790
+ CC_WWWROOT_PORT UI server port (default: 60050)
3791
+
3792
+ Examples:
3793
+
3794
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
3795
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
3796
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
3797
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
3798
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
3799
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
3800
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
3801
+ node ${ENTRY_PATH} --editor
3802
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3803
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3804
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
3805
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
3806
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
3807
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3808
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3809
+ node ${ENTRY_PATH} --init --output my-trading-bot
3787
3810
  `.trimStart();
3788
3811
  const main$1 = async () => {
3789
3812
  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)))) {
@@ -3793,7 +3816,7 @@ const main$1 = async () => {
3793
3816
  if (!values.help) {
3794
3817
  return;
3795
3818
  }
3796
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n\n`);
3819
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n\n`);
3797
3820
  process.stdout.write(HELP_TEXT);
3798
3821
  process.exit(0);
3799
3822
  };
@@ -3807,7 +3830,7 @@ const main = async () => {
3807
3830
  if (!values.version) {
3808
3831
  return;
3809
3832
  }
3810
- process.stdout.write(`@backtest-kit/cli ${"8.0.0"}\n`);
3833
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
3811
3834
  process.exit(0);
3812
3835
  };
3813
3836
  main();