@backtest-kit/cli 9.7.0 → 9.8.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 +1854 -1854
- package/build/index.cjs +204 -186
- package/build/index.mjs +204 -186
- 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
|
@@ -2622,14 +2622,29 @@ class BabelService {
|
|
|
2622
2622
|
}
|
|
2623
2623
|
}
|
|
2624
2624
|
|
|
2625
|
-
const require = createRequire(import.meta.url);
|
|
2626
2625
|
const ModuleWithCache = Module;
|
|
2626
|
+
const LOOKUP_PATHS = ModuleWithCache._nodeModulePaths(process.cwd());
|
|
2627
|
+
const VIRTUAL_MAP = new Map();
|
|
2628
|
+
{
|
|
2629
|
+
const originalResolveFilename = ModuleWithCache._resolveFilename;
|
|
2630
|
+
ModuleWithCache._resolveFilename = function (request, parent, isMain, options) {
|
|
2631
|
+
const virtualKey = VIRTUAL_MAP.get(request);
|
|
2632
|
+
if (virtualKey) {
|
|
2633
|
+
return virtualKey;
|
|
2634
|
+
}
|
|
2635
|
+
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2627
2638
|
function overrideModule(moduleName, newExports) {
|
|
2628
2639
|
const cache = ModuleWithCache._cache;
|
|
2629
|
-
const
|
|
2640
|
+
const resolved = ModuleWithCache._findPath(moduleName, LOOKUP_PATHS, false);
|
|
2641
|
+
const key = resolved || moduleName;
|
|
2642
|
+
VIRTUAL_MAP.set(moduleName, key);
|
|
2630
2643
|
if (!cache[key]) {
|
|
2631
2644
|
cache[key] = new ModuleWithCache(key);
|
|
2632
2645
|
cache[key].loaded = true;
|
|
2646
|
+
cache[key].filename = key;
|
|
2647
|
+
cache[key].paths = [];
|
|
2633
2648
|
}
|
|
2634
2649
|
cache[key].exports = newExports;
|
|
2635
2650
|
}
|
|
@@ -3163,10 +3178,10 @@ init();
|
|
|
3163
3178
|
|
|
3164
3179
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3165
3180
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3166
|
-
const HELP_TEXT$1 = `
|
|
3167
|
-
Example:
|
|
3168
|
-
|
|
3169
|
-
node ${ENTRY_PATH$1} --help
|
|
3181
|
+
const HELP_TEXT$1 = `
|
|
3182
|
+
Example:
|
|
3183
|
+
|
|
3184
|
+
node ${ENTRY_PATH$1} --help
|
|
3170
3185
|
`.trimStart();
|
|
3171
3186
|
const main$g = async () => {
|
|
3172
3187
|
if (!getEntry(import.meta.url)) {
|
|
@@ -3176,7 +3191,7 @@ const main$g = async () => {
|
|
|
3176
3191
|
if (MODES.some((mode) => values[mode])) {
|
|
3177
3192
|
return;
|
|
3178
3193
|
}
|
|
3179
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3194
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.0"}\n`);
|
|
3180
3195
|
process.stdout.write("\n");
|
|
3181
3196
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3182
3197
|
process.stdout.write("\n");
|
|
@@ -3487,6 +3502,9 @@ const main$a = async () => {
|
|
|
3487
3502
|
const cwd = process.cwd();
|
|
3488
3503
|
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3489
3504
|
}
|
|
3505
|
+
if (entryPoints.length === 1) {
|
|
3506
|
+
process.chdir(path.dirname(path.resolve(entryPoints[0])));
|
|
3507
|
+
}
|
|
3490
3508
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3491
3509
|
listenFinish();
|
|
3492
3510
|
createGracefulShutdown(mode)();
|
|
@@ -4070,183 +4088,183 @@ const main$2 = async () => {
|
|
|
4070
4088
|
main$2();
|
|
4071
4089
|
|
|
4072
4090
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
4073
|
-
const HELP_TEXT = `
|
|
4074
|
-
Usage:
|
|
4075
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
4076
|
-
|
|
4077
|
-
Modes:
|
|
4078
|
-
|
|
4079
|
-
--backtest <entry> Run strategy against historical candle data
|
|
4080
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4081
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
4082
|
-
--live <entry> Live trading with real orders
|
|
4083
|
-
--pine <entry> Execute a local .pine indicator file
|
|
4084
|
-
--editor Open the Pine Script visual editor in the browser
|
|
4085
|
-
--dump Fetch and save raw OHLCV candles
|
|
4086
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4087
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4088
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4089
|
-
--init Scaffold a new project in the current directory
|
|
4090
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4091
|
-
--help Print this help message
|
|
4092
|
-
|
|
4093
|
-
Backtest flags:
|
|
4094
|
-
|
|
4095
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4096
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4097
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4098
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4099
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4100
|
-
--noCache Skip candle cache warming before the run
|
|
4101
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4102
|
-
--verbose Log every candle fetch to stdout
|
|
4103
|
-
--ui Start web dashboard at http://localhost:60050
|
|
4104
|
-
--telegram Send trade notifications to Telegram
|
|
4105
|
-
|
|
4106
|
-
Walker flags (--walker):
|
|
4107
|
-
|
|
4108
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4109
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4110
|
-
--noCache Skip candle cache warming before the run
|
|
4111
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4112
|
-
--verbose Log every candle fetch to stdout
|
|
4113
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4114
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
4115
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4116
|
-
|
|
4117
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4118
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
4119
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4120
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4121
|
-
|
|
4122
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4123
|
-
|
|
4124
|
-
Paper / Live flags:
|
|
4125
|
-
|
|
4126
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4127
|
-
--strategy <string> Strategy name (default: first registered)
|
|
4128
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4129
|
-
--verbose Log every candle fetch to stdout
|
|
4130
|
-
--ui Start web dashboard
|
|
4131
|
-
--telegram Send Telegram notifications
|
|
4132
|
-
|
|
4133
|
-
PineScript flags (--pine):
|
|
4134
|
-
|
|
4135
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4136
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4137
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
4138
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4139
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4140
|
-
--output <string> Output file base name without extension
|
|
4141
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4142
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4143
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4144
|
-
|
|
4145
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
4146
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4147
|
-
|
|
4148
|
-
Candle dump flags (--dump):
|
|
4149
|
-
|
|
4150
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4151
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4152
|
-
--limit <string> Number of candles (default: 250)
|
|
4153
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4154
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4155
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4156
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4157
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4158
|
-
|
|
4159
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4160
|
-
|
|
4161
|
-
PnL debug flags (--pnldebug):
|
|
4162
|
-
|
|
4163
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4164
|
-
--priceopen <number> Entry price (required)
|
|
4165
|
-
--direction <string> Position direction: long or short (default: long)
|
|
4166
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4167
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4168
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4169
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4170
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4171
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4172
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4173
|
-
|
|
4174
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4175
|
-
|
|
4176
|
-
Broker debug flags (--brokerdebug):
|
|
4177
|
-
|
|
4178
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4179
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4180
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4181
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4182
|
-
(default: signal-open)
|
|
4183
|
-
|
|
4184
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4185
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
4186
|
-
|
|
4187
|
-
Flush flags (--flush):
|
|
4188
|
-
|
|
4189
|
-
One or more positional entry points. For each entry point the following
|
|
4190
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
4191
|
-
|
|
4192
|
-
report log markdown agent
|
|
4193
|
-
|
|
4194
|
-
Init flags (--init):
|
|
4195
|
-
|
|
4196
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
4197
|
-
|
|
4198
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4199
|
-
|
|
4200
|
-
Docker flags (--docker):
|
|
4201
|
-
|
|
4202
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4203
|
-
|
|
4204
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4205
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4206
|
-
docker compose up to start the container.
|
|
4207
|
-
|
|
4208
|
-
Module hooks (loaded automatically by each mode):
|
|
4209
|
-
|
|
4210
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4211
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4212
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4213
|
-
modules/live.module --live Broker adapter for live trading
|
|
4214
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4215
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4216
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4217
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4218
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4219
|
-
|
|
4220
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4221
|
-
|
|
4222
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4223
|
-
|
|
4224
|
-
Environment variables:
|
|
4225
|
-
|
|
4226
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4227
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4228
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4229
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4230
|
-
|
|
4231
|
-
Examples:
|
|
4232
|
-
|
|
4233
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4234
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4235
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4236
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4237
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4238
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4239
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4240
|
-
node ${ENTRY_PATH} --editor
|
|
4241
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4242
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4243
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4244
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4245
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4246
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4247
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4248
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4249
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4091
|
+
const HELP_TEXT = `
|
|
4092
|
+
Usage:
|
|
4093
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
4094
|
+
|
|
4095
|
+
Modes:
|
|
4096
|
+
|
|
4097
|
+
--backtest <entry> Run strategy against historical candle data
|
|
4098
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4099
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
4100
|
+
--live <entry> Live trading with real orders
|
|
4101
|
+
--pine <entry> Execute a local .pine indicator file
|
|
4102
|
+
--editor Open the Pine Script visual editor in the browser
|
|
4103
|
+
--dump Fetch and save raw OHLCV candles
|
|
4104
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4105
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4106
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4107
|
+
--init Scaffold a new project in the current directory
|
|
4108
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4109
|
+
--help Print this help message
|
|
4110
|
+
|
|
4111
|
+
Backtest flags:
|
|
4112
|
+
|
|
4113
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4114
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4115
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4116
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4117
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4118
|
+
--noCache Skip candle cache warming before the run
|
|
4119
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4120
|
+
--verbose Log every candle fetch to stdout
|
|
4121
|
+
--ui Start web dashboard at http://localhost:60050
|
|
4122
|
+
--telegram Send trade notifications to Telegram
|
|
4123
|
+
|
|
4124
|
+
Walker flags (--walker):
|
|
4125
|
+
|
|
4126
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4127
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4128
|
+
--noCache Skip candle cache warming before the run
|
|
4129
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4130
|
+
--verbose Log every candle fetch to stdout
|
|
4131
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4132
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
4133
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4134
|
+
|
|
4135
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4136
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
4137
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4138
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4139
|
+
|
|
4140
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4141
|
+
|
|
4142
|
+
Paper / Live flags:
|
|
4143
|
+
|
|
4144
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4145
|
+
--strategy <string> Strategy name (default: first registered)
|
|
4146
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4147
|
+
--verbose Log every candle fetch to stdout
|
|
4148
|
+
--ui Start web dashboard
|
|
4149
|
+
--telegram Send Telegram notifications
|
|
4150
|
+
|
|
4151
|
+
PineScript flags (--pine):
|
|
4152
|
+
|
|
4153
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4154
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4155
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
4156
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4157
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4158
|
+
--output <string> Output file base name without extension
|
|
4159
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4160
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4161
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4162
|
+
|
|
4163
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
4164
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4165
|
+
|
|
4166
|
+
Candle dump flags (--dump):
|
|
4167
|
+
|
|
4168
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4169
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4170
|
+
--limit <string> Number of candles (default: 250)
|
|
4171
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4172
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4173
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4174
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4175
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4176
|
+
|
|
4177
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4178
|
+
|
|
4179
|
+
PnL debug flags (--pnldebug):
|
|
4180
|
+
|
|
4181
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4182
|
+
--priceopen <number> Entry price (required)
|
|
4183
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4184
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4185
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4186
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4187
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4188
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4189
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4190
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4191
|
+
|
|
4192
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4193
|
+
|
|
4194
|
+
Broker debug flags (--brokerdebug):
|
|
4195
|
+
|
|
4196
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4197
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4198
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4199
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4200
|
+
(default: signal-open)
|
|
4201
|
+
|
|
4202
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4203
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4204
|
+
|
|
4205
|
+
Flush flags (--flush):
|
|
4206
|
+
|
|
4207
|
+
One or more positional entry points. For each entry point the following
|
|
4208
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4209
|
+
|
|
4210
|
+
report log markdown agent
|
|
4211
|
+
|
|
4212
|
+
Init flags (--init):
|
|
4213
|
+
|
|
4214
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4215
|
+
|
|
4216
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4217
|
+
|
|
4218
|
+
Docker flags (--docker):
|
|
4219
|
+
|
|
4220
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4221
|
+
|
|
4222
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4223
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4224
|
+
docker compose up to start the container.
|
|
4225
|
+
|
|
4226
|
+
Module hooks (loaded automatically by each mode):
|
|
4227
|
+
|
|
4228
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4229
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4230
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4231
|
+
modules/live.module --live Broker adapter for live trading
|
|
4232
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4233
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4234
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4235
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4236
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4237
|
+
|
|
4238
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4239
|
+
|
|
4240
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4241
|
+
|
|
4242
|
+
Environment variables:
|
|
4243
|
+
|
|
4244
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4245
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4246
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4247
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4248
|
+
|
|
4249
|
+
Examples:
|
|
4250
|
+
|
|
4251
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4252
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4253
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4254
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4255
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4256
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4257
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4258
|
+
node ${ENTRY_PATH} --editor
|
|
4259
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4260
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4261
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4262
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4263
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4264
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4265
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4266
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4267
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4250
4268
|
`.trimStart();
|
|
4251
4269
|
const main$1 = async () => {
|
|
4252
4270
|
if (!getEntry(import.meta.url)) {
|
|
@@ -4256,7 +4274,7 @@ const main$1 = async () => {
|
|
|
4256
4274
|
if (!values.help) {
|
|
4257
4275
|
return;
|
|
4258
4276
|
}
|
|
4259
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4277
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.0"}\n\n`);
|
|
4260
4278
|
process.stdout.write(HELP_TEXT);
|
|
4261
4279
|
process.exit(0);
|
|
4262
4280
|
};
|
|
@@ -4270,7 +4288,7 @@ const main = async () => {
|
|
|
4270
4288
|
if (!values.version) {
|
|
4271
4289
|
return;
|
|
4272
4290
|
}
|
|
4273
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4291
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.0"}\n`);
|
|
4274
4292
|
process.exit(0);
|
|
4275
4293
|
};
|
|
4276
4294
|
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
|
+
};
|