@backtest-kit/cli 8.1.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/README.md CHANGED
@@ -45,6 +45,7 @@ Point the CLI at your strategy file, choose a mode, and it handles exchange conn
45
45
  | **Pine Editor** | `--editor` | Open the visual Pine Script editor in the browser |
46
46
  | **Candle Dump** | `--dump` | Fetch and save raw OHLCV candles to a file |
47
47
  | **PnL Debug** | `--pnldebug` | Simulate per-minute PnL for a given entry price and direction |
48
+ | **Broker Debug** | `--brokerdebug` | Fire a single broker commit against the live broker adapter |
48
49
  | **Flush** | `--flush` | Delete report/log/markdown/agent folders from strategy dump dir |
49
50
  | **Init Project** | `--init` | Scaffold a new backtest-kit project |
50
51
 
@@ -155,6 +156,8 @@ npm start -- --symbol BTCUSDT --ui
155
156
  | `--exchange` | string | Exchange name (default: first registered) |
156
157
  | `--frame` | string | Backtest frame name (default: first registered) |
157
158
  | `--cacheInterval` | string | Intervals to pre-cache before backtest (default: `"1m, 15m, 30m, 4h"`) |
159
+ | `--brokerdebug` | boolean | Fire a single broker commit against the live broker adapter (default: `false`) |
160
+ | `--commit` | string | Commit type for `--brokerdebug` (default: `"signal-open"`) |
158
161
 
159
162
  **Positional argument (required):** path to your strategy entry point file (set once in `package.json` scripts).
160
163
 
@@ -567,7 +570,8 @@ The CLI supports **mode-specific module files** that are loaded as side-effect i
567
570
  | `--live` | `./modules/live.module.mjs` | `Live.background()` |
568
571
  | `--paper` | `./modules/paper.module.mjs` | `Live.background()` (paper) |
569
572
  | `--backtest` | `./modules/backtest.module.mjs` | `Backtest.background()` |
570
- | `--walker` | `./modules/walker.module.mjs` | `Walker.background()` |
573
+ | `--walker` | `./modules/walker.module.mjs` | `Walker.background()` |
574
+ | `--brokerdebug` | `./modules/brokerdebug.module.mjs` | broker commit test |
571
575
 
572
576
  > File is resolved relative to `cwd` (the strategy directory). All of `.mjs`, `.cjs`, `.ts` extensions are tried automatically. Missing module is a soft warning — not an error.
573
577
 
@@ -1170,6 +1174,63 @@ Symbol: BTCUSDT | Direction: short | PriceOpen: 64069.50 | From: 2025-02-25T00:0
1170
1174
  120 | 2025-02-25T02:00:00.000Z | 63200.00 | +1.36% | +1.36% | -0.06%
