@backtest-kit/cli 12.8.0 → 13.3.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 +1888 -1888
- package/build/index.cjs +206 -205
- package/build/index.mjs +207 -206
- package/config/notification.config.mjs +13 -13
- package/config/symbol.config.mjs +460 -460
- package/docker/.env.example +2 -2
- package/docker/content/feb_2026/feb_2026.strategy.ts +11 -11
- package/docker/content/feb_2026/modules/backtest.module.ts +83 -83
- package/docker/docker-compose.yaml +46 -46
- package/docker/package.json +39 -39
- package/docker/tsconfig.json +36 -36
- package/package.json +126 -126
- package/template/average-buy.mustache +22 -22
- package/template/breakeven.mustache +21 -21
- package/template/cancel-scheduled.mustache +14 -14
- package/template/cancelled.mustache +21 -21
- package/template/close-pending.mustache +16 -16
- package/template/closed.mustache +23 -23
- package/template/opened.mustache +22 -22
- package/template/partial-loss.mustache +22 -22
- package/template/partial-profit.mustache +22 -22
- package/template/project/config/symbol.config.ts +460 -460
- package/template/project/package.mustache +28 -28
- package/template/risk.mustache +19 -19
- package/template/scheduled.mustache +22 -22
- package/template/signal-close.mustache +22 -22
- package/template/signal-info.mustache +20 -20
- package/template/signal-open.mustache +22 -22
- package/template/source/CLAUDE.md +160 -160
- package/template/trailing-stop.mustache +21 -21
- package/template/trailing-take.mustache +21 -21
package/build/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as BacktestKit from 'backtest-kit';
|
|
3
|
-
import { setConfig, emitters, Notification, Cron, Recent, Storage, Markdown, Report, Dump, State, Memory, MarkdownWriter, ReportWriter, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistIntervalAdapter, PersistMemoryAdapter, PersistRecentAdapter, PersistStateAdapter, PersistSessionAdapter, Log, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, RecentLive, RecentBacktest, Broker, SessionLive, SessionBacktest, MemoryLive, MemoryBacktest, StateLive, StateBacktest, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, System, Cache, Interval, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, listenSignalNotify, Exchange } from 'backtest-kit';
|
|
3
|
+
import { setConfig, emitters, Notification, Cron, Recent, Storage, Markdown, Report, Dump, State, Memory, MarkdownWriter, ReportWriter, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistIntervalAdapter, PersistMemoryAdapter, PersistRecentAdapter, PersistStateAdapter, PersistSessionAdapter, PersistStrategyAdapter, Log, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, RecentLive, RecentBacktest, Broker, SessionLive, SessionBacktest, MemoryLive, MemoryBacktest, StateLive, StateBacktest, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, System, Cache, Interval, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, listenSignalNotify, Exchange } from 'backtest-kit';
|
|
4
4
|
import { singleshot, BehaviorSubject, Subject, getErrorMessage, errorData, str, compose, sleep, createAwaiter, execpool, queued, randomString, TIMEOUT_SYMBOL, typo, retry, trycatch, memoize, isObject } from 'functools-kit';
|
|
5
5
|
import fs, { constants, realpathSync } from 'fs';
|
|
6
6
|
import * as stackTrace from 'stack-trace';
|
|
@@ -334,6 +334,7 @@ class SetupUtils {
|
|
|
334
334
|
PersistRecentAdapter.clear();
|
|
335
335
|
PersistStateAdapter.clear();
|
|
336
336
|
PersistSessionAdapter.clear();
|
|
337
|
+
PersistStrategyAdapter.clear();
|
|
337
338
|
}
|
|
338
339
|
{
|
|
339
340
|
Dump.clear();
|
|
@@ -3354,10 +3355,10 @@ init();
|
|
|
3354
3355
|
|
|
3355
3356
|
const MODES = ["backtest", "walker", "paper", "live", "main", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3356
3357
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3357
|
-
const HELP_TEXT$1 = `
|
|
3358
|
-
Example:
|
|
3359
|
-
|
|
3360
|
-
node ${ENTRY_PATH$1} --help
|
|
3358
|
+
const HELP_TEXT$1 = `
|
|
3359
|
+
Example:
|
|
3360
|
+
|
|
3361
|
+
node ${ENTRY_PATH$1} --help
|
|
3361
3362
|
`.trimStart();
|
|
3362
3363
|
const main$h = async () => {
|
|
3363
3364
|
if (!getEntry(import.meta.url)) {
|
|
@@ -3367,7 +3368,7 @@ const main$h = async () => {
|
|
|
3367
3368
|
if (MODES.some((mode) => values[mode])) {
|
|
3368
3369
|
return;
|
|
3369
3370
|
}
|
|
3370
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
3371
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n`);
|
|
3371
3372
|
process.stdout.write("\n");
|
|
3372
3373
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3373
3374
|
process.stdout.write("\n");
|
|
@@ -4466,204 +4467,204 @@ const main$2 = async () => {
|
|
|
4466
4467
|
main$2();
|
|
4467
4468
|
|
|
4468
4469
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
4469
|
-
const HELP_TEXT = `
|
|
4470
|
-
Usage:
|
|
4471
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
4472
|
-
|
|
4473
|
-
Modes:
|
|
4474
|
-
|
|
4475
|
-
--backtest <entry> Run strategy against historical candle data
|
|
4476
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4477
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
4478
|
-
--live <entry> Live trading with real orders
|
|
4479
|
-
--main <entry> Run an entry point with prepared environment, no trading harness
|
|
4480
|
-
--pine <entry> Execute a local .pine indicator file
|
|
4481
|
-
--editor Open the Pine Script visual editor in the browser
|
|
4482
|
-
--dump Fetch and save raw OHLCV candles
|
|
4483
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4484
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4485
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4486
|
-
--init Scaffold a new project in the current directory
|
|
4487
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4488
|
-
--help Print this help message
|
|
4489
|
-
|
|
4490
|
-
Backtest flags:
|
|
4491
|
-
|
|
4492
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4493
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4494
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4495
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4496
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4497
|
-
--noCache Skip candle cache warming before the run
|
|
4498
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4499
|
-
--verbose Log every candle fetch to stdout
|
|
4500
|
-
--ui Start web dashboard at http://localhost:60050
|
|
4501
|
-
--telegram Send trade notifications to Telegram
|
|
4502
|
-
|
|
4503
|
-
Walker flags (--walker):
|
|
4504
|
-
|
|
4505
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4506
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4507
|
-
--noCache Skip candle cache warming before the run
|
|
4508
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4509
|
-
--verbose Log every candle fetch to stdout
|
|
4510
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4511
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
4512
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4513
|
-
|
|
4514
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4515
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
4516
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4517
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4518
|
-
|
|
4519
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4520
|
-
|
|
4521
|
-
Paper / Live flags:
|
|
4522
|
-
|
|
4523
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4524
|
-
--strategy <string> Strategy name (default: first registered)
|
|
4525
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4526
|
-
--verbose Log every candle fetch to stdout
|
|
4527
|
-
--ui Start web dashboard
|
|
4528
|
-
--telegram Send Telegram notifications
|
|
4529
|
-
|
|
4530
|
-
Main flags (--main):
|
|
4531
|
-
|
|
4532
|
-
--noFlush Skip removing report/log/markdown/agent folders before the run
|
|
4533
|
-
|
|
4534
|
-
Prepares the runtime environment (loads .env, setup.config, loader.config and
|
|
4535
|
-
modules/main.module) and runs the single positional entry point — but does NOT
|
|
4536
|
-
start any trading harness. Unlike --backtest/--live/--walker, the CLI never calls
|
|
4537
|
-
Backtest/Live/Walker.background; the entry point decides what to run.
|
|
4538
|
-
|
|
4539
|
-
Exactly one positional entry point is required. process.cwd() is changed to the
|
|
4540
|
-
entry point directory and its local .env is loaded.
|
|
4541
|
-
|
|
4542
|
-
Backtest, Live and Walker runs started from userspace are still tracked: the run
|
|
4543
|
-
finishes automatically when one of them completes, Ctrl+C stops any active run,
|
|
4544
|
-
and a second Ctrl+C force-quits.
|
|
4545
|
-
|
|
4546
|
-
Module file ./modules/main.module is loaded automatically if it exists.
|
|
4547
|
-
|
|
4548
|
-
PineScript flags (--pine):
|
|
4549
|
-
|
|
4550
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4551
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4552
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
4553
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4554
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4555
|
-
--output <string> Output file base name without extension
|
|
4556
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4557
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4558
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4559
|
-
|
|
4560
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
4561
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4562
|
-
|
|
4563
|
-
Candle dump flags (--dump):
|
|
4564
|
-
|
|
4565
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4566
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4567
|
-
--limit <string> Number of candles (default: 250)
|
|
4568
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4569
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4570
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4571
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4572
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4573
|
-
|
|
4574
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4575
|
-
|
|
4576
|
-
PnL debug flags (--pnldebug):
|
|
4577
|
-
|
|
4578
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4579
|
-
--priceopen <number> Entry price (required)
|
|
4580
|
-
--direction <string> Position direction: long or short (default: long)
|
|
4581
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4582
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4583
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4584
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4585
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4586
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4587
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4588
|
-
|
|
4589
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4590
|
-
|
|
4591
|
-
Broker debug flags (--brokerdebug):
|
|
4592
|
-
|
|
4593
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4594
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4595
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4596
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4597
|
-
(default: signal-open)
|
|
4598
|
-
|
|
4599
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4600
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
4601
|
-
|
|
4602
|
-
Flush flags (--flush):
|
|
4603
|
-
|
|
4604
|
-
One or more positional entry points. For each entry point the following
|
|
4605
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
4606
|
-
|
|
4607
|
-
report log markdown agent
|
|
4608
|
-
|
|
4609
|
-
Init flags (--init):
|
|
4610
|
-
|
|
4611
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
4612
|
-
|
|
4613
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4614
|
-
|
|
4615
|
-
Docker flags (--docker):
|
|
4616
|
-
|
|
4617
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4618
|
-
|
|
4619
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4620
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4621
|
-
docker compose up to start the container.
|
|
4622
|
-
|
|
4623
|
-
Module hooks (loaded automatically by each mode):
|
|
4624
|
-
|
|
4625
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4626
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4627
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4628
|
-
modules/live.module --live Broker adapter for live trading
|
|
4629
|
-
modules/main.module --main Environment setup for a custom entry point
|
|
4630
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4631
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4632
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4633
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4634
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4635
|
-
|
|
4636
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4637
|
-
|
|
4638
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4639
|
-
|
|
4640
|
-
Environment variables:
|
|
4641
|
-
|
|
4642
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4643
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4644
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4645
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4646
|
-
|
|
4647
|
-
Examples:
|
|
4648
|
-
|
|
4649
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4650
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4651
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4652
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4653
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4654
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4655
|
-
node ${ENTRY_PATH} --main ./tools/fetch_fear_and_greed.ts
|
|
4656
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4657
|
-
node ${ENTRY_PATH} --editor
|
|
4658
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4659
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4660
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4661
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4662
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4663
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4664
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4665
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4666
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4470
|
+
const HELP_TEXT = `
|
|
4471
|
+
Usage:
|
|
4472
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
4473
|
+
|
|
4474
|
+
Modes:
|
|
4475
|
+
|
|
4476
|
+
--backtest <entry> Run strategy against historical candle data
|
|
4477
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4478
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
4479
|
+
--live <entry> Live trading with real orders
|
|
4480
|
+
--main <entry> Run an entry point with prepared environment, no trading harness
|
|
4481
|
+
--pine <entry> Execute a local .pine indicator file
|
|
4482
|
+
--editor Open the Pine Script visual editor in the browser
|
|
4483
|
+
--dump Fetch and save raw OHLCV candles
|
|
4484
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4485
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4486
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4487
|
+
--init Scaffold a new project in the current directory
|
|
4488
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4489
|
+
--help Print this help message
|
|
4490
|
+
|
|
4491
|
+
Backtest flags:
|
|
4492
|
+
|
|
4493
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4494
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4495
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4496
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4497
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4498
|
+
--noCache Skip candle cache warming before the run
|
|
4499
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4500
|
+
--verbose Log every candle fetch to stdout
|
|
4501
|
+
--ui Start web dashboard at http://localhost:60050
|
|
4502
|
+
--telegram Send trade notifications to Telegram
|
|
4503
|
+
|
|
4504
|
+
Walker flags (--walker):
|
|
4505
|
+
|
|
4506
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4507
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4508
|
+
--noCache Skip candle cache warming before the run
|
|
4509
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4510
|
+
--verbose Log every candle fetch to stdout
|
|
4511
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4512
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
4513
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4514
|
+
|
|
4515
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4516
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
4517
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4518
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4519
|
+
|
|
4520
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4521
|
+
|
|
4522
|
+
Paper / Live flags:
|
|
4523
|
+
|
|
4524
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4525
|
+
--strategy <string> Strategy name (default: first registered)
|
|
4526
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4527
|
+
--verbose Log every candle fetch to stdout
|
|
4528
|
+
--ui Start web dashboard
|
|
4529
|
+
--telegram Send Telegram notifications
|
|
4530
|
+
|
|
4531
|
+
Main flags (--main):
|
|
4532
|
+
|
|
4533
|
+
--noFlush Skip removing report/log/markdown/agent folders before the run
|
|
4534
|
+
|
|
4535
|
+
Prepares the runtime environment (loads .env, setup.config, loader.config and
|
|
4536
|
+
modules/main.module) and runs the single positional entry point — but does NOT
|
|
4537
|
+
start any trading harness. Unlike --backtest/--live/--walker, the CLI never calls
|
|
4538
|
+
Backtest/Live/Walker.background; the entry point decides what to run.
|
|
4539
|
+
|
|
4540
|
+
Exactly one positional entry point is required. process.cwd() is changed to the
|
|
4541
|
+
entry point directory and its local .env is loaded.
|
|
4542
|
+
|
|
4543
|
+
Backtest, Live and Walker runs started from userspace are still tracked: the run
|
|
4544
|
+
finishes automatically when one of them completes, Ctrl+C stops any active run,
|
|
4545
|
+
and a second Ctrl+C force-quits.
|
|
4546
|
+
|
|
4547
|
+
Module file ./modules/main.module is loaded automatically if it exists.
|
|
4548
|
+
|
|
4549
|
+
PineScript flags (--pine):
|
|
4550
|
+
|
|
4551
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4552
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4553
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
4554
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4555
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4556
|
+
--output <string> Output file base name without extension
|
|
4557
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4558
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4559
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4560
|
+
|
|
4561
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
4562
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4563
|
+
|
|
4564
|
+
Candle dump flags (--dump):
|
|
4565
|
+
|
|
4566
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4567
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4568
|
+
--limit <string> Number of candles (default: 250)
|
|
4569
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4570
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4571
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4572
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4573
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4574
|
+
|
|
4575
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4576
|
+
|
|
4577
|
+
PnL debug flags (--pnldebug):
|
|
4578
|
+
|
|
4579
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4580
|
+
--priceopen <number> Entry price (required)
|
|
4581
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4582
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4583
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4584
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4585
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4586
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4587
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4588
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4589
|
+
|
|
4590
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4591
|
+
|
|
4592
|
+
Broker debug flags (--brokerdebug):
|
|
4593
|
+
|
|
4594
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4595
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4596
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4597
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4598
|
+
(default: signal-open)
|
|
4599
|
+
|
|
4600
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4601
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4602
|
+
|
|
4603
|
+
Flush flags (--flush):
|
|
4604
|
+
|
|
4605
|
+
One or more positional entry points. For each entry point the following
|
|
4606
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4607
|
+
|
|
4608
|
+
report log markdown agent
|
|
4609
|
+
|
|
4610
|
+
Init flags (--init):
|
|
4611
|
+
|
|
4612
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4613
|
+
|
|
4614
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4615
|
+
|
|
4616
|
+
Docker flags (--docker):
|
|
4617
|
+
|
|
4618
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4619
|
+
|
|
4620
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4621
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4622
|
+
docker compose up to start the container.
|
|
4623
|
+
|
|
4624
|
+
Module hooks (loaded automatically by each mode):
|
|
4625
|
+
|
|
4626
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4627
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4628
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4629
|
+
modules/live.module --live Broker adapter for live trading
|
|
4630
|
+
modules/main.module --main Environment setup for a custom entry point
|
|
4631
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4632
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4633
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4634
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4635
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4636
|
+
|
|
4637
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4638
|
+
|
|
4639
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4640
|
+
|
|
4641
|
+
Environment variables:
|
|
4642
|
+
|
|
4643
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4644
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4645
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4646
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4647
|
+
|
|
4648
|
+
Examples:
|
|
4649
|
+
|
|
4650
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4651
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4652
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4653
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4654
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4655
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4656
|
+
node ${ENTRY_PATH} --main ./tools/fetch_fear_and_greed.ts
|
|
4657
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4658
|
+
node ${ENTRY_PATH} --editor
|
|
4659
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4660
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4661
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4662
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4663
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4664
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4665
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4666
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4667
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4667
4668
|
`.trimStart();
|
|
4668
4669
|
const main$1 = async () => {
|
|
4669
4670
|
if (!getEntry(import.meta.url)) {
|
|
@@ -4673,7 +4674,7 @@ const main$1 = async () => {
|
|
|
4673
4674
|
if (!values.help) {
|
|
4674
4675
|
return;
|
|
4675
4676
|
}
|
|
4676
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4677
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n\n`);
|
|
4677
4678
|
process.stdout.write(HELP_TEXT);
|
|
4678
4679
|
process.exit(0);
|
|
4679
4680
|
};
|
|
@@ -4687,7 +4688,7 @@ const main = async () => {
|
|
|
4687
4688
|
if (!values.version) {
|
|
4688
4689
|
return;
|
|
4689
4690
|
}
|
|
4690
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4691
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n`);
|
|
4691
4692
|
process.exit(0);
|
|
4692
4693
|
};
|
|
4693
4694
|
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
|
+
};
|