@backtest-kit/cli 9.1.0 → 9.1.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/build/index.cjs CHANGED
@@ -3038,10 +3038,10 @@ init();
3038
3038
 
3039
3039
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3040
3040
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3041
- const HELP_TEXT$1 = `
3042
- Example:
3043
-
3044
- node ${ENTRY_PATH$1} --help
3041
+ const HELP_TEXT$1 = `
3042
+ Example:
3043
+
3044
+ node ${ENTRY_PATH$1} --help
3045
3045
  `.trimStart();
3046
3046
  const main$g = async () => {
3047
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)))) {
@@ -3051,7 +3051,7 @@ const main$g = async () => {
3051
3051
  if (MODES.some((mode) => values[mode])) {
3052
3052
  return;
3053
3053
  }
3054
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
3054
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
3055
3055
  process.stdout.write("\n");
3056
3056
  process.stdout.write(`Run with --help to see available commands.\n`);
3057
3057
  process.stdout.write("\n");
@@ -3868,183 +3868,183 @@ const main$2 = async () => {
3868
3868
  main$2();
3869
3869
 
3870
3870
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
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
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
4048
4048
  `.trimStart();
4049
4049
  const main$1 = async () => {
4050
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)))) {
@@ -4054,7 +4054,7 @@ const main$1 = async () => {
4054
4054
  if (!values.help) {
4055
4055
  return;
4056
4056
  }
4057
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n\n`);
4057
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n\n`);
4058
4058
  process.stdout.write(HELP_TEXT);
4059
4059
  process.exit(0);
4060
4060
  };
@@ -4068,7 +4068,7 @@ const main = async () => {
4068
4068
  if (!values.version) {
4069
4069
  return;
4070
4070
  }
4071
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
4071
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
4072
4072
  process.exit(0);
4073
4073
  };
4074
4074
  main();