@backtest-kit/cli 6.1.5 → 6.2.1

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
@@ -17,7 +17,7 @@ Point the CLI at your strategy file, choose a mode, and it handles exchange conn
17
17
  ## ✨ Features
18
18
 
19
19
  - 🚀 **Zero Config**: Run `npx @backtest-kit/cli --backtest ./strategy.mjs` — no boilerplate needed
20
- - 🔄 **Three Modes**: Backtest on historical data, paper trade on live prices, or deploy live bots
20
+ - 🔄 **Four Modes**: Backtest on historical data, walker A/B comparison, paper trade on live prices, or deploy live bots
21
21
  - 💾 **Auto Candle Cache**: Warms OHLCV cache for all required intervals before backtest starts
22
22
  - 🌐 **Web Dashboard**: Launch `@backtest-kit/ui` with a single `--ui` flag
23
23
  - 📬 **Telegram Alerts**: Send formatted trade notifications with charts via `--telegram`
@@ -34,6 +34,7 @@ Point the CLI at your strategy file, choose a mode, and it handles exchange conn
34
34
  | Mode | Command Line Args | Description |
35
35
  |------------------|----------------------------|----------------------------------------------|
36
36
  | **Backtest** | `--backtest` | Run strategy on historical candle data |
37
+ | **Walker** | `--walker` | A/B compare multiple strategies on the same historical data |
37
38
  | **Paper** | `--paper` | Live prices, no real orders |
38
39
  | **Live** | `--live` | Real trades via exchange API |
39
40
  | **UI Dashboard** | `--ui` | Web dashboard at `http://localhost:60050` |
@@ -136,6 +137,7 @@ npm start -- --symbol BTCUSDT --ui
136
137
  | Command Line Args | Type | Description |
137
138
  |---------------------------|---------|--------------------------------------------------------------------|
138
139
  | `--backtest` | boolean | Run historical backtest (default: `false`) |
140
+ | `--walker` | boolean | Run Walker A/B strategy comparison (default: `false`) |
139
141
  | `--paper` | boolean | Paper trading (live prices, no orders) (default: `false`) |
140
142
  | `--live` | boolean | Run live trading (default: `false`) |
141
143
  | `--ui` | boolean | Start web UI dashboard (default: `false`) |
@@ -210,6 +212,61 @@ Deploys a real trading bot. Requires exchange API keys configured in your `.env`
210
212
  npm start
211
213
  ```
212
214
 
215
+ ### Walker — A/B Strategy Comparison
216
+
217
+ Runs the same historical period against multiple strategy files and prints a ranked comparison report. Use it to pick the best variant before deploying to backtest or live.
218
+
219
+ ```json
220
+ {
221
+ "scripts": {
222
+ "walker": "npx @backtest-kit/cli --walker --symbol BTCUSDT --noCache ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts"
223
+ }
224
+ }
225
+ ```
226
+
227
+ ```bash
228
+ npm run walker
229
+ ```
230
+
231
+ Each positional argument is a separate strategy entry point. All files are loaded without changing `process.cwd()` — `.env` is read from the working directory only. After loading, `addWalkerSchema` is called automatically using the exchange and frame registered by the strategy files.
232
+
233
+ If no frame is registered, the CLI falls back to the last 31 days from `Date.now()` with a console warning.
234
+
235
+ **Walker-specific flags:**
236
+
237
+ | Flag | Type | Description |
238
+ |------|------|-------------|
239
+ | `--walker` | boolean | Enable Walker comparison mode |
240
+ | `--symbol` | string | Trading pair (default: `"BTCUSDT"`) |
241
+ | `--cacheInterval` | string | Intervals to pre-cache (default: `"1m, 15m, 30m, 4h"`) |
242
+ | `--noCache` | boolean | Skip candle cache warming (default: `false`) |
243
+ | `--verbose` | boolean | Log each candle fetch and strategy progress (default: `false`) |
244
+ | `--output` | string | Output file base name (default: `walker_{SYMBOL}_{TIMESTAMP}`) |
245
+ | `--json` | boolean | Save results as JSON to `./dump/<output>.json` |
246
+ | `--markdown` | boolean | Save report as Markdown to `./dump/<output>.md` |
247
+
248
+ **Output modes:**
249
+
250
+ - No flag — print Markdown report to stdout
251
+ - `--json` — save `Walker.getData()` result as JSON and exit
252
+ - `--markdown` — save `Walker.getReport()` as `.md` file and exit
253
+
254
+ **Module hook:** `./modules/walker.module` is loaded automatically before the comparison starts (same rules as other modes — `.ts`, `.mjs`, `.cjs` tried in order).
255
+
256
+ **Example — compare three variants and save the report:**
257
+
258
+ ```bash
259
+ npx @backtest-kit/cli --walker \
260
+ --symbol BTCUSDT \
261
+ --noCache \
262
+ --markdown \
263
+ --output feb_2026_comparison \
264
+ ./content/feb_2026_v1.strategy.ts \
265
+ ./content/feb_2026_v2.strategy.ts \
266
+ ./content/feb_2026_v3.strategy.ts
267
+ # → ./dump/feb_2026_comparison.md
268
+ ```
269
+
213
270
  ## 🗂️ Monorepo Usage
214
271
 
215
272
  `@backtest-kit/cli` works out of the box in a monorepo where each strategy lives in its own subdirectory. When the CLI loads your entry point file, it automatically changes the working directory to the file's location — so all relative paths (`dump/`, `modules/`, `template/`) resolve inside that strategy's folder, not the project root.
@@ -278,6 +335,7 @@ npm run backtest:dec
278
335
  | Broker module (live) | `./modules/live.module.mjs` | ✅ per-strategy |
279
336
  | Broker module (paper) | `./modules/paper.module.mjs` | ✅ per-strategy |
280
337
  | Broker module (backtest) | `./modules/backtest.module.mjs` | ✅ per-strategy |
338
+ | Config module (walker) | `./modules/walker.module.mjs` | ✅ loaded once |
281
339
  | Telegram templates | `./template/*.mustache` | ✅ per-strategy |
282
340
  | Environment variables | `./.env` (overrides root) | ✅ per-strategy |
283
341
 
@@ -310,6 +368,7 @@ The CLI supports **mode-specific module files** that are loaded as side-effect i
310
368
  | `--live` | `./modules/live.module.mjs` | `Live.background()` |
311
369
  | `--paper` | `./modules/paper.module.mjs` | `Live.background()` (paper) |
312
370
  | `--backtest` | `./modules/backtest.module.mjs` | `Backtest.background()` |
371
+ | `--walker` | `./modules/walker.module.mjs` | `Walker.background()` |
313
372
 
314
373
  > 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.
315
374