1171
1175
  ```
1172
1176
 
1177
+ ## 🐛 Broker Debug (`--brokerdebug`)
1178
+
1179
+ `@backtest-kit/cli` can fire a single broker commit against your live broker adapter without running a full strategy — useful for verifying that your `brokerdebug.module` correctly wires up exchange calls.
1180
+
1181
+ ### CLI Flags
1182
+
1183
+ | Flag | Type | Description |
1184
+ |------|------|-------------|
1185
+ | `--brokerdebug` | boolean | Enable broker debug mode |
1186
+ | `--commit` | string | Commit type to fire (default: `"signal-open"`) |
1187
+ | `--symbol` | string | Trading pair (default: `"BTCUSDT"`) |
1188
+ | `--exchange` | string | Exchange name (default: first registered) |
1189
+
1190
+ **Available `--commit` values:**
1191
+
1192
+ | Value | Broker hook |
1193
+ |-------|-------------|
1194
+ | `signal-open` | `onSignalOpenCommit` |
1195
+ | `signal-close` | `onSignalCloseCommit` |
1196
+ | `partial-profit` | `onPartialProfitCommit` |
1197
+ | `partial-loss` | `onPartialLossCommit` |
1198
+ | `average-buy` | `onAverageBuyCommit` |
1199
+ | `trailing-stop` | `onTrailingStopCommit` |
1200
+ | `trailing-take` | `onTrailingTakeCommit` |
1201
+ | `breakeven` | `onBreakevenCommit` |
1202
+
1203
+ ### How It Works
1204
+
1205
+ The CLI loads `./modules/brokerdebug.module`, fetches the last candle for `--symbol` / `--timeframe`, derives synthetic payload values from `currentPrice` (TP = +2%, SL = -2%), and calls the selected broker hook once. Exits with code `0` on success.
1206
+
1207
+ ### Broker via `brokerdebug.module`
1208
+
1209
+ Create a `modules/brokerdebug.module.ts` file and register your broker adapter:
1210
+
1211
+ ```typescript
1212
+ // modules/brokerdebug.module.ts
1213
+ import { Broker } from 'backtest-kit';
1214
+ import { myExchange } from './exchange.mjs';
1215
+
1216
+ class MyBroker {
1217
+ async onSignalOpenCommit({ symbol, priceOpen, position }) {
1218
+ await myExchange.openPosition(symbol, position, priceOpen);
1219
+ }
1220
+ // ... other hooks
1221
+ }
1222
+
1223
+ Broker.useBrokerAdapter(MyBroker);
1224
+ Broker.enable();
1225
+ ```
1226
+
1227
+ ### Usage
1228
+
1229
+ ```bash
1230
+ npx @backtest-kit/cli --brokerdebug --commit signal-open --symbol BTCUSDT
1231
+ npx @backtest-kit/cli --brokerdebug --commit partial-profit --symbol ETHUSDT --timeframe 1h
1232
+ ```
1233
+
1173
1234
  ## 🗑️ Flushing Strategy Output (`--flush`)
1174
1235
 
1175
1236
  `@backtest-kit/cli` can delete generated output folders from one or more strategy dump directories without touching cached candle data.
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,7 +3007,7 @@ 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
3012
  const HELP_TEXT$1 = `
3005
3013
  Example:
@@ -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.1.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");
@@ -3646,6 +3654,7 @@ Modes:
3646
3654
  --editor Open the Pine Script visual editor in the browser
3647
3655
  --dump Fetch and save raw OHLCV candles
3648
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
3649
3658
  --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3650
3659
  --init Scaffold a new project in the current directory
3651
3660
  --help Print this help message
@@ -3733,6 +3742,17 @@ PnL debug flags (--pnldebug):
3733
3742
 
3734
3743
  Module file ./modules/pnldebug.module is loaded automatically if it exists.
3735
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
+
3736
3756
  Flush flags (--flush):
3737
3757
 
3738
3758
  One or more positional entry points. For each entry point the following
@@ -3755,7 +3775,8 @@ Module hooks (loaded automatically by each mode):
3755
3775
  modules/pine.module --pine Exchange schema for PineScript runs
3756
3776
  modules/editor.module --editor Exchange schema for the visual Pine editor
3757
3777
  modules/dump.module --dump Exchange schema for candle dumps
3758
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3778
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3779
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3759
3780
 
3760
3781
  --flush has no associated module. It only removes dump subdirectories.
3761
3782
 
@@ -3781,6 +3802,8 @@ Examples:
3781
3802
  node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3782
3803
  node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3783
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
3784
3807
  node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3785
3808
  node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3786
3809
  node ${ENTRY_PATH} --init --output my-trading-bot
@@ -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.1.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.1.0"}\n`);
3833
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
3811
3834
  process.exit(0);
3812
3835
  };
3813
3836
  main();
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,7 +2978,7 @@ 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
2983
  const HELP_TEXT$1 = `
2976
2984
  Example:
@@ -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.1.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");
@@ -3617,6 +3625,7 @@ Modes:
3617
3625
  --editor Open the Pine Script visual editor in the browser
3618
3626
  --dump Fetch and save raw OHLCV candles
3619
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
3620
3629
  --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3621
3630
  --init Scaffold a new project in the current directory
3622
3631
  --help Print this help message
@@ -3704,6 +3713,17 @@ PnL debug flags (--pnldebug):
3704
3713
 
3705
3714
  Module file ./modules/pnldebug.module is loaded automatically if it exists.
3706
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
+
3707
3727
  Flush flags (--flush):
3708
3728
 
3709
3729
  One or more positional entry points. For each entry point the following
@@ -3726,7 +3746,8 @@ Module hooks (loaded automatically by each mode):
3726
3746
  modules/pine.module --pine Exchange schema for PineScript runs
3727
3747
  modules/editor.module --editor Exchange schema for the visual Pine editor
3728
3748
  modules/dump.module --dump Exchange schema for candle dumps
3729
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3749
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3750
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3730
3751
 
3731
3752
  --flush has no associated module. It only removes dump subdirectories.
3732
3753
 
@@ -3752,6 +3773,8 @@ Examples:
3752
3773
  node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
3753
3774
  node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
3754
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
3755
3778
  node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
3756
3779
  node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
3757
3780
  node ${ENTRY_PATH} --init --output my-trading-bot
@@ -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.1.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.1.0"}\n`);
3804
+ process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
3782
3805
  process.exit(0);
