@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.cjs
CHANGED
|
@@ -359,6 +359,7 @@ class SetupUtils {
|
|
|
359
359
|
BacktestKit.PersistRecentAdapter.clear();
|
|
360
360
|
BacktestKit.PersistStateAdapter.clear();
|
|
361
361
|
BacktestKit.PersistSessionAdapter.clear();
|
|
362
|
+
BacktestKit.PersistStrategyAdapter.clear();
|
|
362
363
|
}
|
|
363
364
|
{
|
|
364
365
|
BacktestKit.Dump.clear();
|
|
@@ -3383,10 +3384,10 @@ init();
|
|
|
3383
3384
|
|
|
3384
3385
|
const MODES = ["backtest", "walker", "paper", "live", "main", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3385
3386
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3386
|
-
const HELP_TEXT$1 = `
|
|
3387
|
-
Example:
|
|
3388
|
-
|
|
3389
|
-
node ${ENTRY_PATH$1} --help
|
|
3387
|
+
const HELP_TEXT$1 = `
|
|
3388
|
+
Example:
|
|
3389
|
+
|
|
3390
|
+
node ${ENTRY_PATH$1} --help
|
|
3390
3391
|
`.trimStart();
|
|
3391
3392
|
const main$h = async () => {
|
|
3392
3393
|
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)))) {
|
|
@@ -3396,7 +3397,7 @@ const main$h = async () => {
|
|
|
3396
3397
|
if (MODES.some((mode) => values[mode])) {
|
|
3397
3398
|
return;
|
|
3398
3399
|
}
|
|
3399
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
3400
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n`);
|
|
3400
3401
|
process.stdout.write("\n");
|
|
3401
3402
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3402
3403
|
process.stdout.write("\n");
|
|
@@ -4495,204 +4496,204 @@ const main$2 = async () => {
|
|
|
4495
4496
|
main$2();
|
|
4496
4497
|
|
|
4497
4498
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
4498
|
-
const HELP_TEXT = `
|
|
4499
|
-
Usage:
|
|
4500
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
4501
|
-
|
|
4502
|
-
Modes:
|
|
4503
|
-
|
|
4504
|
-
--backtest <entry> Run strategy against historical candle data
|
|
4505
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4506
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
4507
|
-
--live <entry> Live trading with real orders
|
|
4508
|
-
--main <entry> Run an entry point with prepared environment, no trading harness
|
|
4509
|
-
--pine <entry> Execute a local .pine indicator file
|
|
4510
|
-
--editor Open the Pine Script visual editor in the browser
|
|
4511
|
-
--dump Fetch and save raw OHLCV candles
|
|
4512
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4513
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4514
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4515
|
-
--init Scaffold a new project in the current directory
|
|
4516
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4517
|
-
--help Print this help message
|
|
4518
|
-
|
|
4519
|
-
Backtest flags:
|
|
4520
|
-
|
|
4521
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4522
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4523
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4524
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4525
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4526
|
-
--noCache Skip candle cache warming before the run
|
|
4527
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4528
|
-
--verbose Log every candle fetch to stdout
|
|
4529
|
-
--ui Start web dashboard at http://localhost:60050
|
|
4530
|
-
--telegram Send trade notifications to Telegram
|
|
4531
|
-
|
|
4532
|
-
Walker flags (--walker):
|
|
4533
|
-
|
|
4534
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4535
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4536
|
-
--noCache Skip candle cache warming before the run
|
|
4537
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4538
|
-
--verbose Log every candle fetch to stdout
|
|
4539
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4540
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
4541
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4542
|
-
|
|
4543
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4544
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
4545
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4546
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4547
|
-
|
|
4548
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4549
|
-
|
|
4550
|
-
Paper / Live flags:
|
|
4551
|
-
|
|
4552
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4553
|
-
--strategy <string> Strategy name (default: first registered)
|
|
4554
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4555
|
-
--verbose Log every candle fetch to stdout
|
|
4556
|
-
--ui Start web dashboard
|
|
4557
|
-
--telegram Send Telegram notifications
|
|
4558
|
-
|
|
4559
|
-
Main flags (--main):
|
|
4560
|
-
|
|
4561
|
-
--noFlush Skip removing report/log/markdown/agent folders before the run
|
|
4562
|
-
|
|
4563
|
-
Prepares the runtime environment (loads .env, setup.config, loader.config and
|
|
4564
|
-
modules/main.module) and runs the single positional entry point — but does NOT
|
|
4565
|
-
start any trading harness. Unlike --backtest/--live/--walker, the CLI never calls
|
|
4566
|
-
Backtest/Live/Walker.background; the entry point decides what to run.
|
|
4567
|
-
|
|
4568
|
-
Exactly one positional entry point is required. process.cwd() is changed to the
|
|
4569
|
-
entry point directory and its local .env is loaded.
|
|
4570
|
-
|
|
4571
|
-
Backtest, Live and Walker runs started from userspace are still tracked: the run
|
|
4572
|
-
finishes automatically when one of them completes, Ctrl+C stops any active run,
|
|
4573
|
-
and a second Ctrl+C force-quits.
|
|
4574
|
-
|
|
4575
|
-
Module file ./modules/main.module is loaded automatically if it exists.
|
|
4576
|
-
|
|
4577
|
-
PineScript flags (--pine):
|
|
4578
|
-
|
|
4579
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4580
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4581
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
4582
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4583
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4584
|
-
--output <string> Output file base name without extension
|
|
4585
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4586
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4587
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4588
|
-
|
|
4589
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
4590
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4591
|
-
|
|
4592
|
-
Candle dump flags (--dump):
|
|
4593
|
-
|
|
4594
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4595
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4596
|
-
--limit <string> Number of candles (default: 250)
|
|
4597
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4598
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4599
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4600
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4601
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4602
|
-
|
|
4603
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4604
|
-
|
|
4605
|
-
PnL debug flags (--pnldebug):
|
|
4606
|
-
|
|
4607
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4608
|
-
--priceopen <number> Entry price (required)
|
|
4609
|
-
--direction <string> Position direction: long or short (default: long)
|
|
4610
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4611
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4612
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4613
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4614
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4615
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4616
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4617
|
-
|
|
4618
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4619
|
-
|
|
4620
|
-
Broker debug flags (--brokerdebug):
|
|
4621
|
-
|
|
4622
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4623
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4624
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4625
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4626
|
-
(default: signal-open)
|
|
4627
|
-
|
|
4628
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4629
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
4630
|
-
|
|
4631
|
-
Flush flags (--flush):
|
|
4632
|
-
|
|
4633
|
-
One or more positional entry points. For each entry point the following
|
|
4634
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
4635
|
-
|
|
4636
|
-
report log markdown agent
|
|
4637
|
-
|
|
4638
|
-
Init flags (--init):
|
|
4639
|
-
|
|
4640
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
4641
|
-
|
|
4642
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4643
|
-
|
|
4644
|
-
Docker flags (--docker):
|
|
4645
|
-
|
|
4646
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4647
|
-
|
|
4648
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4649
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4650
|
-
docker compose up to start the container.
|
|
4651
|
-
|
|
4652
|
-
Module hooks (loaded automatically by each mode):
|
|
4653
|
-
|
|
4654
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4655
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4656
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4657
|
-
modules/live.module --live Broker adapter for live trading
|
|
4658
|
-
modules/main.module --main Environment setup for a custom entry point
|
|
4659
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4660
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4661
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4662
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4663
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4664
|
-
|
|
4665
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4666
|
-
|
|
4667
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4668
|
-
|
|
4669
|
-
Environment variables:
|
|
4670
|
-
|
|
4671
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4672
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4673
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4674
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4675
|
-
|
|
4676
|
-
Examples:
|
|
4677
|
-
|
|
4678
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4679
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4680
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4681
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4682
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4683
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4684
|
-
node ${ENTRY_PATH} --main ./tools/fetch_fear_and_greed.ts
|
|
4685
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4686
|
-
node ${ENTRY_PATH} --editor
|
|
4687
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4688
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4689
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4690
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4691
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4692
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4693
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4694
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4695
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4499
|
+
const HELP_TEXT = `
|
|
4500
|
+
Usage:
|
|
4501
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
4502
|
+
|
|
4503
|
+
Modes:
|
|
4504
|
+
|
|
4505
|
+
--backtest <entry> Run strategy against historical candle data
|
|
4506
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4507
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
4508
|
+
--live <entry> Live trading with real orders
|
|
4509
|
+
--main <entry> Run an entry point with prepared environment, no trading harness
|
|
4510
|
+
--pine <entry> Execute a local .pine indicator file
|
|
4511
|
+
--editor Open the Pine Script visual editor in the browser
|
|
4512
|
+
--dump Fetch and save raw OHLCV candles
|
|
4513
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4514
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4515
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4516
|
+
--init Scaffold a new project in the current directory
|
|
4517
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4518
|
+
--help Print this help message
|
|
4519
|
+
|
|
4520
|
+
Backtest flags:
|
|
4521
|
+
|
|
4522
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4523
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4524
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4525
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4526
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4527
|
+
--noCache Skip candle cache warming before the run
|
|
4528
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4529
|
+
--verbose Log every candle fetch to stdout
|
|
4530
|
+
--ui Start web dashboard at http://localhost:60050
|
|
4531
|
+
--telegram Send trade notifications to Telegram
|
|
4532
|
+
|
|
4533
|
+
Walker flags (--walker):
|
|
4534
|
+
|
|
4535
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4536
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4537
|
+
--noCache Skip candle cache warming before the run
|
|
4538
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4539
|
+
--verbose Log every candle fetch to stdout
|
|
4540
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4541
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
4542
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4543
|
+
|
|
4544
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4545
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
4546
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4547
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4548
|
+
|
|
4549
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4550
|
+
|
|
4551
|
+
Paper / Live flags:
|
|
4552
|
+
|
|
4553
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4554
|
+
--strategy <string> Strategy name (default: first registered)
|
|
4555
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4556
|
+
--verbose Log every candle fetch to stdout
|
|
4557
|
+
--ui Start web dashboard
|
|
4558
|
+
--telegram Send Telegram notifications
|
|
4559
|
+
|
|
4560
|
+
Main flags (--main):
|
|
4561
|
+
|
|
4562
|
+
--noFlush Skip removing report/log/markdown/agent folders before the run
|
|
4563
|
+
|
|
4564
|
+
Prepares the runtime environment (loads .env, setup.config, loader.config and
|
|
4565
|
+
modules/main.module) and runs the single positional entry point — but does NOT
|
|
4566
|
+
start any trading harness. Unlike --backtest/--live/--walker, the CLI never calls
|
|
4567
|
+
Backtest/Live/Walker.background; the entry point decides what to run.
|
|
4568
|
+
|
|
4569
|
+
Exactly one positional entry point is required. process.cwd() is changed to the
|
|
4570
|
+
entry point directory and its local .env is loaded.
|
|
4571
|
+
|
|
4572
|
+
Backtest, Live and Walker runs started from userspace are still tracked: the run
|
|
4573
|
+
finishes automatically when one of them completes, Ctrl+C stops any active run,
|
|
4574
|
+
and a second Ctrl+C force-quits.
|
|
4575
|
+
|
|
4576
|
+
Module file ./modules/main.module is loaded automatically if it exists.
|
|
4577
|
+
|
|
4578
|
+
PineScript flags (--pine):
|
|
4579
|
+
|
|
4580
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4581
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4582
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
4583
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4584
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4585
|
+
--output <string> Output file base name without extension
|
|
4586
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4587
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4588
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4589
|
+
|
|
4590
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
4591
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4592
|
+
|
|
4593
|
+
Candle dump flags (--dump):
|
|
4594
|
+
|
|
4595
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4596
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4597
|
+
--limit <string> Number of candles (default: 250)
|
|
4598
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4599
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4600
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4601
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4602
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4603
|
+
|
|
4604
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4605
|
+
|
|
4606
|
+
PnL debug flags (--pnldebug):
|
|
4607
|
+
|
|
4608
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4609
|
+
--priceopen <number> Entry price (required)
|
|
4610
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4611
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4612
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4613
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4614
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4615
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4616
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4617
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4618
|
+
|
|
4619
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4620
|
+
|
|
4621
|
+
Broker debug flags (--brokerdebug):
|
|
4622
|
+
|
|
4623
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4624
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4625
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4626
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4627
|
+
(default: signal-open)
|
|
4628
|
+
|
|
4629
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4630
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4631
|
+
|
|
4632
|
+
Flush flags (--flush):
|
|
4633
|
+
|
|
4634
|
+
One or more positional entry points. For each entry point the following
|
|
4635
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4636
|
+
|
|
4637
|
+
report log markdown agent
|
|
4638
|
+
|
|
4639
|
+
Init flags (--init):
|
|
4640
|
+
|
|
4641
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4642
|
+
|
|
4643
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4644
|
+
|
|
4645
|
+
Docker flags (--docker):
|
|
4646
|
+
|
|
4647
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4648
|
+
|
|
4649
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4650
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4651
|
+
docker compose up to start the container.
|
|
4652
|
+
|
|
4653
|
+
Module hooks (loaded automatically by each mode):
|
|
4654
|
+
|
|
4655
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4656
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4657
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4658
|
+
modules/live.module --live Broker adapter for live trading
|
|
4659
|
+
modules/main.module --main Environment setup for a custom entry point
|
|
4660
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4661
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4662
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4663
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4664
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4665
|
+
|
|
4666
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4667
|
+
|
|
4668
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4669
|
+
|
|
4670
|
+
Environment variables:
|
|
4671
|
+
|
|
4672
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4673
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4674
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4675
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4676
|
+
|
|
4677
|
+
Examples:
|
|
4678
|
+
|
|
4679
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4680
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4681
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4682
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4683
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4684
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4685
|
+
node ${ENTRY_PATH} --main ./tools/fetch_fear_and_greed.ts
|
|
4686
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4687
|
+
node ${ENTRY_PATH} --editor
|
|
4688
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4689
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4690
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4691
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4692
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4693
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4694
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4695
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4696
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4696
4697
|
`.trimStart();
|
|
4697
4698
|
const main$1 = async () => {
|
|
4698
4699
|
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)))) {
|
|
@@ -4702,7 +4703,7 @@ const main$1 = async () => {
|
|
|
4702
4703
|
if (!values.help) {
|
|
4703
4704
|
return;
|
|
4704
4705
|
}
|
|
4705
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4706
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n\n`);
|
|
4706
4707
|
process.stdout.write(HELP_TEXT);
|
|
4707
4708
|
process.exit(0);
|
|
4708
4709
|
};
|
|
@@ -4716,7 +4717,7 @@ const main = async () => {
|
|
|
4716
4717
|
if (!values.version) {
|
|
4717
4718
|
return;
|
|
4718
4719
|
}
|
|
4719
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4720
|
+
process.stdout.write(`@backtest-kit/cli ${"13.3.0"}\n`);
|
|
4720
4721
|
process.exit(0);
|
|
4721
4722
|
};
|
|
4722
4723
|
main();
|