@backtest-kit/cli 16.3.0 → 16.5.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
@@ -104,6 +104,7 @@ Every invocation is **one mode** (a primary flag) + a positional strategy/entry
104
104
  | **Candle Dump** | `--dump` | Fetch & save raw OHLCV candles to a file |
105
105
  | **PnL Debug** | `--pnldebug` | Simulate per-minute PnL for a given entry price & direction |
106
106
  | **Broker Debug** | `--brokerdebug` | Fire a single broker commit against the live adapter |
107
+ | **Simulator** | `--simulator` | Sweep exit/entry parameters over a crowd-ideas feed, train an author whitelist |
107
108
  | **Flush** | `--flush` | Delete report/log/markdown/agent folders from a strategy dump dir |
108
109
  | **Init** | `--init` | Scaffold a new project |
109
110
  | **Docker** | `--docker` | Scaffold a self-contained Docker workspace |
@@ -266,12 +267,12 @@ The same shape works for `--live --entry` / `--paper --entry` (call `Live.backgr
266
267
 
267
268
  ## 🛠️ Tooling modes
268
269
 
269
- Five utilities that don't run a strategy. They share one convention, explained once here and referenced below.
270
+ Six utilities that don't run a strategy. They share one convention, explained once here and referenced below.
270
271
 
271
272
  > **The `<mode>.module` convention.** By default the CLI auto-registers CCXT Binance. To use a different exchange (custom API keys, rate limits, a non-spot market), drop a `modules/<mode>.module.ts` that calls `addExchangeSchema` from `backtest-kit`. The CLI loads it automatically before running, trying `.ts`/`.mjs`/`.cjs`; it's searched **next to the target file first, then in the project root**. `.env` is loaded root-first then the target-file dir (override), so API keys stay out of code.
272
273
 
273
274
  <details>
274
- <summary>The shared <code>&lt;mode&gt;.module.ts</code> shape (pine / editor / dump / pnldebug / brokerdebug)</summary>
275
+ <summary>The shared <code>&lt;mode&gt;.module.ts</code> shape (pine / editor / dump / pnldebug / brokerdebug / simulator)</summary>
275
276
 
276
277
  ```typescript
277
278
  // modules/pine.module.ts (same shape for editor/dump/pnldebug.module; brokerdebug registers a Broker instead)
@@ -449,6 +450,34 @@ The CLI loads `./modules/brokerdebug.module`, fetches the last candle for `--sym
449
450
 
450
451
  </details>
451
452
 
453
+ ### 🎛️ Simulator (`--simulator`)
454
+
455
+ Sweep exit/entry parameters over a feed of crowd trading ideas using the `Simulator` entity — one candle pass per idea, a full parameter grid evaluated arithmetically, an author whitelist trained with default-ban semantics. Prints a Markdown report with four ranking winners (time-based Sharpe, Sortino, PnL, recovery factor) and the production whitelist.
456
+
457
+ ```bash
458
+ npx @backtest-kit/cli --simulator --symbol BTCUSDT ./assets/tv-ideas.normalized.jsonl
459
+ # → summary to stdout; add --json / --markdown to save into ./dump/
460
+ ```
461
+
462
+ <details>
463
+ <summary>Simulator flags, input format & behavior</summary>
464
+
465
+ | Flag | Type | Description |
466
+ |------|------|-------------|
467
+ | `--simulator` | boolean | Enable simulator mode |
468
+ | `--symbol` | string | Trading pair to simulate (default `"BTCUSDT"`) |
469
+ | `--exchange` | string | Exchange (default: first registered, falls back to CCXT Binance) |
470
+ | `--output` | string | Output base name (default `simulator_{SYMBOL}_{TIMESTAMP}`) |
471
+ | `--json` | boolean | Save the full `ISimulatorResult` to `./dump/<output>.json` |
472
+ | `--markdown` | boolean | Save the summary report to `./dump/<output>.md` |
473
+ | `--verbose` | boolean | Log every simulator lifecycle callback to the console |
474
+
475
+ **Positional (required):** path to an ideas `.jsonl` file — one idea per line, exact shape `{ "id": number, "ts": number, "symbol": string, "direction": "LONG"|"SHORT"|"NEUTRAL", "author": string }`. The file is validated **before any work starts** — the first line that does not match the structure aborts the run with an error naming the line and the field. Ideas of other symbols are filtered out by the engine, so one shared feed serves any `--symbol`.
476
+
477
+ Under the hood: 5-day candle horizon per idea (lazy chunked fetch through the exchange, persist cache first), flood dedupe (one idea per author per direction per 8h), author ban thresholds swept as grid axes (unproven author = banned by default), production slot semantics, time-based Sharpe/Sortino over daily equity buckets. With `--verbose` every lifecycle callback (`onIdeas`, `onProfiles`, `onAuthorsTrained`, `onGridPoint`, `onRanking`, `onDone`) is logged to the console as it fires, so long runs show progress. Exchange via `simulator.module` (see convention above).
478
+
479
+ </details>
480
+
452
481
  ### 🗑️ Flush (`--flush`)
453
482
 
454
483
  Delete generated output folders from one or more strategy dump dirs **without** touching cached candle data.