@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.mjs
CHANGED
|
@@ -879,6 +879,10 @@ class BacktestMainService {
|
|
|
879
879
|
this.frontendProviderService.connect();
|
|
880
880
|
this.telegramProviderService.connect();
|
|
881
881
|
}
|
|
882
|
+
{
|
|
883
|
+
const cwd = process.cwd();
|
|
884
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
885
|
+
}
|
|
882
886
|
{
|
|
883
887
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
884
888
|
await this.moduleConnectionService.loadModule("./backtest.module");
|
|
@@ -1017,6 +1021,10 @@ class WalkerMainService {
|
|
|
1017
1021
|
Cache.resetCounter();
|
|
1018
1022
|
Interval.resetCounter();
|
|
1019
1023
|
}
|
|
1024
|
+
{
|
|
1025
|
+
const cwd = process.cwd();
|
|
1026
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1027
|
+
}
|
|
1020
1028
|
await this.moduleConnectionService.loadModule("./walker.module");
|
|
1021
1029
|
{
|
|
1022
1030
|
this.exchangeSchemaService.addSchema();
|
|
@@ -1211,6 +1219,10 @@ class LiveMainService {
|
|
|
1211
1219
|
this.frontendProviderService.connect();
|
|
1212
1220
|
this.telegramProviderService.connect();
|
|
1213
1221
|
}
|
|
1222
|
+
{
|
|
1223
|
+
const cwd = process.cwd();
|
|
1224
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1225
|
+
}
|
|
1214
1226
|
{
|
|
1215
1227
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
1216
1228
|
await this.moduleConnectionService.loadModule("./live.module");
|
|
@@ -1291,6 +1303,10 @@ class PaperMainService {
|
|
|
1291
1303
|
this.frontendProviderService.connect();
|
|
1292
1304
|
this.telegramProviderService.connect();
|
|
1293
1305
|
}
|
|
1306
|
+
{
|
|
1307
|
+
const cwd = process.cwd();
|
|
1308
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
1309
|
+
}
|
|
1294
1310
|
{
|
|
1295
1311
|
await this.resolveService.attachJavascript(payload.entryPoint);
|
|
1296
1312
|
await this.moduleConnectionService.loadModule("./paper.module");
|
|
@@ -3009,10 +3025,10 @@ init();
|
|
|
3009
3025
|
|
|
3010
3026
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3011
3027
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3012
|
-
const HELP_TEXT$1 = `
|
|
3013
|
-
Example:
|
|
3014
|
-
|
|
3015
|
-
node ${ENTRY_PATH$1} --help
|
|
3028
|
+
const HELP_TEXT$1 = `
|
|
3029
|
+
Example:
|
|
3030
|
+
|
|
3031
|
+
node ${ENTRY_PATH$1} --help
|
|
3016
3032
|
`.trimStart();
|
|
3017
3033
|
const main$g = async () => {
|
|
3018
3034
|
if (!getEntry(import.meta.url)) {
|
|
@@ -3022,7 +3038,7 @@ const main$g = async () => {
|
|
|
3022
3038
|
if (MODES.some((mode) => values[mode])) {
|
|
3023
3039
|
return;
|
|
3024
3040
|
}
|
|
3025
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3041
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n`);
|
|
3026
3042
|
process.stdout.write("\n");
|
|
3027
3043
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3028
3044
|
process.stdout.write("\n");
|
|
@@ -3314,6 +3330,10 @@ const main$a = async () => {
|
|
|
3314
3330
|
Setup.enable();
|
|
3315
3331
|
cli.frontendProviderService.connect();
|
|
3316
3332
|
cli.telegramProviderService.connect();
|
|
3333
|
+
{
|
|
3334
|
+
const cwd = process.cwd();
|
|
3335
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3336
|
+
}
|
|
3317
3337
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3318
3338
|
listenFinish();
|
|
3319
3339
|
createGracefulShutdown(mode)();
|
|
@@ -3398,6 +3418,10 @@ const main$7 = async () => {
|
|
|
3398
3418
|
return;
|
|
3399
3419
|
}
|
|
3400
3420
|
const source = await cli.resolveService.attachPine(entryPoint);
|
|
3421
|
+
{
|
|
3422
|
+
const cwd = process.cwd();
|
|
3423
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3424
|
+
}
|
|
3401
3425
|
await cli.moduleConnectionService.loadModule("./pine.module");
|
|
3402
3426
|
{
|
|
3403
3427
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3479,6 +3503,10 @@ const main$6 = async () => {
|
|
|
3479
3503
|
await cli.configService.waitForInit();
|
|
3480
3504
|
Setup.enable();
|
|
3481
3505
|
}
|
|
3506
|
+
{
|
|
3507
|
+
const cwd = process.cwd();
|
|
3508
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3509
|
+
}
|
|
3482
3510
|
await cli.moduleConnectionService.loadModule("./editor.module");
|
|
3483
3511
|
{
|
|
3484
3512
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3508,6 +3536,10 @@ const main$5 = async () => {
|
|
|
3508
3536
|
if (!values.dump) {
|
|
3509
3537
|
return;
|
|
3510
3538
|
}
|
|
3539
|
+
{
|
|
3540
|
+
const cwd = process.cwd();
|
|
3541
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3542
|
+
}
|
|
3511
3543
|
await cli.moduleConnectionService.loadModule("./dump.module");
|
|
3512
3544
|
{
|
|
3513
3545
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3571,6 +3603,10 @@ const main$4 = async () => {
|
|
|
3571
3603
|
if (!values.pnldebug) {
|
|
3572
3604
|
return;
|
|
3573
3605
|
}
|
|
3606
|
+
{
|
|
3607
|
+
const cwd = process.cwd();
|
|
3608
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3609
|
+
}
|
|
3574
3610
|
await cli.moduleConnectionService.loadModule("./pnldebug.module");
|
|
3575
3611
|
{
|
|
3576
3612
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3839,183 +3875,183 @@ const main$2 = async () => {
|
|
|
3839
3875
|
main$2();
|
|
3840
3876
|
|
|
3841
3877
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3842
|
-
const HELP_TEXT = `
|
|
3843
|
-
Usage:
|
|
3844
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
3845
|
-
|
|
3846
|
-
Modes:
|
|
3847
|
-
|
|
3848
|
-
--backtest <entry> Run strategy against historical candle data
|
|
3849
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3850
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
3851
|
-
--live <entry> Live trading with real orders
|
|
3852
|
-
--pine <entry> Execute a local .pine indicator file
|
|
3853
|
-
--editor Open the Pine Script visual editor in the browser
|
|
3854
|
-
--dump Fetch and save raw OHLCV candles
|
|
3855
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3856
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3857
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3858
|
-
--init Scaffold a new project in the current directory
|
|
3859
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3860
|
-
--help Print this help message
|
|
3861
|
-
|
|
3862
|
-
Backtest flags:
|
|
3863
|
-
|
|
3864
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3865
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3866
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3867
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3868
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3869
|
-
--noCache Skip candle cache warming before the run
|
|
3870
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3871
|
-
--verbose Log every candle fetch to stdout
|
|
3872
|
-
--ui Start web dashboard at http://localhost:60050
|
|
3873
|
-
--telegram Send trade notifications to Telegram
|
|
3874
|
-
|
|
3875
|
-
Walker flags (--walker):
|
|
3876
|
-
|
|
3877
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3878
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3879
|
-
--noCache Skip candle cache warming before the run
|
|
3880
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3881
|
-
--verbose Log every candle fetch to stdout
|
|
3882
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3883
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
3884
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3885
|
-
|
|
3886
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3887
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
3888
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3889
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3890
|
-
|
|
3891
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3892
|
-
|
|
3893
|
-
Paper / Live flags:
|
|
3894
|
-
|
|
3895
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3896
|
-
--strategy <string> Strategy name (default: first registered)
|
|
3897
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3898
|
-
--verbose Log every candle fetch to stdout
|
|
3899
|
-
--ui Start web dashboard
|
|
3900
|
-
--telegram Send Telegram notifications
|
|
3901
|
-
|
|
3902
|
-
PineScript flags (--pine):
|
|
3903
|
-
|
|
3904
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3905
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3906
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
3907
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3908
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3909
|
-
--output <string> Output file base name without extension
|
|
3910
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3911
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3912
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3913
|
-
|
|
3914
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
3915
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3916
|
-
|
|
3917
|
-
Candle dump flags (--dump):
|
|
3918
|
-
|
|
3919
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3920
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3921
|
-
--limit <string> Number of candles (default: 250)
|
|
3922
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3923
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3924
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3925
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3926
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3927
|
-
|
|
3928
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3929
|
-
|
|
3930
|
-
PnL debug flags (--pnldebug):
|
|
3931
|
-
|
|
3932
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3933
|
-
--priceopen <number> Entry price (required)
|
|
3934
|
-
--direction <string> Position direction: long or short (default: long)
|
|
3935
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3936
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3937
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3938
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3939
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3940
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3941
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3942
|
-
|
|
3943
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3944
|
-
|
|
3945
|
-
Broker debug flags (--brokerdebug):
|
|
3946
|
-
|
|
3947
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3948
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3949
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3950
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3951
|
-
(default: signal-open)
|
|
3952
|
-
|
|
3953
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3954
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
3955
|
-
|
|
3956
|
-
Flush flags (--flush):
|
|
3957
|
-
|
|
3958
|
-
One or more positional entry points. For each entry point the following
|
|
3959
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
3960
|
-
|
|
3961
|
-
report log markdown agent
|
|
3962
|
-
|
|
3963
|
-
Init flags (--init):
|
|
3964
|
-
|
|
3965
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
3966
|
-
|
|
3967
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3968
|
-
|
|
3969
|
-
Docker flags (--docker):
|
|
3970
|
-
|
|
3971
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
3972
|
-
|
|
3973
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
3974
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
3975
|
-
docker compose up to start the container.
|
|
3976
|
-
|
|
3977
|
-
Module hooks (loaded automatically by each mode):
|
|
3978
|
-
|
|
3979
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
3980
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
3981
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
3982
|
-
modules/live.module --live Broker adapter for live trading
|
|
3983
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
3984
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
3985
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
3986
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
3987
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
3988
|
-
|
|
3989
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
3990
|
-
|
|
3991
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
3992
|
-
|
|
3993
|
-
Environment variables:
|
|
3994
|
-
|
|
3995
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
3996
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
3997
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
3998
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
3999
|
-
|
|
4000
|
-
Examples:
|
|
4001
|
-
|
|
4002
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4003
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4004
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4005
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4006
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4007
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4008
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4009
|
-
node ${ENTRY_PATH} --editor
|
|
4010
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4011
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4012
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4013
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4014
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4015
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4016
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4017
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4018
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
3878
|
+
const HELP_TEXT = `
|
|
3879
|
+
Usage:
|
|
3880
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
3881
|
+
|
|
3882
|
+
Modes:
|
|
3883
|
+
|
|
3884
|
+
--backtest <entry> Run strategy against historical candle data
|
|
3885
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3886
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
3887
|
+
--live <entry> Live trading with real orders
|
|
3888
|
+
--pine <entry> Execute a local .pine indicator file
|
|
3889
|
+
--editor Open the Pine Script visual editor in the browser
|
|
3890
|
+
--dump Fetch and save raw OHLCV candles
|
|
3891
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3892
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3893
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3894
|
+
--init Scaffold a new project in the current directory
|
|
3895
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3896
|
+
--help Print this help message
|
|
3897
|
+
|
|
3898
|
+
Backtest flags:
|
|
3899
|
+
|
|
3900
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3901
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3902
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3903
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3904
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3905
|
+
--noCache Skip candle cache warming before the run
|
|
3906
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3907
|
+
--verbose Log every candle fetch to stdout
|
|
3908
|
+
--ui Start web dashboard at http://localhost:60050
|
|
3909
|
+
--telegram Send trade notifications to Telegram
|
|
3910
|
+
|
|
3911
|
+
Walker flags (--walker):
|
|
3912
|
+
|
|
3913
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3914
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3915
|
+
--noCache Skip candle cache warming before the run
|
|
3916
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3917
|
+
--verbose Log every candle fetch to stdout
|
|
3918
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3919
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
3920
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3921
|
+
|
|
3922
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3923
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
3924
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3925
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3926
|
+
|
|
3927
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3928
|
+
|
|
3929
|
+
Paper / Live flags:
|
|
3930
|
+
|
|
3931
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3932
|
+
--strategy <string> Strategy name (default: first registered)
|
|
3933
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3934
|
+
--verbose Log every candle fetch to stdout
|
|
3935
|
+
--ui Start web dashboard
|
|
3936
|
+
--telegram Send Telegram notifications
|
|
3937
|
+
|
|
3938
|
+
PineScript flags (--pine):
|
|
3939
|
+
|
|
3940
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3941
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3942
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
3943
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3944
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3945
|
+
--output <string> Output file base name without extension
|
|
3946
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3947
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3948
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3949
|
+
|
|
3950
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
3951
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3952
|
+
|
|
3953
|
+
Candle dump flags (--dump):
|
|
3954
|
+
|
|
3955
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3956
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3957
|
+
--limit <string> Number of candles (default: 250)
|
|
3958
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3959
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3960
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3961
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3962
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3963
|
+
|
|
3964
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3965
|
+
|
|
3966
|
+
PnL debug flags (--pnldebug):
|
|
3967
|
+
|
|
3968
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3969
|
+
--priceopen <number> Entry price (required)
|
|
3970
|
+
--direction <string> Position direction: long or short (default: long)
|
|
3971
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3972
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3973
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3974
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3975
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3976
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3977
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3978
|
+
|
|
3979
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3980
|
+
|
|
3981
|
+
Broker debug flags (--brokerdebug):
|
|
3982
|
+
|
|
3983
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3984
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3985
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3986
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3987
|
+
(default: signal-open)
|
|
3988
|
+
|
|
3989
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3990
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
3991
|
+
|
|
3992
|
+
Flush flags (--flush):
|
|
3993
|
+
|
|
3994
|
+
One or more positional entry points. For each entry point the following
|
|
3995
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
3996
|
+
|
|
3997
|
+
report log markdown agent
|
|
3998
|
+
|
|
3999
|
+
Init flags (--init):
|
|
4000
|
+
|
|
4001
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4002
|
+
|
|
4003
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4004
|
+
|
|
4005
|
+
Docker flags (--docker):
|
|
4006
|
+
|
|
4007
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4008
|
+
|
|
4009
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4010
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4011
|
+
docker compose up to start the container.
|
|
4012
|
+
|
|
4013
|
+
Module hooks (loaded automatically by each mode):
|
|
4014
|
+
|
|
4015
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4016
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4017
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4018
|
+
modules/live.module --live Broker adapter for live trading
|
|
4019
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4020
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4021
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4022
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4023
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4024
|
+
|
|
4025
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4026
|
+
|
|
4027
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4028
|
+
|
|
4029
|
+
Environment variables:
|
|
4030
|
+
|
|
4031
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4032
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4033
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4034
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4035
|
+
|
|
4036
|
+
Examples:
|
|
4037
|
+
|
|
4038
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4039
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4040
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4041
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4042
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4043
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4044
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4045
|
+
node ${ENTRY_PATH} --editor
|
|
4046
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4047
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4048
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4049
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4050
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4051
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4052
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4053
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4054
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4019
4055
|
`.trimStart();
|
|
4020
4056
|
const main$1 = async () => {
|
|
4021
4057
|
if (!getEntry(import.meta.url)) {
|
|
@@ -4025,7 +4061,7 @@ const main$1 = async () => {
|
|
|
4025
4061
|
if (!values.help) {
|
|
4026
4062
|
return;
|
|
4027
4063
|
}
|
|
4028
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4064
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n\n`);
|
|
4029
4065
|
process.stdout.write(HELP_TEXT);
|
|
4030
4066
|
process.exit(0);
|
|
4031
4067
|
};
|
|
@@ -4039,7 +4075,7 @@ const main = async () => {
|
|
|
4039
4075
|
if (!values.version) {
|
|
4040
4076
|
return;
|
|
4041
4077
|
}
|
|
4042
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4078
|
+
process.stdout.write(`@backtest-kit/cli ${"9.2.0"}\n`);
|
|
4043
4079
|
process.exit(0);
|
|
4044
4080
|
};
|
|
4045
4081
|
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
|
+
};
|