@backtest-kit/cli 9.1.1 → 9.2.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 +1694 -1694
- package/build/index.cjs +220 -184
- package/build/index.mjs +220 -184
- 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
|
@@ -904,6 +904,10 @@ class BacktestMainService {
|
|
|
904
904
|
this.frontendProviderService.connect();
|
|
905
905
|
this.telegramProviderService.connect();
|
|
906
906
|
}
|
|
907
|
+
{
|
|
908
|
+
const cwd = process.cwd();
|
|
909
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
910
|
+
}
|
|
907
911
|
{
|
|
908
912
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
909
913
|
await this.moduleConnectionService.loadModule("./backtest.module");
|
|
@@ -1042,6 +1046,10 @@ class WalkerMainService {
|
|
|
1042
1046
|
BacktestKit.Cache.resetCounter();
|
|
1043
1047
|
BacktestKit.Interval.resetCounter();
|
|
1044
1048
|
}
|
|
1049
|
+
{
|
|
1050
|
+
const cwd = process.cwd();
|
|
1051
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1052
|
+
}
|
|
1045
1053
|
await this.moduleConnectionService.loadModule("./walker.module");
|
|
1046
1054
|
{
|
|
1047
1055
|
this.exchangeSchemaService.addSchema();
|
|
@@ -1236,6 +1244,10 @@ class LiveMainService {
|
|
|
1236
1244
|
this.frontendProviderService.connect();
|
|
1237
1245
|
this.telegramProviderService.connect();
|
|
1238
1246
|
}
|
|
1247
|
+
{
|
|
1248
|
+
const cwd = process.cwd();
|
|
1249
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1250
|
+
}
|
|
1239
1251
|
{
|
|
1240
1252
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
1241
1253
|
await this.moduleConnectionService.loadModule("./live.module");
|
|
@@ -1316,6 +1328,10 @@ class PaperMainService {
|
|
|
1316
1328
|
this.frontendProviderService.connect();
|
|
1317
1329
|
this.telegramProviderService.connect();
|
|
1318
1330
|
}
|
|
1331
|
+
{
|
|
1332
|
+
const cwd = process.cwd();
|
|
1333
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1334
|
+
}
|
|
1319
1335
|
{
|
|
1320
1336
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
1321
1337
|
await this.moduleConnectionService.loadModule("./paper.module");
|
|
@@ -3038,10 +3054,10 @@ init();
|
|
|
3038
3054
|
|
|
3039
3055
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3040
3056
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3041
|
-
const HELP_TEXT$1 = `
|
|
3042
|
-
Example:
|
|
3043
|
-
|
|
3044
|
-
node ${ENTRY_PATH$1} --help
|
|
3057
|
+
const HELP_TEXT$1 = `
|
|
3058
|
+
Example:
|
|
3059
|
+
|
|
3060
|
+
node ${ENTRY_PATH$1} --help
|
|
3045
3061
|
`.trimStart();
|
|
3046
3062
|
const main$g = async () => {
|
|
3047
3063
|
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)))) {
|
|
@@ -3051,7 +3067,7 @@ const main$g = async () => {
|
|
|
3051
3067
|
if (MODES.some((mode) => values[mode])) {
|
|
3052
3068
|
return;
|
|
3053
3069
|
}
|
|
3054
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3070
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n`);
|
|
3055
3071
|
process.stdout.write("\n");
|
|
3056
3072
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3057
3073
|
process.stdout.write("\n");
|
|
@@ -3343,6 +3359,10 @@ const main$a = async () => {
|
|
|
3343
3359
|
Setup.enable();
|
|
3344
3360
|
cli.frontendProviderService.connect();
|
|
3345
3361
|
cli.telegramProviderService.connect();
|
|
3362
|
+
{
|
|
3363
|
+
const cwd = process.cwd();
|
|
3364
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3365
|
+
}
|
|
3346
3366
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3347
3367
|
listenFinish();
|
|
3348
3368
|
createGracefulShutdown(mode)();
|
|
@@ -3427,6 +3447,10 @@ const main$7 = async () => {
|
|
|
3427
3447
|
return;
|
|
3428
3448
|
}
|
|
3429
3449
|
const source = await cli.resolveService.attachPine(entryPoint);
|
|
3450
|
+
{
|
|
3451
|
+
const cwd = process.cwd();
|
|
3452
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3453
|
+
}
|
|
3430
3454
|
await cli.moduleConnectionService.loadModule("./pine.module");
|
|
3431
3455
|
{
|
|
3432
3456
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3508,6 +3532,10 @@ const main$6 = async () => {
|
|
|
3508
3532
|
await cli.configService.waitForInit();
|
|
3509
3533
|
Setup.enable();
|
|
3510
3534
|
}
|
|
3535
|
+
{
|
|
3536
|
+
const cwd = process.cwd();
|
|
3537
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3538
|
+
}
|
|
3511
3539
|
await cli.moduleConnectionService.loadModule("./editor.module");
|
|
3512
3540
|
{
|
|
3513
3541
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3537,6 +3565,10 @@ const main$5 = async () => {
|
|
|
3537
3565
|
if (!values.dump) {
|
|
3538
3566
|
return;
|
|
3539
3567
|
}
|
|
3568
|
+
{
|
|
3569
|
+
const cwd = process.cwd();
|
|
3570
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3571
|
+
}
|
|
3540
3572
|
await cli.moduleConnectionService.loadModule("./dump.module");
|
|
3541
3573
|
{
|
|
3542
3574
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3600,6 +3632,10 @@ const main$4 = async () => {
|
|
|
3600
3632
|
if (!values.pnldebug) {
|
|
3601
3633
|
return;
|
|
3602
3634
|
}
|
|
3635
|
+
{
|
|
3636
|
+
const cwd = process.cwd();
|
|
3637
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3638
|
+
}
|
|
3603
3639
|
await cli.moduleConnectionService.loadModule("./pnldebug.module");
|
|
3604
3640
|
{
|
|
3605
3641
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3868,183 +3904,183 @@ const main$2 = async () => {
|
|
|
3868
3904
|
main$2();
|
|
3869
3905
|
|
|
3870
3906
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3871
|
-
const HELP_TEXT = `
|
|
3872
|
-
Usage:
|
|
3873
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
3874
|
-
|
|
3875
|
-
Modes:
|
|
3876
|
-
|
|
3877
|
-
--backtest <entry> Run strategy against historical candle data
|
|
3878
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3879
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
3880
|
-
--live <entry> Live trading with real orders
|
|
3881
|
-
--pine <entry> Execute a local .pine indicator file
|
|
3882
|
-
--editor Open the Pine Script visual editor in the browser
|
|
3883
|
-
--dump Fetch and save raw OHLCV candles
|
|
3884
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3885
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3886
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3887
|
-
--init Scaffold a new project in the current directory
|
|
3888
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3889
|
-
--help Print this help message
|
|
3890
|
-
|
|
3891
|
-
Backtest flags:
|
|
3892
|
-
|
|
3893
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3894
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3895
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3896
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3897
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3898
|
-
--noCache Skip candle cache warming before the run
|
|
3899
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3900
|
-
--verbose Log every candle fetch to stdout
|
|
3901
|
-
--ui Start web dashboard at http://localhost:60050
|
|
3902
|
-
--telegram Send trade notifications to Telegram
|
|
3903
|
-
|
|
3904
|
-
Walker flags (--walker):
|
|
3905
|
-
|
|
3906
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3907
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3908
|
-
--noCache Skip candle cache warming before the run
|
|
3909
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3910
|
-
--verbose Log every candle fetch to stdout
|
|
3911
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3912
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
3913
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3914
|
-
|
|
3915
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3916
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
3917
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3918
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3919
|
-
|
|
3920
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3921
|
-
|
|
3922
|
-
Paper / Live flags:
|
|
3923
|
-
|
|
3924
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3925
|
-
--strategy <string> Strategy name (default: first registered)
|
|
3926
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3927
|
-
--verbose Log every candle fetch to stdout
|
|
3928
|
-
--ui Start web dashboard
|
|
3929
|
-
--telegram Send Telegram notifications
|
|
3930
|
-
|
|
3931
|
-
PineScript flags (--pine):
|
|
3932
|
-
|
|
3933
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3934
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3935
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
3936
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3937
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3938
|
-
--output <string> Output file base name without extension
|
|
3939
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3940
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3941
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3942
|
-
|
|
3943
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
3944
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3945
|
-
|
|
3946
|
-
Candle dump flags (--dump):
|
|
3947
|
-
|
|
3948
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3949
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3950
|
-
--limit <string> Number of candles (default: 250)
|
|
3951
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3952
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3953
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3954
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3955
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3956
|
-
|
|
3957
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3958
|
-
|
|
3959
|
-
PnL debug flags (--pnldebug):
|
|
3960
|
-
|
|
3961
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3962
|
-
--priceopen <number> Entry price (required)
|
|
3963
|
-
--direction <string> Position direction: long or short (default: long)
|
|
3964
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3965
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3966
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3967
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3968
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3969
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3970
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3971
|
-
|
|
3972
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3973
|
-
|
|
3974
|
-
Broker debug flags (--brokerdebug):
|
|
3975
|
-
|
|
3976
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3977
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3978
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3979
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3980
|
-
(default: signal-open)
|
|
3981
|
-
|
|
3982
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3983
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
3984
|
-
|
|
3985
|
-
Flush flags (--flush):
|
|
3986
|
-
|
|
3987
|
-
One or more positional entry points. For each entry point the following
|
|
3988
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
3989
|
-
|
|
3990
|
-
report log markdown agent
|
|
3991
|
-
|
|
3992
|
-
Init flags (--init):
|
|
3993
|
-
|
|
3994
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
3995
|
-
|
|
3996
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3997
|
-
|
|
3998
|
-
Docker flags (--docker):
|
|
3999
|
-
|
|
4000
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4001
|
-
|
|
4002
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4003
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4004
|
-
docker compose up to start the container.
|
|
4005
|
-
|
|
4006
|
-
Module hooks (loaded automatically by each mode):
|
|
4007
|
-
|
|
4008
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4009
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4010
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4011
|
-
modules/live.module --live Broker adapter for live trading
|
|
4012
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4013
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4014
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4015
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4016
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4017
|
-
|
|
4018
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4019
|
-
|
|
4020
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4021
|
-
|
|
4022
|
-
Environment variables:
|
|
4023
|
-
|
|
4024
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4025
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4026
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4027
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4028
|
-
|
|
4029
|
-
Examples:
|
|
4030
|
-
|
|
4031
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4032
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4033
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4034
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4035
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4036
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4037
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4038
|
-
node ${ENTRY_PATH} --editor
|
|
4039
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4040
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4041
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4042
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4043
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4044
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4045
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4046
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4047
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
3907
|
+
const HELP_TEXT = `
|
|
3908
|
+
Usage:
|
|
3909
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
3910
|
+
|
|
3911
|
+
Modes:
|
|
3912
|
+
|
|
3913
|
+
--backtest <entry> Run strategy against historical candle data
|
|
3914
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3915
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
3916
|
+
--live <entry> Live trading with real orders
|
|
3917
|
+
--pine <entry> Execute a local .pine indicator file
|
|
3918
|
+
--editor Open the Pine Script visual editor in the browser
|
|
3919
|
+
--dump Fetch and save raw OHLCV candles
|
|
3920
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3921
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3922
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3923
|
+
--init Scaffold a new project in the current directory
|
|
3924
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3925
|
+
--help Print this help message
|
|
3926
|
+
|
|
3927
|
+
Backtest flags:
|
|
3928
|
+
|
|
3929
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3930
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3931
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3932
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3933
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3934
|
+
--noCache Skip candle cache warming before the run
|
|
3935
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3936
|
+
--verbose Log every candle fetch to stdout
|
|
3937
|
+
--ui Start web dashboard at http://localhost:60050
|
|
3938
|
+
--telegram Send trade notifications to Telegram
|
|
3939
|
+
|
|
3940
|
+
Walker flags (--walker):
|
|
3941
|
+
|
|
3942
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3943
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3944
|
+
--noCache Skip candle cache warming before the run
|
|
3945
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3946
|
+
--verbose Log every candle fetch to stdout
|
|
3947
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3948
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
3949
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3950
|
+
|
|
3951
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3952
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
3953
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3954
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3955
|
+
|
|
3956
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3957
|
+
|
|
3958
|
+
Paper / Live flags:
|
|
3959
|
+
|
|
3960
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3961
|
+
--strategy <string> Strategy name (default: first registered)
|
|
3962
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3963
|
+
--verbose Log every candle fetch to stdout
|
|
3964
|
+
--ui Start web dashboard
|
|
3965
|
+
--telegram Send Telegram notifications
|
|
3966
|
+
|
|
3967
|
+
PineScript flags (--pine):
|
|
3968
|
+
|
|
3969
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3970
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3971
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
3972
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3973
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3974
|
+
--output <string> Output file base name without extension
|
|
3975
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3976
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3977
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3978
|
+
|
|
3979
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
3980
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3981
|
+
|
|
3982
|
+
Candle dump flags (--dump):
|
|
3983
|
+
|
|
3984
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3985
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3986
|
+
--limit <string> Number of candles (default: 250)
|
|
3987
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3988
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3989
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3990
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3991
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3992
|
+
|
|
3993
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3994
|
+
|
|
3995
|
+
PnL debug flags (--pnldebug):
|
|
3996
|
+
|
|
3997
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3998
|
+
--priceopen <number> Entry price (required)
|
|
3999
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4000
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4001
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4002
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4003
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4004
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4005
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4006
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4007
|
+
|
|
4008
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4009
|
+
|
|
4010
|
+
Broker debug flags (--brokerdebug):
|
|
4011
|
+
|
|
4012
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4013
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4014
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4015
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4016
|
+
(default: signal-open)
|
|
4017
|
+
|
|
4018
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4019
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4020
|
+
|
|
4021
|
+
Flush flags (--flush):
|
|
4022
|
+
|
|
4023
|
+
One or more positional entry points. For each entry point the following
|
|
4024
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4025
|
+
|
|
4026
|
+
report log markdown agent
|
|
4027
|
+
|
|
4028
|
+
Init flags (--init):
|
|
4029
|
+
|
|
4030
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4031
|
+
|
|
4032
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4033
|
+
|
|
4034
|
+
Docker flags (--docker):
|
|
4035
|
+
|
|
4036
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4037
|
+
|
|
4038
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4039
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4040
|
+
docker compose up to start the container.
|
|
4041
|
+
|
|
4042
|
+
Module hooks (loaded automatically by each mode):
|
|
4043
|
+
|
|
4044
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4045
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4046
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4047
|
+
modules/live.module --live Broker adapter for live trading
|
|
4048
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4049
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4050
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4051
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4052
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4053
|
+
|
|
4054
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4055
|
+
|
|
4056
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4057
|
+
|
|
4058
|
+
Environment variables:
|
|
4059
|
+
|
|
4060
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4061
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4062
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4063
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4064
|
+
|
|
4065
|
+
Examples:
|
|
4066
|
+
|
|
4067
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4068
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4069
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4070
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4071
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4072
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4073
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4074
|
+
node ${ENTRY_PATH} --editor
|
|
4075
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4076
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4077
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4078
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4079
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4080
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4081
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4082
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4083
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4048
4084
|
`.trimStart();
|
|
4049
4085
|
const main$1 = async () => {
|
|
4050
4086
|
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)))) {
|
|
@@ -4054,7 +4090,7 @@ const main$1 = async () => {
|
|
|
4054
4090
|
if (!values.help) {
|
|
4055
4091
|
return;
|
|
4056
4092
|
}
|
|
4057
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4093
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n\n`);
|
|
4058
4094
|
process.stdout.write(HELP_TEXT);
|
|
4059
4095
|
process.exit(0);
|
|
4060
4096
|
};
|
|
@@ -4068,7 +4104,7 @@ const main = async () => {
|
|
|
4068
4104
|
if (!values.version) {
|
|
4069
4105
|
return;
|
|
4070
4106
|
}
|
|
4071
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4107
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n`);
|
|
4072
4108
|
process.exit(0);
|
|
4073
4109
|
};
|
|
4074
4110
|
main();
|