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