@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.mjs CHANGED
@@ -3009,10 +3009,10 @@ init();
3009
3009
 
3010
3010
  const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "docker", "help", "version"];
3011
3011
  const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
3012
- const HELP_TEXT$1 = `
3013
- Example:
3014
-
3015
- node ${ENTRY_PATH$1} --help
3012
+ const HELP_TEXT$1 = `
3013
+ Example:
3014
+
3015
+ node ${ENTRY_PATH$1} --help
3016
3016
  `.trimStart();
3017
3017
  const main$g = async () => {
3018
3018
  if (!getEntry(import.meta.url)) {
@@ -3022,7 +3022,7 @@ const main$g = async () => {
3022
3022
  if (MODES.some((mode) => values[mode])) {
3023
3023
  return;
3024
3024
  }
3025
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
3025
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
3026
3026
  process.stdout.write("\n");
3027
3027
  process.stdout.write(`Run with --help to see available commands.\n`);
3028
3028
  process.stdout.write("\n");
@@ -3839,183 +3839,183 @@ const main$2 = async () => {
3839
3839
  main$2();
3840
3840
 
3841
3841
  const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
3842
- const HELP_TEXT = `
3843
- Usage:
3844
- node index.mjs --<mode> [flags] [entry-point]
3845
-
3846
- Modes:
3847
-
3848
- --backtest <entry> Run strategy against historical candle data
3849
- --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3850
- --paper <entry> Paper trading (live prices, no real orders)
3851
- --live <entry> Live trading with real orders
3852
- --pine <entry> Execute a local .pine indicator file
3853
- --editor Open the Pine Script visual editor in the browser
3854
- --dump Fetch and save raw OHLCV candles
3855
- --pnldebug Simulate PnL per minute for a given entry price and direction
3856
- --brokerdebug Fire a single broker commit against the live broker adapter
3857
- --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3858
- --init Scaffold a new project in the current directory
3859
- --docker Scaffold a Docker workspace for running strategies in a container
3860
- --help Print this help message
3861
-
3862
- Backtest flags:
3863
-
3864
- --symbol <string> Trading pair (default: BTCUSDT)
3865
- --strategy <string> Strategy name from addStrategySchema (default: first registered)
3866
- --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3867
- --frame <string> Frame name from addFrameSchema (default: first registered)
3868
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3869
- --noCache Skip candle cache warming before the run
3870
- --noFlush Skip removing report/log/markdown/agent folders before backtest run
3871
- --verbose Log every candle fetch to stdout
3872
- --ui Start web dashboard at http://localhost:60050
3873
- --telegram Send trade notifications to Telegram
3874
-
3875
- Walker flags (--walker):
3876
-
3877
- --symbol <string> Trading pair (default: BTCUSDT)
3878
- --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3879
- --noCache Skip candle cache warming before the run
3880
- --noFlush Skip removing report/log/markdown/agent folders before walker run
3881
- --verbose Log every candle fetch to stdout
3882
- --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3883
- --json Save results as JSON to ./dump/<output>.json
3884
- --markdown Save report as Markdown to ./dump/<output>.md
3885
-
3886
- Each positional argument is a strategy entry point. All strategy files are loaded without
3887
- changing process.cwd() — .env is read from the working directory only.
3888
- addWalkerSchema is called automatically using the registered exchange and frame.
3889
- After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3890
-
3891
- Module file ./modules/walker.module is loaded automatically if it exists.
3892
-
3893
- Paper / Live flags:
3894
-
3895
- --symbol <string> Trading pair (default: BTCUSDT)
3896
- --strategy <string> Strategy name (default: first registered)
3897
- --exchange <string> Exchange name (default: first registered)
3898
- --verbose Log every candle fetch to stdout
3899
- --ui Start web dashboard
3900
- --telegram Send Telegram notifications
3901
-
3902
- PineScript flags (--pine):
3903
-
3904
- --symbol <string> Trading pair (default: BTCUSDT)
3905
- --timeframe <string> Candle interval (default: 15m)
3906
- --limit <string> Number of candles to fetch (default: 250)
3907
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3908
- --exchange <string> Exchange name (default: first registered)
3909
- --output <string> Output file base name without extension
3910
- --json Save output as JSON array to <pine-dir>/dump/<output>.json
3911
- --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3912
- --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3913
-
3914
- Only plot() calls with display=display.data_window produce output columns.
3915
- Module file ./modules/pine.module is loaded automatically if it exists.
3916
-
3917
- Candle dump flags (--dump):
3918
-
3919
- --symbol <string> Trading pair (default: BTCUSDT)
3920
- --timeframe <string> Candle interval (default: 15m)
3921
- --limit <string> Number of candles (default: 250)
3922
- --when <string> End date — ISO 8601 or Unix ms (default: now)
3923
- --exchange <string> Exchange name (default: first registered)
3924
- --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3925
- --json Save as JSON array to ./dump/<output>.json
3926
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3927
-
3928
- Module file ./modules/dump.module is loaded automatically if it exists.
3929
-
3930
- PnL debug flags (--pnldebug):
3931
-
3932
- --symbol <string> Trading pair (default: BTCUSDT)
3933
- --priceopen <number> Entry price (required)
3934
- --direction <string> Position direction: long or short (default: long)
3935
- --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
3936
- --minutes <string> Number of 1m candles to simulate (default: 60)
3937
- --exchange <string> Exchange name (default: first registered)
3938
- --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3939
- --json Save as JSON array to ./dump/<output>.json
3940
- --jsonl Save as JSONL to ./dump/<output>.jsonl
3941
- --markdown Save as Markdown table to ./dump/<output>.md
3942
-
3943
- Module file ./modules/pnldebug.module is loaded automatically if it exists.
3944
-
3945
- Broker debug flags (--brokerdebug):
3946
-
3947
- --symbol <string> Trading pair (default: BTCUSDT)
3948
- --exchange <string> Exchange name (default: first registered)
3949
- --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3950
- partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3951
- (default: signal-open)
3952
-
3953
- Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3954
- the selected broker commit with synthetic payload values derived from current price.
3955
-
3956
- Flush flags (--flush):
3957
-
3958
- One or more positional entry points. For each entry point the following
3959
- subdirectories are removed from <entry-dir>/dump/:
3960
-
3961
- report log markdown agent
3962
-
3963
- Init flags (--init):
3964
-
3965
- --output <string> Target directory name (default: backtest-kit-project)
3966
-
3967
- Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3968
-
3969
- Docker flags (--docker):
3970
-
3971
- --output <string> Target directory name (default: backtest-kit-docker)
3972
-
3973
- Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
3974
- tsconfig.json, and a sample strategy under content/. Run npm install then
3975
- docker compose up to start the container.
3976
-
3977
- Module hooks (loaded automatically by each mode):
3978
-
3979
- modules/backtest.module --backtest Broker adapter for backtest
3980
- modules/walker.module --walker Broker adapter for walker comparison
3981
- modules/paper.module --paper Broker adapter for paper trading
3982
- modules/live.module --live Broker adapter for live trading
3983
- modules/pine.module --pine Exchange schema for PineScript runs
3984
- modules/editor.module --editor Exchange schema for the visual Pine editor
3985
- modules/dump.module --dump Exchange schema for candle dumps
3986
- modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3987
- modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3988
-
3989
- --flush has no associated module. It only removes dump subdirectories.
3990
-
3991
- Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3992
-
3993
- Environment variables:
3994
-
3995
- CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3996
- CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3997
- CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3998
- CC_WWWROOT_PORT UI server port (default: 60050)
3999
-
4000
- Examples:
4001
-
4002
- node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4003
- node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4004
- node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4005
- node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4006
- node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4007
- node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4008
- node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4009
- node ${ENTRY_PATH} --editor
4010
- node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4011
- node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4012
- node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4013
- node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4014
- node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4015
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4016
- node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4017
- node ${ENTRY_PATH} --init --output my-trading-bot
4018
- node ${ENTRY_PATH} --docker --output my-docker-workspace
3842
+ const HELP_TEXT = `
3843
+ Usage:
3844
+ node index.mjs --<mode> [flags] [entry-point]
3845
+
3846
+ Modes:
3847
+
3848
+ --backtest <entry> Run strategy against historical candle data
3849
+ --walker <entry...> Run Walker A/B strategy comparison across multiple strategies
3850
+ --paper <entry> Paper trading (live prices, no real orders)
3851
+ --live <entry> Live trading with real orders
3852
+ --pine <entry> Execute a local .pine indicator file
3853
+ --editor Open the Pine Script visual editor in the browser
3854
+ --dump Fetch and save raw OHLCV candles
3855
+ --pnldebug Simulate PnL per minute for a given entry price and direction
3856
+ --brokerdebug Fire a single broker commit against the live broker adapter
3857
+ --flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
3858
+ --init Scaffold a new project in the current directory
3859
+ --docker Scaffold a Docker workspace for running strategies in a container
3860
+ --help Print this help message
3861
+
3862
+ Backtest flags:
3863
+
3864
+ --symbol <string> Trading pair (default: BTCUSDT)
3865
+ --strategy <string> Strategy name from addStrategySchema (default: first registered)
3866
+ --exchange <string> Exchange name from addExchangeSchema (default: first registered)
3867
+ --frame <string> Frame name from addFrameSchema (default: first registered)
3868
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3869
+ --noCache Skip candle cache warming before the run
3870
+ --noFlush Skip removing report/log/markdown/agent folders before backtest run
3871
+ --verbose Log every candle fetch to stdout
3872
+ --ui Start web dashboard at http://localhost:60050
3873
+ --telegram Send trade notifications to Telegram
3874
+
3875
+ Walker flags (--walker):
3876
+
3877
+ --symbol <string> Trading pair (default: BTCUSDT)
3878
+ --cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
3879
+ --noCache Skip candle cache warming before the run
3880
+ --noFlush Skip removing report/log/markdown/agent folders before walker run
3881
+ --verbose Log every candle fetch to stdout
3882
+ --output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
3883
+ --json Save results as JSON to ./dump/<output>.json
3884
+ --markdown Save report as Markdown to ./dump/<output>.md
3885
+
3886
+ Each positional argument is a strategy entry point. All strategy files are loaded without
3887
+ changing process.cwd() — .env is read from the working directory only.
3888
+ addWalkerSchema is called automatically using the registered exchange and frame.
3889
+ After comparison completes the report is printed to stdout (or saved if --json/--markdown).
3890
+
3891
+ Module file ./modules/walker.module is loaded automatically if it exists.
3892
+
3893
+ Paper / Live flags:
3894
+
3895
+ --symbol <string> Trading pair (default: BTCUSDT)
3896
+ --strategy <string> Strategy name (default: first registered)
3897
+ --exchange <string> Exchange name (default: first registered)
3898
+ --verbose Log every candle fetch to stdout
3899
+ --ui Start web dashboard
3900
+ --telegram Send Telegram notifications
3901
+
3902
+ PineScript flags (--pine):
3903
+
3904
+ --symbol <string> Trading pair (default: BTCUSDT)
3905
+ --timeframe <string> Candle interval (default: 15m)
3906
+ --limit <string> Number of candles to fetch (default: 250)
3907
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3908
+ --exchange <string> Exchange name (default: first registered)
3909
+ --output <string> Output file base name without extension
3910
+ --json Save output as JSON array to <pine-dir>/dump/<output>.json
3911
+ --jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
3912
+ --markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
3913
+
3914
+ Only plot() calls with display=display.data_window produce output columns.
3915
+ Module file ./modules/pine.module is loaded automatically if it exists.
3916
+
3917
+ Candle dump flags (--dump):
3918
+
3919
+ --symbol <string> Trading pair (default: BTCUSDT)
3920
+ --timeframe <string> Candle interval (default: 15m)
3921
+ --limit <string> Number of candles (default: 250)
3922
+ --when <string> End date — ISO 8601 or Unix ms (default: now)
3923
+ --exchange <string> Exchange name (default: first registered)
3924
+ --output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
3925
+ --json Save as JSON array to ./dump/<output>.json
3926
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3927
+
3928
+ Module file ./modules/dump.module is loaded automatically if it exists.
3929
+
3930
+ PnL debug flags (--pnldebug):
3931
+
3932
+ --symbol <string> Trading pair (default: BTCUSDT)
3933
+ --priceopen <number> Entry price (required)
3934
+ --direction <string> Position direction: long or short (default: long)
3935
+ --when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
3936
+ --minutes <string> Number of 1m candles to simulate (default: 60)
3937
+ --exchange <string> Exchange name (default: first registered)
3938
+ --output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
3939
+ --json Save as JSON array to ./dump/<output>.json
3940
+ --jsonl Save as JSONL to ./dump/<output>.jsonl
3941
+ --markdown Save as Markdown table to ./dump/<output>.md
3942
+
3943
+ Module file ./modules/pnldebug.module is loaded automatically if it exists.
3944
+
3945
+ Broker debug flags (--brokerdebug):
3946
+
3947
+ --symbol <string> Trading pair (default: BTCUSDT)
3948
+ --exchange <string> Exchange name (default: first registered)
3949
+ --commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
3950
+ partial-loss, average-buy, trailing-stop, trailing-take, breakeven
3951
+ (default: signal-open)
3952
+
3953
+ Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
3954
+ the selected broker commit with synthetic payload values derived from current price.
3955
+
3956
+ Flush flags (--flush):
3957
+
3958
+ One or more positional entry points. For each entry point the following
3959
+ subdirectories are removed from <entry-dir>/dump/:
3960
+
3961
+ report log markdown agent
3962
+
3963
+ Init flags (--init):
3964
+
3965
+ --output <string> Target directory name (default: backtest-kit-project)
3966
+
3967
+ Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
3968
+
3969
+ Docker flags (--docker):
3970
+
3971
+ --output <string> Target directory name (default: backtest-kit-docker)
3972
+
3973
+ Scaffolds a Docker workspace: docker-compose.yaml, .env.example, package.json,
3974
+ tsconfig.json, and a sample strategy under content/. Run npm install then
3975
+ docker compose up to start the container.
3976
+
3977
+ Module hooks (loaded automatically by each mode):
3978
+
3979
+ modules/backtest.module --backtest Broker adapter for backtest
3980
+ modules/walker.module --walker Broker adapter for walker comparison
3981
+ modules/paper.module --paper Broker adapter for paper trading
3982
+ modules/live.module --live Broker adapter for live trading
3983
+ modules/pine.module --pine Exchange schema for PineScript runs
3984
+ modules/editor.module --editor Exchange schema for the visual Pine editor
3985
+ modules/dump.module --dump Exchange schema for candle dumps
3986
+ modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
3987
+ modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
3988
+
3989
+ --flush has no associated module. It only removes dump subdirectories.
3990
+
3991
+ Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
3992
+
3993
+ Environment variables:
3994
+
3995
+ CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
3996
+ CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
3997
+ CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
3998
+ CC_WWWROOT_PORT UI server port (default: 60050)
3999
+
4000
+ Examples:
4001
+
4002
+ node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
4003
+ node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
4004
+ node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
4005
+ node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
4006
+ node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
4007
+ node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
4008
+ node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
4009
+ node ${ENTRY_PATH} --editor
4010
+ node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
4011
+ node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
4012
+ node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
4013
+ node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
4014
+ node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
4015
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
4016
+ node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
4017
+ node ${ENTRY_PATH} --init --output my-trading-bot
4018
+ node ${ENTRY_PATH} --docker --output my-docker-workspace
4019
4019
  `.trimStart();
4020
4020
  const main$1 = async () => {
4021
4021
  if (!getEntry(import.meta.url)) {
@@ -4025,7 +4025,7 @@ const main$1 = async () => {
4025
4025
  if (!values.help) {
4026
4026
  return;
4027
4027
  }
4028
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n\n`);
4028
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n\n`);
4029
4029
  process.stdout.write(HELP_TEXT);
4030
4030
  process.exit(0);
4031
4031
  };
@@ -4039,7 +4039,7 @@ const main = async () => {
4039
4039
  if (!values.version) {
4040
4040
  return;
4041
4041
  }
4042
- process.stdout.write(`@backtest-kit/cli ${"9.1.0"}\n`);
4042
+ process.stdout.write(`@backtest-kit/cli ${"9.1.1"}\n`);
4043
4043
  process.exit(0);
4044
4044
  };
4045
4045
  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
+ };