@backtest-kit/cli 10.1.0 → 11.0.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 +1854 -1854
- package/build/index.cjs +205 -193
- package/build/index.mjs +207 -195
- 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 +38 -38
- 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
|
@@ -90,6 +90,20 @@ BacktestKit.setConfig({
|
|
|
90
90
|
CC_WALKER_MARKDOWN_TOP_N: 10,
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
const getEntrySubject = functoolsKit.singleshot(() => {
|
|
94
|
+
const entrySubject = BacktestKit.emitters["entrySubject"];
|
|
95
|
+
if (entrySubject) {
|
|
96
|
+
return entrySubject;
|
|
97
|
+
}
|
|
98
|
+
return new functoolsKit.BehaviorSubject();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const main$h = () => {
|
|
102
|
+
const entrySubject = getEntrySubject();
|
|
103
|
+
entrySubject.subscribe((path) => console.log("Running", path));
|
|
104
|
+
};
|
|
105
|
+
main$h();
|
|
106
|
+
|
|
93
107
|
const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
|
|
94
108
|
function dumpStackTrace() {
|
|
95
109
|
const trace = stackTrace__namespace.get();
|
|
@@ -860,8 +874,6 @@ const notifyVerbose = functoolsKit.singleshot(() => {
|
|
|
860
874
|
});
|
|
861
875
|
});
|
|
862
876
|
|
|
863
|
-
const entrySubject = new functoolsKit.BehaviorSubject();
|
|
864
|
-
|
|
865
877
|
function killPid(pid, signal) {
|
|
866
878
|
try {
|
|
867
879
|
process.kill(pid, signal);
|
|
@@ -1085,7 +1097,7 @@ class BacktestMainService {
|
|
|
1085
1097
|
});
|
|
1086
1098
|
notifyVerbose();
|
|
1087
1099
|
}
|
|
1088
|
-
await
|
|
1100
|
+
await getEntrySubject().next(absolutePath);
|
|
1089
1101
|
BacktestKit.Backtest.background(symbol, {
|
|
1090
1102
|
strategyName,
|
|
1091
1103
|
frameName,
|
|
@@ -1451,7 +1463,7 @@ class LiveMainService {
|
|
|
1451
1463
|
});
|
|
1452
1464
|
notifyVerbose();
|
|
1453
1465
|
}
|
|
1454
|
-
await
|
|
1466
|
+
await getEntrySubject().next(absolutePath);
|
|
1455
1467
|
BacktestKit.Live.background(symbol, {
|
|
1456
1468
|
strategyName,
|
|
1457
1469
|
exchangeName,
|
|
@@ -1555,7 +1567,7 @@ class PaperMainService {
|
|
|
1555
1567
|
});
|
|
1556
1568
|
notifyVerbose();
|
|
1557
1569
|
}
|
|
1558
|
-
await
|
|
1570
|
+
await getEntrySubject().next(absolutePath);
|
|
1559
1571
|
BacktestKit.Live.background(symbol, {
|
|
1560
1572
|
strategyName,
|
|
1561
1573
|
exchangeName,
|
|
@@ -1587,7 +1599,7 @@ class PaperMainService {
|
|
|
1587
1599
|
}
|
|
1588
1600
|
|
|
1589
1601
|
const getEnv = functoolsKit.singleshot(() => {
|
|
1590
|
-
if (!
|
|
1602
|
+
if (!getEntrySubject().data) {
|
|
1591
1603
|
getEnv.clear();
|
|
1592
1604
|
}
|
|
1593
1605
|
return {
|
|
@@ -1680,7 +1692,7 @@ class FrontendProviderService {
|
|
|
1680
1692
|
if (!getArgs().values.ui) {
|
|
1681
1693
|
return;
|
|
1682
1694
|
}
|
|
1683
|
-
return
|
|
1695
|
+
return getEntrySubject().subscribe(this.enable);
|
|
1684
1696
|
});
|
|
1685
1697
|
}
|
|
1686
1698
|
}
|
|
@@ -1716,7 +1728,7 @@ class TelegramProviderService {
|
|
|
1716
1728
|
if (!getArgs().values.telegram) {
|
|
1717
1729
|
return;
|
|
1718
1730
|
}
|
|
1719
|
-
return
|
|
1731
|
+
return getEntrySubject().subscribe(this.enable);
|
|
1720
1732
|
});
|
|
1721
1733
|
}
|
|
1722
1734
|
}
|
|
@@ -3348,10 +3360,10 @@ init();
|
|
|
3348
3360
|
|
|
3349
3361
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3350
3362
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3351
|
-
const HELP_TEXT$1 = `
|
|
3352
|
-
Example:
|
|
3353
|
-
|
|
3354
|
-
node ${ENTRY_PATH$1} --help
|
|
3363
|
+
const HELP_TEXT$1 = `
|
|
3364
|
+
Example:
|
|
3365
|
+
|
|
3366
|
+
node ${ENTRY_PATH$1} --help
|
|
3355
3367
|
`.trimStart();
|
|
3356
3368
|
const main$g = async () => {
|
|
3357
3369
|
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)))) {
|
|
@@ -3361,7 +3373,7 @@ const main$g = async () => {
|
|
|
3361
3373
|
if (MODES.some((mode) => values[mode])) {
|
|
3362
3374
|
return;
|
|
3363
3375
|
}
|
|
3364
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
3376
|
+
process.stdout.write(`@backtest-kit/cli ${"11.0.0"}\n`);
|
|
3365
3377
|
process.stdout.write("\n");
|
|
3366
3378
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3367
3379
|
process.stdout.write("\n");
|
|
@@ -3701,7 +3713,7 @@ const main$a = async () => {
|
|
|
3701
3713
|
absolutePath = path.resolve(cwd, entryPoint);
|
|
3702
3714
|
await cli.resolveService.attachEntry(absolutePath);
|
|
3703
3715
|
}
|
|
3704
|
-
await
|
|
3716
|
+
await getEntrySubject().next(absolutePath);
|
|
3705
3717
|
};
|
|
3706
3718
|
main$a();
|
|
3707
3719
|
|
|
@@ -4312,183 +4324,183 @@ const main$2 = async () => {
|
|
|
4312
4324
|
main$2();
|
|
4313
4325
|
|
|
4314
4326
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
4315
|
-
const HELP_TEXT = `
|
|
4316
|
-
Usage:
|
|
4317
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
4318
|
-
|
|
4319
|
-
Modes:
|
|
4320
|
-
|
|
4321
|
-
--backtest <entry> Run strategy against historical candle data
|
|
4322
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4323
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
4324
|
-
--live <entry> Live trading with real orders
|
|
4325
|
-
--pine <entry> Execute a local .pine indicator file
|
|
4326
|
-
--editor Open the Pine Script visual editor in the browser
|
|
4327
|
-
--dump Fetch and save raw OHLCV candles
|
|
4328
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4329
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4330
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4331
|
-
--init Scaffold a new project in the current directory
|
|
4332
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4333
|
-
--help Print this help message
|
|
4334
|
-
|
|
4335
|
-
Backtest flags:
|
|
4336
|
-
|
|
4337
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4338
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4339
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4340
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4341
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4342
|
-
--noCache Skip candle cache warming before the run
|
|
4343
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4344
|
-
--verbose Log every candle fetch to stdout
|
|
4345
|
-
--ui Start web dashboard at http://localhost:60050
|
|
4346
|
-
--telegram Send trade notifications to Telegram
|
|
4347
|
-
|
|
4348
|
-
Walker flags (--walker):
|
|
4349
|
-
|
|
4350
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4351
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4352
|
-
--noCache Skip candle cache warming before the run
|
|
4353
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4354
|
-
--verbose Log every candle fetch to stdout
|
|
4355
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4356
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
4357
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4358
|
-
|
|
4359
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4360
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
4361
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4362
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4363
|
-
|
|
4364
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4365
|
-
|
|
4366
|
-
Paper / Live flags:
|
|
4367
|
-
|
|
4368
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4369
|
-
--strategy <string> Strategy name (default: first registered)
|
|
4370
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4371
|
-
--verbose Log every candle fetch to stdout
|
|
4372
|
-
--ui Start web dashboard
|
|
4373
|
-
--telegram Send Telegram notifications
|
|
4374
|
-
|
|
4375
|
-
PineScript flags (--pine):
|
|
4376
|
-
|
|
4377
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4378
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4379
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
4380
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4381
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4382
|
-
--output <string> Output file base name without extension
|
|
4383
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4384
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4385
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4386
|
-
|
|
4387
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
4388
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4389
|
-
|
|
4390
|
-
Candle dump flags (--dump):
|
|
4391
|
-
|
|
4392
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4393
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4394
|
-
--limit <string> Number of candles (default: 250)
|
|
4395
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4396
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4397
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4398
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4399
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4400
|
-
|
|
4401
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4402
|
-
|
|
4403
|
-
PnL debug flags (--pnldebug):
|
|
4404
|
-
|
|
4405
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4406
|
-
--priceopen <number> Entry price (required)
|
|
4407
|
-
--direction <string> Position direction: long or short (default: long)
|
|
4408
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4409
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4410
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4411
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4412
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4413
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4414
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4415
|
-
|
|
4416
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4417
|
-
|
|
4418
|
-
Broker debug flags (--brokerdebug):
|
|
4419
|
-
|
|
4420
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4421
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4422
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4423
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4424
|
-
(default: signal-open)
|
|
4425
|
-
|
|
4426
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4427
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
4428
|
-
|
|
4429
|
-
Flush flags (--flush):
|
|
4430
|
-
|
|
4431
|
-
One or more positional entry points. For each entry point the following
|
|
4432
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
4433
|
-
|
|
4434
|
-
report log markdown agent
|
|
4435
|
-
|
|
4436
|
-
Init flags (--init):
|
|
4437
|
-
|
|
4438
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
4439
|
-
|
|
4440
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4441
|
-
|
|
4442
|
-
Docker flags (--docker):
|
|
4443
|
-
|
|
4444
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4445
|
-
|
|
4446
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4447
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4448
|
-
docker compose up to start the container.
|
|
4449
|
-
|
|
4450
|
-
Module hooks (loaded automatically by each mode):
|
|
4451
|
-
|
|
4452
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4453
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4454
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4455
|
-
modules/live.module --live Broker adapter for live trading
|
|
4456
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4457
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4458
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4459
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4460
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4461
|
-
|
|
4462
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4463
|
-
|
|
4464
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4465
|
-
|
|
4466
|
-
Environment variables:
|
|
4467
|
-
|
|
4468
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4469
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4470
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4471
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4472
|
-
|
|
4473
|
-
Examples:
|
|
4474
|
-
|
|
4475
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4476
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4477
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4478
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4479
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4480
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4481
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4482
|
-
node ${ENTRY_PATH} --editor
|
|
4483
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4484
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4485
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4486
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4487
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4488
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4489
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4490
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4491
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4327
|
+
const HELP_TEXT = `
|
|
4328
|
+
Usage:
|
|
4329
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
4330
|
+
|
|
4331
|
+
Modes:
|
|
4332
|
+
|
|
4333
|
+
--backtest <entry> Run strategy against historical candle data
|
|
4334
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4335
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
4336
|
+
--live <entry> Live trading with real orders
|
|
4337
|
+
--pine <entry> Execute a local .pine indicator file
|
|
4338
|
+
--editor Open the Pine Script visual editor in the browser
|
|
4339
|
+
--dump Fetch and save raw OHLCV candles
|
|
4340
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4341
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4342
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4343
|
+
--init Scaffold a new project in the current directory
|
|
4344
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4345
|
+
--help Print this help message
|
|
4346
|
+
|
|
4347
|
+
Backtest flags:
|
|
4348
|
+
|
|
4349
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4350
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4351
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4352
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4353
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4354
|
+
--noCache Skip candle cache warming before the run
|
|
4355
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4356
|
+
--verbose Log every candle fetch to stdout
|
|
4357
|
+
--ui Start web dashboard at http://localhost:60050
|
|
4358
|
+
--telegram Send trade notifications to Telegram
|
|
4359
|
+
|
|
4360
|
+
Walker flags (--walker):
|
|
4361
|
+
|
|
4362
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4363
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4364
|
+
--noCache Skip candle cache warming before the run
|
|
4365
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4366
|
+
--verbose Log every candle fetch to stdout
|
|
4367
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4368
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
4369
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4370
|
+
|
|
4371
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4372
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
4373
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4374
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4375
|
+
|
|
4376
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4377
|
+
|
|
4378
|
+
Paper / Live flags:
|
|
4379
|
+
|
|
4380
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4381
|
+
--strategy <string> Strategy name (default: first registered)
|
|
4382
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4383
|
+
--verbose Log every candle fetch to stdout
|
|
4384
|
+
--ui Start web dashboard
|
|
4385
|
+
--telegram Send Telegram notifications
|
|
4386
|
+
|
|
4387
|
+
PineScript flags (--pine):
|
|
4388
|
+
|
|
4389
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4390
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4391
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
4392
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4393
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4394
|
+
--output <string> Output file base name without extension
|
|
4395
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4396
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4397
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4398
|
+
|
|
4399
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
4400
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4401
|
+
|
|
4402
|
+
Candle dump flags (--dump):
|
|
4403
|
+
|
|
4404
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4405
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4406
|
+
--limit <string> Number of candles (default: 250)
|
|
4407
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4408
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4409
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4410
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4411
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4412
|
+
|
|
4413
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4414
|
+
|
|
4415
|
+
PnL debug flags (--pnldebug):
|
|
4416
|
+
|
|
4417
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4418
|
+
--priceopen <number> Entry price (required)
|
|
4419
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4420
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4421
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4422
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4423
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4424
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4425
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4426
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4427
|
+
|
|
4428
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4429
|
+
|
|
4430
|
+
Broker debug flags (--brokerdebug):
|
|
4431
|
+
|
|
4432
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4433
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4434
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4435
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4436
|
+
(default: signal-open)
|
|
4437
|
+
|
|
4438
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4439
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4440
|
+
|
|
4441
|
+
Flush flags (--flush):
|
|
4442
|
+
|
|
4443
|
+
One or more positional entry points. For each entry point the following
|
|
4444
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4445
|
+
|
|
4446
|
+
report log markdown agent
|
|
4447
|
+
|
|
4448
|
+
Init flags (--init):
|
|
4449
|
+
|
|
4450
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4451
|
+
|
|
4452
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4453
|
+
|
|
4454
|
+
Docker flags (--docker):
|
|
4455
|
+
|
|
4456
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4457
|
+
|
|
4458
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4459
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4460
|
+
docker compose up to start the container.
|
|
4461
|
+
|
|
4462
|
+
Module hooks (loaded automatically by each mode):
|
|
4463
|
+
|
|
4464
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4465
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4466
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4467
|
+
modules/live.module --live Broker adapter for live trading
|
|
4468
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4469
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4470
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4471
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4472
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4473
|
+
|
|
4474
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4475
|
+
|
|
4476
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4477
|
+
|
|
4478
|
+
Environment variables:
|
|
4479
|
+
|
|
4480
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4481
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4482
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4483
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4484
|
+
|
|
4485
|
+
Examples:
|
|
4486
|
+
|
|
4487
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4488
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4489
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4490
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4491
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4492
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4493
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4494
|
+
node ${ENTRY_PATH} --editor
|
|
4495
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4496
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4497
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4498
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4499
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4500
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4501
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4502
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4503
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4492
4504
|
`.trimStart();
|
|
4493
4505
|
const main$1 = async () => {
|
|
4494
4506
|
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)))) {
|
|
@@ -4498,7 +4510,7 @@ const main$1 = async () => {
|
|
|
4498
4510
|
if (!values.help) {
|
|
4499
4511
|
return;
|
|
4500
4512
|
}
|
|
4501
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4513
|
+
process.stdout.write(`@backtest-kit/cli ${"11.0.0"}\n\n`);
|
|
4502
4514
|
process.stdout.write(HELP_TEXT);
|
|
4503
4515
|
process.exit(0);
|
|
4504
4516
|
};
|
|
@@ -4512,7 +4524,7 @@ const main = async () => {
|
|
|
4512
4524
|
if (!values.version) {
|
|
4513
4525
|
return;
|
|
4514
4526
|
}
|
|
4515
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4527
|
+
process.stdout.write(`@backtest-kit/cli ${"11.0.0"}\n`);
|
|
4516
4528
|
process.exit(0);
|
|
4517
4529
|
};
|
|
4518
4530
|
main();
|