@backtest-kit/cli 8.5.0 → 9.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 +1692 -1692
- package/build/index.cjs +187 -184
- package/build/index.mjs +187 -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 +45 -45
- 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
|
@@ -656,6 +656,9 @@ const notifyFinish = singleshot(() => {
|
|
|
656
656
|
});
|
|
657
657
|
|
|
658
658
|
const getEntry = (metaUrl) => {
|
|
659
|
+
if (!process.argv[1]) {
|
|
660
|
+
return "";
|
|
661
|
+
}
|
|
659
662
|
const metaPath = fileURLToPath(metaUrl);
|
|
660
663
|
const realArgv = realpathSync(process.argv[1]);
|
|
661
664
|
return path.resolve(realArgv) === path.resolve(metaPath);
|
|
@@ -2989,10 +2992,10 @@ init();
|
|
|
2989
2992
|
|
|
2990
2993
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
2991
2994
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
2992
|
-
const HELP_TEXT$1 = `
|
|
2993
|
-
Example:
|
|
2994
|
-
|
|
2995
|
-
node ${ENTRY_PATH$1} --help
|
|
2995
|
+
const HELP_TEXT$1 = `
|
|
2996
|
+
Example:
|
|
2997
|
+
|
|
2998
|
+
node ${ENTRY_PATH$1} --help
|
|
2996
2999
|
`.trimStart();
|
|
2997
3000
|
const main$g = async () => {
|
|
2998
3001
|
if (!getEntry(import.meta.url)) {
|
|
@@ -3002,7 +3005,7 @@ const main$g = async () => {
|
|
|
3002
3005
|
if (MODES.some((mode) => values[mode])) {
|
|
3003
3006
|
return;
|
|
3004
3007
|
}
|
|
3005
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
3008
|
+
process.stdout.write(`@backtest-kit/cli ${"9.0.0"}\n`);
|
|
3006
3009
|
process.stdout.write("\n");
|
|
3007
3010
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3008
3011
|
process.stdout.write("\n");
|
|
@@ -3819,183 +3822,183 @@ const main$2 = async () => {
|
|
|
3819
3822
|
main$2();
|
|
3820
3823
|
|
|
3821
3824
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3822
|
-
const HELP_TEXT = `
|
|
3823
|
-
Usage:
|
|
3824
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
3825
|
-
|
|
3826
|
-
Modes:
|
|
3827
|
-
|
|
3828
|
-
--backtest <entry> Run strategy against historical candle data
|
|
3829
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3830
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
3831
|
-
--live <entry> Live trading with real orders
|
|
3832
|
-
--pine <entry> Execute a local .pine indicator file
|
|
3833
|
-
--editor Open the Pine Script visual editor in the browser
|
|
3834
|
-
--dump Fetch and save raw OHLCV candles
|
|
3835
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3836
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3837
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3838
|
-
--init Scaffold a new project in the current directory
|
|
3839
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3840
|
-
--help Print this help message
|
|
3841
|
-
|
|
3842
|
-
Backtest flags:
|
|
3843
|
-
|
|
3844
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3845
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3846
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3847
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3848
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3849
|
-
--noCache Skip candle cache warming before the run
|
|
3850
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3851
|
-
--verbose Log every candle fetch to stdout
|
|
3852
|
-
--ui Start web dashboard at http://localhost:60050
|
|
3853
|
-
--telegram Send trade notifications to Telegram
|
|
3854
|
-
|
|
3855
|
-
Walker flags (--walker):
|
|
3856
|
-
|
|
3857
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3858
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3859
|
-
--noCache Skip candle cache warming before the run
|
|
3860
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3861
|
-
--verbose Log every candle fetch to stdout
|
|
3862
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3863
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
3864
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3865
|
-
|
|
3866
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3867
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
3868
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3869
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3870
|
-
|
|
3871
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3872
|
-
|
|
3873
|
-
Paper / Live flags:
|
|
3874
|
-
|
|
3875
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3876
|
-
--strategy <string> Strategy name (default: first registered)
|
|
3877
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3878
|
-
--verbose Log every candle fetch to stdout
|
|
3879
|
-
--ui Start web dashboard
|
|
3880
|
-
--telegram Send Telegram notifications
|
|
3881
|
-
|
|
3882
|
-
PineScript flags (--pine):
|
|
3883
|
-
|
|
3884
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3885
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3886
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
3887
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3888
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3889
|
-
--output <string> Output file base name without extension
|
|
3890
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3891
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3892
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3893
|
-
|
|
3894
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
3895
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3896
|
-
|
|
3897
|
-
Candle dump flags (--dump):
|
|
3898
|
-
|
|
3899
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3900
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3901
|
-
--limit <string> Number of candles (default: 250)
|
|
3902
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3903
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3904
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3905
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3906
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3907
|
-
|
|
3908
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3909
|
-
|
|
3910
|
-
PnL debug flags (--pnldebug):
|
|
3911
|
-
|
|
3912
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3913
|
-
--priceopen <number> Entry price (required)
|
|
3914
|
-
--direction <string> Position direction: long or short (default: long)
|
|
3915
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3916
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3917
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3918
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3919
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3920
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3921
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3922
|
-
|
|
3923
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3924
|
-
|
|
3925
|
-
Broker debug flags (--brokerdebug):
|
|
3926
|
-
|
|
3927
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3928
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3929
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3930
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3931
|
-
(default: signal-open)
|
|
3932
|
-
|
|
3933
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3934
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
3935
|
-
|
|
3936
|
-
Flush flags (--flush):
|
|
3937
|
-
|
|
3938
|
-
One or more positional entry points. For each entry point the following
|
|
3939
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
3940
|
-
|
|
3941
|
-
report log markdown agent
|
|
3942
|
-
|
|
3943
|
-
Init flags (--init):
|
|
3944
|
-
|
|
3945
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
3946
|
-
|
|
3947
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3948
|
-
|
|
3949
|
-
Docker flags (--docker):
|
|
3950
|
-
|
|
3951
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
3952
|
-
|
|
3953
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
3954
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
3955
|
-
docker compose up to start the container.
|
|
3956
|
-
|
|
3957
|
-
Module hooks (loaded automatically by each mode):
|
|
3958
|
-
|
|
3959
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
3960
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
3961
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
3962
|
-
modules/live.module --live Broker adapter for live trading
|
|
3963
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
3964
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
3965
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
3966
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
3967
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
3968
|
-
|
|
3969
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
3970
|
-
|
|
3971
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
3972
|
-
|
|
3973
|
-
Environment variables:
|
|
3974
|
-
|
|
3975
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
3976
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
3977
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
3978
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
3979
|
-
|
|
3980
|
-
Examples:
|
|
3981
|
-
|
|
3982
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
3983
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
3984
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
3985
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
3986
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
3987
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
3988
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
3989
|
-
node ${ENTRY_PATH} --editor
|
|
3990
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
3991
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
3992
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
3993
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
3994
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
3995
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
3996
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
3997
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
3998
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
3825
|
+
const HELP_TEXT = `
|
|
3826
|
+
Usage:
|
|
3827
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
3828
|
+
|
|
3829
|
+
Modes:
|
|
3830
|
+
|
|
3831
|
+
--backtest <entry> Run strategy against historical candle data
|
|
3832
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3833
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
3834
|
+
--live <entry> Live trading with real orders
|
|
3835
|
+
--pine <entry> Execute a local .pine indicator file
|
|
3836
|
+
--editor Open the Pine Script visual editor in the browser
|
|
3837
|
+
--dump Fetch and save raw OHLCV candles
|
|
3838
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3839
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3840
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3841
|
+
--init Scaffold a new project in the current directory
|
|
3842
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3843
|
+
--help Print this help message
|
|
3844
|
+
|
|
3845
|
+
Backtest flags:
|
|
3846
|
+
|
|
3847
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3848
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3849
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3850
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3851
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3852
|
+
--noCache Skip candle cache warming before the run
|
|
3853
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3854
|
+
--verbose Log every candle fetch to stdout
|
|
3855
|
+
--ui Start web dashboard at http://localhost:60050
|
|
3856
|
+
--telegram Send trade notifications to Telegram
|
|
3857
|
+
|
|
3858
|
+
Walker flags (--walker):
|
|
3859
|
+
|
|
3860
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3861
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3862
|
+
--noCache Skip candle cache warming before the run
|
|
3863
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3864
|
+
--verbose Log every candle fetch to stdout
|
|
3865
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3866
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
3867
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3868
|
+
|
|
3869
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3870
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
3871
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3872
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3873
|
+
|
|
3874
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3875
|
+
|
|
3876
|
+
Paper / Live flags:
|
|
3877
|
+
|
|
3878
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3879
|
+
--strategy <string> Strategy name (default: first registered)
|
|
3880
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3881
|
+
--verbose Log every candle fetch to stdout
|
|
3882
|
+
--ui Start web dashboard
|
|
3883
|
+
--telegram Send Telegram notifications
|
|
3884
|
+
|
|
3885
|
+
PineScript flags (--pine):
|
|
3886
|
+
|
|
3887
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3888
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3889
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
3890
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3891
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3892
|
+
--output <string> Output file base name without extension
|
|
3893
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3894
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3895
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3896
|
+
|
|
3897
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
3898
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3899
|
+
|
|
3900
|
+
Candle dump flags (--dump):
|
|
3901
|
+
|
|
3902
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3903
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3904
|
+
--limit <string> Number of candles (default: 250)
|
|
3905
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3906
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3907
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3908
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3909
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3910
|
+
|
|
3911
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3912
|
+
|
|
3913
|
+
PnL debug flags (--pnldebug):
|
|
3914
|
+
|
|
3915
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3916
|
+
--priceopen <number> Entry price (required)
|
|
3917
|
+
--direction <string> Position direction: long or short (default: long)
|
|
3918
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3919
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3920
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3921
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3922
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3923
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3924
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3925
|
+
|
|
3926
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3927
|
+
|
|
3928
|
+
Broker debug flags (--brokerdebug):
|
|
3929
|
+
|
|
3930
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3931
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3932
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3933
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3934
|
+
(default: signal-open)
|
|
3935
|
+
|
|
3936
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3937
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
3938
|
+
|
|
3939
|
+
Flush flags (--flush):
|
|
3940
|
+
|
|
3941
|
+
One or more positional entry points. For each entry point the following
|
|
3942
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
3943
|
+
|
|
3944
|
+
report log markdown agent
|
|
3945
|
+
|
|
3946
|
+
Init flags (--init):
|
|
3947
|
+
|
|
3948
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
3949
|
+
|
|
3950
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3951
|
+
|
|
3952
|
+
Docker flags (--docker):
|
|
3953
|
+
|
|
3954
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
3955
|
+
|
|
3956
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
3957
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
3958
|
+
docker compose up to start the container.
|
|
3959
|
+
|
|
3960
|
+
Module hooks (loaded automatically by each mode):
|
|
3961
|
+
|
|
3962
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
3963
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
3964
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
3965
|
+
modules/live.module --live Broker adapter for live trading
|
|
3966
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
3967
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
3968
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
3969
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
3970
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
3971
|
+
|
|
3972
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
3973
|
+
|
|
3974
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
3975
|
+
|
|
3976
|
+
Environment variables:
|
|
3977
|
+
|
|
3978
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
3979
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
3980
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
3981
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
3982
|
+
|
|
3983
|
+
Examples:
|
|
3984
|
+
|
|
3985
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
3986
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
3987
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
3988
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
3989
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
3990
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
3991
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
3992
|
+
node ${ENTRY_PATH} --editor
|
|
3993
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
3994
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
3995
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
3996
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
3997
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
3998
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
3999
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4000
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4001
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
3999
4002
|
`.trimStart();
|
|
4000
4003
|
const main$1 = async () => {
|
|
4001
4004
|
if (!getEntry(import.meta.url)) {
|
|
@@ -4005,7 +4008,7 @@ const main$1 = async () => {
|
|
|
4005
4008
|
if (!values.help) {
|
|
4006
4009
|
return;
|
|
4007
4010
|
}
|
|
4008
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4011
|
+
process.stdout.write(`@backtest-kit/cli ${"9.0.0"}\n\n`);
|
|
4009
4012
|
process.stdout.write(HELP_TEXT);
|
|
4010
4013
|
process.exit(0);
|
|
4011
4014
|
};
|
|
@@ -4019,7 +4022,7 @@ const main = async () => {
|
|
|
4019
4022
|
if (!values.version) {
|
|
4020
4023
|
return;
|
|
4021
4024
|
}
|
|
4022
|
-
process.stdout.write(`@backtest-kit/cli ${"
|
|
4025
|
+
process.stdout.write(`@backtest-kit/cli ${"9.0.0"}\n`);
|
|
4023
4026
|
process.exit(0);
|
|
4024
4027
|
};
|
|
4025
4028
|
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
|
+
};
|