@backtest-kit/cli 9.0.0 → 9.1.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 -1692
- package/build/index.cjs +202 -185
- package/build/index.mjs +202 -185
- 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/types.d.ts +1 -0
package/build/index.mjs
CHANGED
|
@@ -310,6 +310,23 @@ class ResolveService {
|
|
|
310
310
|
}
|
|
311
311
|
_is_launched = true;
|
|
312
312
|
};
|
|
313
|
+
this.attachEntry = async (jsPath) => {
|
|
314
|
+
this.loggerService.log("resolveService attachEntry", {
|
|
315
|
+
jsPath
|
|
316
|
+
});
|
|
317
|
+
if (_is_launched) {
|
|
318
|
+
throw new Error("Entry point is already attached. Multiple entry points are not allowed.");
|
|
319
|
+
}
|
|
320
|
+
const absolutePath = path.resolve(jsPath);
|
|
321
|
+
const cwd = process.cwd();
|
|
322
|
+
await access(absolutePath, constants.F_OK | constants.R_OK);
|
|
323
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
324
|
+
{
|
|
325
|
+
this.loaderService.import(absolutePath);
|
|
326
|
+
await entrySubject.next(absolutePath);
|
|
327
|
+
}
|
|
328
|
+
_is_launched = true;
|
|
329
|
+
};
|
|
313
330
|
}
|
|
314
331
|
}
|
|
315
332
|
|
|
@@ -2992,10 +3009,10 @@ init();
|
|
|
2992
3009
|
|
|
2993
3010
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
2994
3011
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
2995
|
-
const HELP_TEXT$1 = `
|
|
2996
|
-
Example:
|
|
2997
|
-
|
|
2998
|
-
node ${ENTRY_PATH$1} --help
|
|
3012
|
+
const HELP_TEXT$1 = `
|
|
3013
|
+
Example:
|
|
3014
|
+
|
|
3015
|
+
node ${ENTRY_PATH$1} --help
|
|
2999
3016
|
`.trimStart();
|
|
3000
3017
|
const main$g = async () => {
|
|
3001
3018
|
if (!getEntry(import.meta.url)) {
|
|
@@ -3005,7 +3022,7 @@ const main$g = async () => {
|
|
|
3005
3022
|
if (MODES.some((mode) => values[mode])) {
|
|
3006
3023
|
return;
|
|
3007
3024
|
}
|
|
3008
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3025
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
|
|
3009
3026
|
process.stdout.write("\n");
|
|
3010
3027
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3011
3028
|
process.stdout.write("\n");
|
|
@@ -3300,7 +3317,7 @@ const main$a = async () => {
|
|
|
3300
3317
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3301
3318
|
listenFinish();
|
|
3302
3319
|
createGracefulShutdown(mode)();
|
|
3303
|
-
await cli.resolveService.
|
|
3320
|
+
await cli.resolveService.attachEntry(entryPoint);
|
|
3304
3321
|
};
|
|
3305
3322
|
main$a();
|
|
3306
3323
|
|
|
@@ -3822,183 +3839,183 @@ const main$2 = async () => {
|
|
|
3822
3839
|
main$2();
|
|
3823
3840
|
|
|
3824
3841
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
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
|
|
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
|
|
4002
4019
|
`.trimStart();
|
|
4003
4020
|
const main$1 = async () => {
|
|
4004
4021
|
if (!getEntry(import.meta.url)) {
|
|
@@ -4008,7 +4025,7 @@ const main$1 = async () => {
|
|
|
4008
4025
|
if (!values.help) {
|
|
4009
4026
|
return;
|
|
4010
4027
|
}
|
|
4011
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4028
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n\n`);
|
|
4012
4029
|
process.stdout.write(HELP_TEXT);
|
|
4013
4030
|
process.exit(0);
|
|
4014
4031
|
};
|
|
@@ -4022,7 +4039,7 @@ const main = async () => {
|
|
|
4022
4039
|
if (!values.version) {
|
|
4023
4040
|
return;
|
|
4024
4041
|
}
|
|
4025
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4042
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
|
|
4026
4043
|
process.exit(0);
|
|
4027
4044
|
};
|
|
4028
4045
|
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
|
+
};
|