@backtest-kit/cli 9.7.0 → 9.8.1
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 +218 -193
- package/build/index.mjs +219 -194
- 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.cjs
CHANGED
|
@@ -383,6 +383,9 @@ class SetupUtils {
|
|
|
383
383
|
BacktestKit.RecentLive.clear();
|
|
384
384
|
BacktestKit.RecentBacktest.clear();
|
|
385
385
|
}
|
|
386
|
+
{
|
|
387
|
+
BacktestKit.Broker.clear();
|
|
388
|
+
}
|
|
386
389
|
};
|
|
387
390
|
this.update = () => {
|
|
388
391
|
cli.loggerService.debug("SetupUtils update");
|
|
@@ -2647,14 +2650,29 @@ class BabelService {
|
|
|
2647
2650
|
}
|
|
2648
2651
|
}
|
|
2649
2652
|
|
|
2650
|
-
const require$1 = Module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
2651
2653
|
const ModuleWithCache = Module;
|
|
2654
|
+
const LOOKUP_PATHS = ModuleWithCache._nodeModulePaths(process.cwd());
|
|
2655
|
+
const VIRTUAL_MAP = new Map();
|
|
2656
|
+
{
|
|
2657
|
+
const originalResolveFilename = ModuleWithCache._resolveFilename;
|
|
2658
|
+
ModuleWithCache._resolveFilename = function (request, parent, isMain, options) {
|
|
2659
|
+
const virtualKey = VIRTUAL_MAP.get(request);
|
|
2660
|
+
if (virtualKey) {
|
|
2661
|
+
return virtualKey;
|
|
2662
|
+
}
|
|
2663
|
+
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2652
2666
|
function overrideModule(moduleName, newExports) {
|
|
2653
2667
|
const cache = ModuleWithCache._cache;
|
|
2654
|
-
const
|
|
2668
|
+
const resolved = ModuleWithCache._findPath(moduleName, LOOKUP_PATHS, false);
|
|
2669
|
+
const key = resolved || moduleName;
|
|
2670
|
+
VIRTUAL_MAP.set(moduleName, key);
|
|
2655
2671
|
if (!cache[key]) {
|
|
2656
2672
|
cache[key] = new ModuleWithCache(key);
|
|
2657
2673
|
cache[key].loaded = true;
|
|
2674
|
+
cache[key].filename = key;
|
|
2675
|
+
cache[key].paths = [];
|
|
2658
2676
|
}
|
|
2659
2677
|
cache[key].exports = newExports;
|
|
2660
2678
|
}
|
|
@@ -3192,10 +3210,10 @@ init();
|
|
|
3192
3210
|
|
|
3193
3211
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
|
|
3194
3212
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3195
|
-
const HELP_TEXT$1 = `
|
|
3196
|
-
Example:
|
|
3197
|
-
|
|
3198
|
-
node ${ENTRY_PATH$1} --help
|
|
3213
|
+
const HELP_TEXT$1 = `
|
|
3214
|
+
Example:
|
|
3215
|
+
|
|
3216
|
+
node ${ENTRY_PATH$1} --help
|
|
3199
3217
|
`.trimStart();
|
|
3200
3218
|
const main$g = async () => {
|
|
3201
3219
|
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)))) {
|
|
@@ -3205,7 +3223,7 @@ const main$g = async () => {
|
|
|
3205
3223
|
if (MODES.some((mode) => values[mode])) {
|
|
3206
3224
|
return;
|
|
3207
3225
|
}
|
|
3208
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
3226
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n`);
|
|
3209
3227
|
process.stdout.write("\n");
|
|
3210
3228
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3211
3229
|
process.stdout.write("\n");
|
|
@@ -3490,12 +3508,6 @@ const main$a = async () => {
|
|
|
3490
3508
|
if (!entryPoints.length) {
|
|
3491
3509
|
throw new Error("At least one entry point is required");
|
|
3492
3510
|
}
|
|
3493
|
-
for (const entryPoint of entryPoints) {
|
|
3494
|
-
if (values.noFlush) {
|
|
3495
|
-
continue;
|
|
3496
|
-
}
|
|
3497
|
-
await flush(entryPoint);
|
|
3498
|
-
}
|
|
3499
3511
|
await cli.configConnectionService.loadConfig("setup.config");
|
|
3500
3512
|
{
|
|
3501
3513
|
const loader = await cli.configConnectionService.loadConfig("loader.config");
|
|
@@ -3512,10 +3524,23 @@ const main$a = async () => {
|
|
|
3512
3524
|
}
|
|
3513
3525
|
cli.frontendProviderService.connect();
|
|
3514
3526
|
cli.telegramProviderService.connect();
|
|
3527
|
+
const cwd = process.cwd();
|
|
3515
3528
|
{
|
|
3516
|
-
const cwd = process.cwd();
|
|
3517
3529
|
dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
|
|
3518
3530
|
}
|
|
3531
|
+
if (entryPoints.length === 1) {
|
|
3532
|
+
const absolutePath = path.resolve(entryPoints[0]);
|
|
3533
|
+
const moduleRoot = path.dirname(absolutePath);
|
|
3534
|
+
process.chdir(moduleRoot);
|
|
3535
|
+
cwd !== moduleRoot && Setup.update();
|
|
3536
|
+
dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
|
|
3537
|
+
}
|
|
3538
|
+
for (const entryPoint of entryPoints) {
|
|
3539
|
+
if (values.noFlush) {
|
|
3540
|
+
continue;
|
|
3541
|
+
}
|
|
3542
|
+
await flush(entryPoint);
|
|
3543
|
+
}
|
|
3519
3544
|
await cli.moduleConnectionService.loadModule(MODE_MODULE[mode]);
|
|
3520
3545
|
listenFinish();
|
|
3521
3546
|
createGracefulShutdown(mode)();
|
|
@@ -4099,183 +4124,183 @@ const main$2 = async () => {
|
|
|
4099
4124
|
main$2();
|
|
4100
4125
|
|
|
4101
4126
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
4102
|
-
const HELP_TEXT = `
|
|
4103
|
-
Usage:
|
|
4104
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
4105
|
-
|
|
4106
|
-
Modes:
|
|
4107
|
-
|
|
4108
|
-
--backtest <entry> Run strategy against historical candle data
|
|
4109
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4110
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
4111
|
-
--live <entry> Live trading with real orders
|
|
4112
|
-
--pine <entry> Execute a local .pine indicator file
|
|
4113
|
-
--editor Open the Pine Script visual editor in the browser
|
|
4114
|
-
--dump Fetch and save raw OHLCV candles
|
|
4115
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4116
|
-
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4117
|
-
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4118
|
-
--init Scaffold a new project in the current directory
|
|
4119
|
-
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4120
|
-
--help Print this help message
|
|
4121
|
-
|
|
4122
|
-
Backtest flags:
|
|
4123
|
-
|
|
4124
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4125
|
-
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4126
|
-
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4127
|
-
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4128
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4129
|
-
--noCache Skip candle cache warming before the run
|
|
4130
|
-
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4131
|
-
--verbose Log every candle fetch to stdout
|
|
4132
|
-
--ui Start web dashboard at http://localhost:60050
|
|
4133
|
-
--telegram Send trade notifications to Telegram
|
|
4134
|
-
|
|
4135
|
-
Walker flags (--walker):
|
|
4136
|
-
|
|
4137
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4138
|
-
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4139
|
-
--noCache Skip candle cache warming before the run
|
|
4140
|
-
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4141
|
-
--verbose Log every candle fetch to stdout
|
|
4142
|
-
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4143
|
-
--json Save results as JSON to ./dump/<output>.json
|
|
4144
|
-
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4145
|
-
|
|
4146
|
-
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4147
|
-
changing process.cwd() — .env is read from the working directory only.
|
|
4148
|
-
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4149
|
-
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4150
|
-
|
|
4151
|
-
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4152
|
-
|
|
4153
|
-
Paper / Live flags:
|
|
4154
|
-
|
|
4155
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4156
|
-
--strategy <string> Strategy name (default: first registered)
|
|
4157
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4158
|
-
--verbose Log every candle fetch to stdout
|
|
4159
|
-
--ui Start web dashboard
|
|
4160
|
-
--telegram Send Telegram notifications
|
|
4161
|
-
|
|
4162
|
-
PineScript flags (--pine):
|
|
4163
|
-
|
|
4164
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4165
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4166
|
-
--limit <string> Number of candles to fetch (default: 250)
|
|
4167
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4168
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4169
|
-
--output <string> Output file base name without extension
|
|
4170
|
-
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4171
|
-
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4172
|
-
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4173
|
-
|
|
4174
|
-
Only plot() calls with display=display.data_window produce output columns.
|
|
4175
|
-
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4176
|
-
|
|
4177
|
-
Candle dump flags (--dump):
|
|
4178
|
-
|
|
4179
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4180
|
-
--timeframe <string> Candle interval (default: 15m)
|
|
4181
|
-
--limit <string> Number of candles (default: 250)
|
|
4182
|
-
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4183
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4184
|
-
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4185
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4186
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4187
|
-
|
|
4188
|
-
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4189
|
-
|
|
4190
|
-
PnL debug flags (--pnldebug):
|
|
4191
|
-
|
|
4192
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4193
|
-
--priceopen <number> Entry price (required)
|
|
4194
|
-
--direction <string> Position direction: long or short (default: long)
|
|
4195
|
-
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4196
|
-
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4197
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4198
|
-
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4199
|
-
--json Save as JSON array to ./dump/<output>.json
|
|
4200
|
-
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4201
|
-
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4202
|
-
|
|
4203
|
-
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4204
|
-
|
|
4205
|
-
Broker debug flags (--brokerdebug):
|
|
4206
|
-
|
|
4207
|
-
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4208
|
-
--exchange <string> Exchange name (default: first registered)
|
|
4209
|
-
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4210
|
-
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4211
|
-
(default: signal-open)
|
|
4212
|
-
|
|
4213
|
-
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4214
|
-
the selected broker commit with synthetic payload values derived from current price.
|
|
4215
|
-
|
|
4216
|
-
Flush flags (--flush):
|
|
4217
|
-
|
|
4218
|
-
One or more positional entry points. For each entry point the following
|
|
4219
|
-
subdirectories are removed from <entry-dir>/dump/:
|
|
4220
|
-
|
|
4221
|
-
report log markdown agent
|
|
4222
|
-
|
|
4223
|
-
Init flags (--init):
|
|
4224
|
-
|
|
4225
|
-
--output <string> Target directory name (default: backtest-kit-project)
|
|
4226
|
-
|
|
4227
|
-
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4228
|
-
|
|
4229
|
-
Docker flags (--docker):
|
|
4230
|
-
|
|
4231
|
-
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4232
|
-
|
|
4233
|
-
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4234
|
-
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4235
|
-
docker compose up to start the container.
|
|
4236
|
-
|
|
4237
|
-
Module hooks (loaded automatically by each mode):
|
|
4238
|
-
|
|
4239
|
-
modules/backtest.module --backtest Broker adapter for backtest
|
|
4240
|
-
modules/walker.module --walker Broker adapter for walker comparison
|
|
4241
|
-
modules/paper.module --paper Broker adapter for paper trading
|
|
4242
|
-
modules/live.module --live Broker adapter for live trading
|
|
4243
|
-
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4244
|
-
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4245
|
-
modules/dump.module --dump Exchange schema for candle dumps
|
|
4246
|
-
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4247
|
-
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4248
|
-
|
|
4249
|
-
--flush has no associated module. It only removes dump subdirectories.
|
|
4250
|
-
|
|
4251
|
-
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4252
|
-
|
|
4253
|
-
Environment variables:
|
|
4254
|
-
|
|
4255
|
-
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4256
|
-
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4257
|
-
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4258
|
-
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4259
|
-
|
|
4260
|
-
Examples:
|
|
4261
|
-
|
|
4262
|
-
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4263
|
-
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4264
|
-
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4265
|
-
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4266
|
-
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4267
|
-
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4268
|
-
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4269
|
-
node ${ENTRY_PATH} --editor
|
|
4270
|
-
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4271
|
-
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4272
|
-
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4273
|
-
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4274
|
-
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4275
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4276
|
-
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4277
|
-
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4278
|
-
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4127
|
+
const HELP_TEXT = `
|
|
4128
|
+
Usage:
|
|
4129
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
4130
|
+
|
|
4131
|
+
Modes:
|
|
4132
|
+
|
|
4133
|
+
--backtest <entry> Run strategy against historical candle data
|
|
4134
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
4135
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
4136
|
+
--live <entry> Live trading with real orders
|
|
4137
|
+
--pine <entry> Execute a local .pine indicator file
|
|
4138
|
+
--editor Open the Pine Script visual editor in the browser
|
|
4139
|
+
--dump Fetch and save raw OHLCV candles
|
|
4140
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
4141
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
4142
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
4143
|
+
--init Scaffold a new project in the current directory
|
|
4144
|
+
--docker Scaffold a Docker workspace for running strategies in a container
|
|
4145
|
+
--help Print this help message
|
|
4146
|
+
|
|
4147
|
+
Backtest flags:
|
|
4148
|
+
|
|
4149
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4150
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
4151
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
4152
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
4153
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4154
|
+
--noCache Skip candle cache warming before the run
|
|
4155
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
4156
|
+
--verbose Log every candle fetch to stdout
|
|
4157
|
+
--ui Start web dashboard at http://localhost:60050
|
|
4158
|
+
--telegram Send trade notifications to Telegram
|
|
4159
|
+
|
|
4160
|
+
Walker flags (--walker):
|
|
4161
|
+
|
|
4162
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4163
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
4164
|
+
--noCache Skip candle cache warming before the run
|
|
4165
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
4166
|
+
--verbose Log every candle fetch to stdout
|
|
4167
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
4168
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
4169
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
4170
|
+
|
|
4171
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
4172
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
4173
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
4174
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
4175
|
+
|
|
4176
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
4177
|
+
|
|
4178
|
+
Paper / Live flags:
|
|
4179
|
+
|
|
4180
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4181
|
+
--strategy <string> Strategy name (default: first registered)
|
|
4182
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4183
|
+
--verbose Log every candle fetch to stdout
|
|
4184
|
+
--ui Start web dashboard
|
|
4185
|
+
--telegram Send Telegram notifications
|
|
4186
|
+
|
|
4187
|
+
PineScript flags (--pine):
|
|
4188
|
+
|
|
4189
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4190
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4191
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
4192
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4193
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4194
|
+
--output <string> Output file base name without extension
|
|
4195
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
4196
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
4197
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
4198
|
+
|
|
4199
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
4200
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
4201
|
+
|
|
4202
|
+
Candle dump flags (--dump):
|
|
4203
|
+
|
|
4204
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4205
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
4206
|
+
--limit <string> Number of candles (default: 250)
|
|
4207
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
4208
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4209
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
4210
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4211
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4212
|
+
|
|
4213
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
4214
|
+
|
|
4215
|
+
PnL debug flags (--pnldebug):
|
|
4216
|
+
|
|
4217
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4218
|
+
--priceopen <number> Entry price (required)
|
|
4219
|
+
--direction <string> Position direction: long or short (default: long)
|
|
4220
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
4221
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
4222
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4223
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
4224
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
4225
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
4226
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
4227
|
+
|
|
4228
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
4229
|
+
|
|
4230
|
+
Broker debug flags (--brokerdebug):
|
|
4231
|
+
|
|
4232
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
4233
|
+
--exchange <string> Exchange name (default: first registered)
|
|
4234
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
4235
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
4236
|
+
(default: signal-open)
|
|
4237
|
+
|
|
4238
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
4239
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
4240
|
+
|
|
4241
|
+
Flush flags (--flush):
|
|
4242
|
+
|
|
4243
|
+
One or more positional entry points. For each entry point the following
|
|
4244
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
4245
|
+
|
|
4246
|
+
report log markdown agent
|
|
4247
|
+
|
|
4248
|
+
Init flags (--init):
|
|
4249
|
+
|
|
4250
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
4251
|
+
|
|
4252
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
4253
|
+
|
|
4254
|
+
Docker flags (--docker):
|
|
4255
|
+
|
|
4256
|
+
--output <string> Target directory name (default: backtest-kit-docker)
|
|
4257
|
+
|
|
4258
|
+
Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
|
|
4259
|
+
tsconfig.json, and a sample strategy under content/. Run npm install then
|
|
4260
|
+
docker compose up to start the container.
|
|
4261
|
+
|
|
4262
|
+
Module hooks (loaded automatically by each mode):
|
|
4263
|
+
|
|
4264
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
4265
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
4266
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
4267
|
+
modules/live.module --live Broker adapter for live trading
|
|
4268
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
4269
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
4270
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
4271
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
4272
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
4273
|
+
|
|
4274
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
4275
|
+
|
|
4276
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
4277
|
+
|
|
4278
|
+
Environment variables:
|
|
4279
|
+
|
|
4280
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
4281
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
4282
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
4283
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
4284
|
+
|
|
4285
|
+
Examples:
|
|
4286
|
+
|
|
4287
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
4288
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
4289
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
4290
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
4291
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
4292
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
4293
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
4294
|
+
node ${ENTRY_PATH} --editor
|
|
4295
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
4296
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
4297
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
4298
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
4299
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
4300
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
4301
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
4302
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
4303
|
+
node ${ENTRY_PATH} --docker --output my-docker-workspace
|
|
4279
4304
|
`.trimStart();
|
|
4280
4305
|
const main$1 = async () => {
|
|
4281
4306
|
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)))) {
|
|
@@ -4285,7 +4310,7 @@ const main$1 = async () => {
|
|
|
4285
4310
|
if (!values.help) {
|
|
4286
4311
|
return;
|
|
4287
4312
|
}
|
|
4288
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4313
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n\n`);
|
|
4289
4314
|
process.stdout.write(HELP_TEXT);
|
|
4290
4315
|
process.exit(0);
|
|
4291
4316
|
};
|
|
@@ -4299,7 +4324,7 @@ const main = async () => {
|
|
|
4299
4324
|
if (!values.version) {
|
|
4300
4325
|
return;
|
|
4301
4326
|
}
|
|
4302
|
-
process.stdout.write(`@backtest-kit/cli ${"9.
|
|
4327
|
+
process.stdout.write(`@backtest-kit/cli ${"9.8.1"}\n`);
|
|
4303
4328
|
process.exit(0);
|
|
4304
4329
|
};
|
|
4305
4330
|
main();
|