@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.cjs
CHANGED
|
@@ -335,6 +335,23 @@ class ResolveService {
|
|
|
335
335
|
}
|
|
336
336
|
_is_launched = true;
|
|
337
337
|
};
|
|
338
|
+
this.attachEntry = async (jsPath) => {
|
|
339
|
+
this.loggerService.log("resolveService attachEntry", {
|
|
340
|
+
jsPath
|
|
341
|
+
});
|
|
342
|
+
if (_is_launched) {
|
|
343
|
+
throw new Error("Entry point is already attached. Multiple entry points are not allowed.");
|
|
344
|
+
}
|
|
345
|
+
const absolutePath = path.resolve(jsPath);
|
|
346
|
+
const cwd = process.cwd();
|
|
347
|
+
await fs$1.access(absolutePath, fs.constants.F_OK | fs.constants.R_OK);
|
|
348
|
+
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
349
|
+
{
|
|
350
|
+
this.loaderService.import(absolutePath);
|
|
351
|
+
await entrySubject.next(absolutePath);
|
|
352
|
+
}
|
|
353
|
+
_is_launched = true;
|
|
354
|
+
};
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
357
|
|
|
@@ -3021,10 +3038,10 @@ init();
|
|
|
3021
3038
|
|
|
3022
3039
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3023
3040
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3024
|
-
const HELP_TEXT$1 = `
|
|
3025
|
-
Example:
|
|
3026
|
-
|
|
3027
|
-
node ${ENTRY_PATH$1} --help
|
|
3041
|
+
const HELP_TEXT$1 = `
|
|
3042
|
+
Example:
|
|
3043
|
+
|
|
3044
|
+
node ${ENTRY_PATH$1} --help
|
|
3028
3045
|
`.trimStart();
|
|
3029
3046
|
const main$g = async () => {
|
|
3030
3047
|
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)))) {
|
|
@@ -3034,7 +3051,7 @@ const main$g = async () => {
|
|
|
3034
3051
|
if (MODES.some((mode) => values[mode])) {
|
|
3035
3052
|
return;
|
|
3036
3053
|
}
|
|
3037
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3054
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
|
|
3038
3055
|
process.stdout.write("\n");
|
|
3039
3056
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3040
3057
|
process.stdout.write("\n");
|
|
@@ -3329,7 +3346,7 @@ const main$a = async () => {
|
|
|
3329
3346
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3330
3347
|
listenFinish();
|
|
3331
3348
|
createGracefulShutdown(mode)();
|
|
3332
|
-
await cli.resolveService.
|
|
3349
|
+
await cli.resolveService.attachEntry(entryPoint);
|
|
3333
3350
|
};
|
|
3334
3351
|
main$a();
|
|
3335
3352
|
|
|
@@ -3851,183 +3868,183 @@ const main$2 = async () => {
|
|
|
3851
3868
|
main$2();
|
|
3852
3869
|
|
|
3853
3870
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3854
|
-
const HELP_TEXT = `
|
|
3855
|
-
Usage:
|
|
3856
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
3857
|
-
|
|
3858
|
-
Modes:
|
|
3859
|
-
|
|
3860
|
-
--backtest <entry> Run strategy against historical candle data
|
|
3861
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3862
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
3863
|
-
--live <entry> Live trading with real orders
|
|
3864
|
-
--pine <entry> Execute a local .pine indicator file
|
|
3865
|
-
--editor Open the Pine Script visual editor in the browser
|
|
3866
|
-
--dump Fetch and save raw OHLCV candles
|
|
3867
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3868
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3869
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3870
|
-
--init Scaffold a new project in the current directory
|
|
3871
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
3872
|
-
--help Print this help message
|
|
3873
|
-
|
|
3874
|
-
Backtest flags:
|
|
3875
|
-
|
|
3876
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3877
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3878
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3879
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3880
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3881
|
-
--noCache Skip candle cache warming before the run
|
|
3882
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3883
|
-
--verbose Log every candle fetch to stdout
|
|
3884
|
-
--ui Start web dashboard at http://localhost:60050
|
|
3885
|
-
--telegram Send trade notifications to Telegram
|
|
3886
|
-
|
|
3887
|
-
Walker flags (--walker):
|
|
3888
|
-
|
|
3889
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3890
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3891
|
-
--noCache Skip candle cache warming before the run
|
|
3892
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3893
|
-
--verbose Log every candle fetch to stdout
|
|
3894
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3895
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
3896
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3897
|
-
|
|
3898
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3899
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
3900
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3901
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3902
|
-
|
|
3903
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3904
|
-
|
|
3905
|
-
Paper / Live flags:
|
|
3906
|
-
|
|
3907
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3908
|
-
--strategy <string> Strategy name (default: first registered)
|
|
3909
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3910
|
-
--verbose Log every candle fetch to stdout
|
|
3911
|
-
--ui Start web dashboard
|
|
3912
|
-
--telegram Send Telegram notifications
|
|
3913
|
-
|
|
3914
|
-
PineScript flags (--pine):
|
|
3915
|
-
|
|
3916
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3917
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3918
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
3919
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3920
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3921
|
-
--output <string> Output file base name without extension
|
|
3922
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3923
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3924
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3925
|
-
|
|
3926
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
3927
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3928
|
-
|
|
3929
|
-
Candle dump flags (--dump):
|
|
3930
|
-
|
|
3931
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3932
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
3933
|
-
--limit <string> Number of candles (default: 250)
|
|
3934
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3935
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3936
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3937
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3938
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3939
|
-
|
|
3940
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3941
|
-
|
|
3942
|
-
PnL debug flags (--pnldebug):
|
|
3943
|
-
|
|
3944
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3945
|
-
--priceopen <number> Entry price (required)
|
|
3946
|
-
--direction <string> Position direction: long or short (default: long)
|
|
3947
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3948
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3949
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3950
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3951
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
3952
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3953
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3954
|
-
|
|
3955
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3956
|
-
|
|
3957
|
-
Broker debug flags (--brokerdebug):
|
|
3958
|
-
|
|
3959
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3960
|
-
--exchange <string> Exchange name (default: first registered)
|
|
3961
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3962
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3963
|
-
(default: signal-open)
|
|
3964
|
-
|
|
3965
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3966
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
3967
|
-
|
|
3968
|
-
Flush flags (--flush):
|
|
3969
|
-
|
|
3970
|
-
One or more positional entry points. For each entry point the following
|
|
3971
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
3972
|
-
|
|
3973
|
-
report log markdown agent
|
|
3974
|
-
|
|
3975
|
-
Init flags (--init):
|
|
3976
|
-
|
|
3977
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
3978
|
-
|
|
3979
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3980
|
-
|
|
3981
|
-
Docker flags (--docker):
|
|
3982
|
-
|
|
3983
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
3984
|
-
|
|
3985
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
3986
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
3987
|
-
docker compose up to start the container.
|
|
3988
|
-
|
|
3989
|
-
Module hooks (loaded automatically by each mode):
|
|
3990
|
-
|
|
3991
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
3992
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
3993
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
3994
|
-
modules/live.module --live Broker adapter for live trading
|
|
3995
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
3996
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
3997
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
3998
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
3999
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4000
|
-
|
|
4001
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4002
|
-
|
|
4003
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4004
|
-
|
|
4005
|
-
Environment variables:
|
|
4006
|
-
|
|
4007
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4008
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4009
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4010
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4011
|
-
|
|
4012
|
-
Examples:
|
|
4013
|
-
|
|
4014
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4015
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4016
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4017
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4018
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4019
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4020
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4021
|
-
node ${ENTRY_PATH} --editor
|
|
4022
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4023
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4024
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4025
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4026
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4027
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4028
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4029
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4030
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
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
|
|
4031
4048
|
`.trimStart();
|
|
4032
4049
|
const main$1 = async () => {
|
|
4033
4050
|
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)))) {
|
|
@@ -4037,7 +4054,7 @@ const main$1 = async () => {
|
|
|
4037
4054
|
if (!values.help) {
|
|
4038
4055
|
return;
|
|
4039
4056
|
}
|
|
4040
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4057
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n\n`);
|
|
4041
4058
|
process.stdout.write(HELP_TEXT);
|
|
4042
4059
|
process.exit(0);
|
|
4043
4060
|
};
|
|
@@ -4051,7 +4068,7 @@ const main = async () => {
|
|
|
4051
4068
|
if (!values.version) {
|
|
4052
4069
|
return;
|
|
4053
4070
|
}
|
|
4054
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4071
|
+
process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
|
|
4055
4072
|
process.exit(0);
|
|
4056
4073
|
};
|
|
4057
4074
|
main();
|