3783
3806
  };
3784
3807
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/cli",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "Zero-boilerplate CLI runner for backtest-kit strategies. Run backtests, paper trading, and live bots with candle cache warming, web dashboard, and Telegram notifications — no setup code required.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -62,11 +62,11 @@
62
62
  "devDependencies": {
63
63
  "@babel/plugin-transform-modules-umd": "7.27.1",
64
64
  "@babel/standalone": "7.29.1",
65
- "@backtest-kit/graph": "8.1.0",
66
- "@backtest-kit/ollama": "8.1.0",
67
- "@backtest-kit/pinets": "8.1.0",
68
- "@backtest-kit/signals": "8.1.0",
69
- "@backtest-kit/ui": "8.1.0",
65
+ "@backtest-kit/graph": "8.2.0",
66
+ "@backtest-kit/ollama": "8.2.0",
67
+ "@backtest-kit/pinets": "8.2.0",
68
+ "@backtest-kit/signals": "8.2.0",
69
+ "@backtest-kit/ui": "8.2.0",
70
70
  "@rollup/plugin-replace": "6.0.3",
71
71
  "@rollup/plugin-typescript": "11.1.6",
72
72
  "@types/image-size": "0.7.0",
@@ -74,7 +74,7 @@
74
74
  "@types/mustache": "4.2.6",
75
75
  "@types/node": "22.9.0",
76
76
  "@types/stack-trace": "0.0.33",
77
- "backtest-kit": "8.1.0",
77
+ "backtest-kit": "8.2.0",
78
78
  "glob": "11.0.1",
79
79
  "markdown-it": "14.1.1",
80
80
  "rimraf": "6.0.1",
@@ -89,12 +89,12 @@
89
89
  "peerDependencies": {
90
90
  "@babel/plugin-transform-modules-umd": "^7.27.1",
91
91
  "@babel/standalone": "^7.29.1",
92
- "@backtest-kit/graph": "^8.1.0",
93
- "@backtest-kit/ollama": "^8.1.0",
94
- "@backtest-kit/pinets": "^8.1.0",
95
- "@backtest-kit/signals": "^8.1.0",
96
- "@backtest-kit/ui": "^8.1.0",
97
- "backtest-kit": "^8.1.0",
92
+ "@backtest-kit/graph": "^8.2.0",
93
+ "@backtest-kit/ollama": "^8.2.0",
94
+ "@backtest-kit/pinets": "^8.2.0",
95
+ "@backtest-kit/signals": "^8.2.0",
96
+ "@backtest-kit/ui": "^8.2.0",
97
+ "backtest-kit": "^8.2.0",
98
98
  "markdown-it": "^14.1.1",
99
99
  "typescript": "^5.0.0"
100
100
  },
@@ -13,12 +13,12 @@
13
13
  "license": "ISC",
14
14
  "type": "commonjs",
15
15
  "dependencies": {
16
- "@backtest-kit/cli": "^8.1.0",
17
- "@backtest-kit/graph": "^8.1.0",
18
- "@backtest-kit/pinets": "^8.1.0",
19
- "@backtest-kit/ui": "^8.1.0",
16
+ "@backtest-kit/cli": "^8.2.0",
17
+ "@backtest-kit/graph": "^8.2.0",
18
+ "@backtest-kit/pinets": "^8.2.0",
19
+ "@backtest-kit/ui": "^8.2.0",
20
20
  "agent-swarm-kit": "^2.6.0",
21
- "backtest-kit": "^8.1.0",
21
+ "backtest-kit": "^8.2.0",
22
22
  "functools-kit": "^2.3.0",
23
23
  "garch": "^1.2.3",
24
24
  "get-moment-stamp": "^1.1.2",