@backtest-kit/cli 8.0.0 → 8.2.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 +1545 -1484
- package/build/index.cjs +183 -160
- package/build/index.mjs +183 -160
- package/config/notification.config.mjs +13 -13
- package/config/symbol.config.mjs +460 -460
- package/package.json +125 -125
- 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
|
@@ -586,6 +586,14 @@ const getArgs = functoolsKit.singleshot(() => {
|
|
|
586
586
|
type: "string",
|
|
587
587
|
default: "",
|
|
588
588
|
},
|
|
589
|
+
brokerdebug: {
|
|
590
|
+
type: "boolean",
|
|
591
|
+
default: false,
|
|
592
|
+
},
|
|
593
|
+
commit: {
|
|
594
|
+
type: "string",
|
|
595
|
+
default: "",
|
|
596
|
+
},
|
|
589
597
|
init: {
|
|
590
598
|
type: "boolean",
|
|
591
599
|
default: false,
|
|
@@ -2999,12 +3007,12 @@ const cli = {
|
|
|
2999
3007
|
};
|
|
3000
3008
|
init();
|
|
3001
3009
|
|
|
3002
|
-
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "flush", "init", "help", "version"];
|
|
3010
|
+
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "pnldebug", "brokerdebug", "flush", "init", "help", "version"];
|
|
3003
3011
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3004
|
-
const HELP_TEXT$1 = `
|
|
3005
|
-
Example:
|
|
3006
|
-
|
|
3007
|
-
node ${ENTRY_PATH$1} --help
|
|
3012
|
+
const HELP_TEXT$1 = `
|
|
3013
|
+
Example:
|
|
3014
|
+
|
|
3015
|
+
node ${ENTRY_PATH$1} --help
|
|
3008
3016
|
`.trimStart();
|
|
3009
3017
|
const main$e = async () => {
|
|
3010
3018
|
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)))) {
|
|
@@ -3014,7 +3022,7 @@ const main$e = async () => {
|
|
|
3014
3022
|
if (MODES.some((mode) => values[mode])) {
|
|
3015
3023
|
return;
|
|
3016
3024
|
}
|
|
3017
|
-
process.stdout.write(`@backtest-kit/cli ${"8.
|
|
3025
|
+
process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
|
|
3018
3026
|
process.stdout.write("\n");
|
|
3019
3027
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
3020
3028
|
process.stdout.write("\n");
|
|
@@ -3632,158 +3640,173 @@ const main$2 = async () => {
|
|
|
3632
3640
|
main$2();
|
|
3633
3641
|
|
|
3634
3642
|
const ENTRY_PATH = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
3635
|
-
const HELP_TEXT = `
|
|
3636
|
-
Usage:
|
|
3637
|
-
node index.mjs --<mode> [flags] [entry-point]
|
|
3638
|
-
|
|
3639
|
-
Modes:
|
|
3640
|
-
|
|
3641
|
-
--backtest <entry> Run strategy against historical candle data
|
|
3642
|
-
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3643
|
-
--paper <entry> Paper trading (live prices, no real orders)
|
|
3644
|
-
--live <entry> Live trading with real orders
|
|
3645
|
-
--pine <entry> Execute a local .pine indicator file
|
|
3646
|
-
--editor Open the Pine Script visual editor in the browser
|
|
3647
|
-
--dump Fetch and save raw OHLCV candles
|
|
3648
|
-
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3649
|
-
--
|
|
3650
|
-
--
|
|
3651
|
-
--
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
--
|
|
3657
|
-
--
|
|
3658
|
-
--
|
|
3659
|
-
--
|
|
3660
|
-
--
|
|
3661
|
-
--
|
|
3662
|
-
--
|
|
3663
|
-
--
|
|
3664
|
-
--
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
--
|
|
3670
|
-
--
|
|
3671
|
-
--
|
|
3672
|
-
--
|
|
3673
|
-
--
|
|
3674
|
-
--
|
|
3675
|
-
--
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
--
|
|
3688
|
-
--
|
|
3689
|
-
--
|
|
3690
|
-
--
|
|
3691
|
-
--
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
--
|
|
3697
|
-
--
|
|
3698
|
-
--
|
|
3699
|
-
--
|
|
3700
|
-
--
|
|
3701
|
-
--
|
|
3702
|
-
--
|
|
3703
|
-
--
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
--
|
|
3712
|
-
--
|
|
3713
|
-
--
|
|
3714
|
-
--
|
|
3715
|
-
--
|
|
3716
|
-
--
|
|
3717
|
-
--
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
--
|
|
3725
|
-
--
|
|
3726
|
-
--
|
|
3727
|
-
--
|
|
3728
|
-
--
|
|
3729
|
-
--
|
|
3730
|
-
--
|
|
3731
|
-
--
|
|
3732
|
-
--
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
node ${ENTRY_PATH} --
|
|
3643
|
+
const HELP_TEXT = `
|
|
3644
|
+
Usage:
|
|
3645
|
+
node index.mjs --<mode> [flags] [entry-point]
|
|
3646
|
+
|
|
3647
|
+
Modes:
|
|
3648
|
+
|
|
3649
|
+
--backtest <entry> Run strategy against historical candle data
|
|
3650
|
+
--walker <entry...> Run Walker A/B strategy comparison across multiple strategies
|
|
3651
|
+
--paper <entry> Paper trading (live prices, no real orders)
|
|
3652
|
+
--live <entry> Live trading with real orders
|
|
3653
|
+
--pine <entry> Execute a local .pine indicator file
|
|
3654
|
+
--editor Open the Pine Script visual editor in the browser
|
|
3655
|
+
--dump Fetch and save raw OHLCV candles
|
|
3656
|
+
--pnldebug Simulate PnL per minute for a given entry price and direction
|
|
3657
|
+
--brokerdebug Fire a single broker commit against the live broker adapter
|
|
3658
|
+
--flush <entry...> Delete report/log/markdown/agent folders from strategy dump dir
|
|
3659
|
+
--init Scaffold a new project in the current directory
|
|
3660
|
+
--help Print this help message
|
|
3661
|
+
|
|
3662
|
+
Backtest flags:
|
|
3663
|
+
|
|
3664
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3665
|
+
--strategy <string> Strategy name from addStrategySchema (default: first registered)
|
|
3666
|
+
--exchange <string> Exchange name from addExchangeSchema (default: first registered)
|
|
3667
|
+
--frame <string> Frame name from addFrameSchema (default: first registered)
|
|
3668
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3669
|
+
--noCache Skip candle cache warming before the run
|
|
3670
|
+
--noFlush Skip removing report/log/markdown/agent folders before backtest run
|
|
3671
|
+
--verbose Log every candle fetch to stdout
|
|
3672
|
+
--ui Start web dashboard at http://localhost:60050
|
|
3673
|
+
--telegram Send trade notifications to Telegram
|
|
3674
|
+
|
|
3675
|
+
Walker flags (--walker):
|
|
3676
|
+
|
|
3677
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3678
|
+
--cacheInterval <string> Comma-separated intervals to pre-cache (default: "1m, 15m, 30m, 4h")
|
|
3679
|
+
--noCache Skip candle cache warming before the run
|
|
3680
|
+
--noFlush Skip removing report/log/markdown/agent folders before walker run
|
|
3681
|
+
--verbose Log every candle fetch to stdout
|
|
3682
|
+
--output <string> Output file base name (default: walker_{SYMBOL}_{TIMESTAMP})
|
|
3683
|
+
--json Save results as JSON to ./dump/<output>.json
|
|
3684
|
+
--markdown Save report as Markdown to ./dump/<output>.md
|
|
3685
|
+
|
|
3686
|
+
Each positional argument is a strategy entry point. All strategy files are loaded without
|
|
3687
|
+
changing process.cwd() — .env is read from the working directory only.
|
|
3688
|
+
addWalkerSchema is called automatically using the registered exchange and frame.
|
|
3689
|
+
After comparison completes the report is printed to stdout (or saved if --json/--markdown).
|
|
3690
|
+
|
|
3691
|
+
Module file ./modules/walker.module is loaded automatically if it exists.
|
|
3692
|
+
|
|
3693
|
+
Paper / Live flags:
|
|
3694
|
+
|
|
3695
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3696
|
+
--strategy <string> Strategy name (default: first registered)
|
|
3697
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3698
|
+
--verbose Log every candle fetch to stdout
|
|
3699
|
+
--ui Start web dashboard
|
|
3700
|
+
--telegram Send Telegram notifications
|
|
3701
|
+
|
|
3702
|
+
PineScript flags (--pine):
|
|
3703
|
+
|
|
3704
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3705
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3706
|
+
--limit <string> Number of candles to fetch (default: 250)
|
|
3707
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3708
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3709
|
+
--output <string> Output file base name without extension
|
|
3710
|
+
--json Save output as JSON array to <pine-dir>/dump/<output>.json
|
|
3711
|
+
--jsonl Save output as JSONL to <pine-dir>/dump/<output>.jsonl
|
|
3712
|
+
--markdown Save output as Markdown table to <pine-dir>/dump/<output>.md
|
|
3713
|
+
|
|
3714
|
+
Only plot() calls with display=display.data_window produce output columns.
|
|
3715
|
+
Module file ./modules/pine.module is loaded automatically if it exists.
|
|
3716
|
+
|
|
3717
|
+
Candle dump flags (--dump):
|
|
3718
|
+
|
|
3719
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3720
|
+
--timeframe <string> Candle interval (default: 15m)
|
|
3721
|
+
--limit <string> Number of candles (default: 250)
|
|
3722
|
+
--when <string> End date — ISO 8601 or Unix ms (default: now)
|
|
3723
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3724
|
+
--output <string> Output file base name (default: {SYMBOL}_{LIMIT}_{TIMEFRAME}_{TIMESTAMP})
|
|
3725
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3726
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3727
|
+
|
|
3728
|
+
Module file ./modules/dump.module is loaded automatically if it exists.
|
|
3729
|
+
|
|
3730
|
+
PnL debug flags (--pnldebug):
|
|
3731
|
+
|
|
3732
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3733
|
+
--priceopen <number> Entry price (required)
|
|
3734
|
+
--direction <string> Position direction: long or short (default: long)
|
|
3735
|
+
--when <string> Start timestamp — ISO 8601 or Unix ms (default: now)
|
|
3736
|
+
--minutes <string> Number of 1m candles to simulate (default: 60)
|
|
3737
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3738
|
+
--output <string> Output file base name (default: {SYMBOL}_{DIRECTION}_{PRICEOPEN}_{TIMESTAMP})
|
|
3739
|
+
--json Save as JSON array to ./dump/<output>.json
|
|
3740
|
+
--jsonl Save as JSONL to ./dump/<output>.jsonl
|
|
3741
|
+
--markdown Save as Markdown table to ./dump/<output>.md
|
|
3742
|
+
|
|
3743
|
+
Module file ./modules/pnldebug.module is loaded automatically if it exists.
|
|
3744
|
+
|
|
3745
|
+
Broker debug flags (--brokerdebug):
|
|
3746
|
+
|
|
3747
|
+
--symbol <string> Trading pair (default: BTCUSDT)
|
|
3748
|
+
--exchange <string> Exchange name (default: first registered)
|
|
3749
|
+
--commit <string> Commit type to fire: signal-open, signal-close, partial-profit,
|
|
3750
|
+
partial-loss, average-buy, trailing-stop, trailing-take, breakeven
|
|
3751
|
+
(default: signal-open)
|
|
3752
|
+
|
|
3753
|
+
Loads ./live.module, fetches the last candle for --symbol/--timeframe, and calls
|
|
3754
|
+
the selected broker commit with synthetic payload values derived from current price.
|
|
3755
|
+
|
|
3756
|
+
Flush flags (--flush):
|
|
3757
|
+
|
|
3758
|
+
One or more positional entry points. For each entry point the following
|
|
3759
|
+
subdirectories are removed from <entry-dir>/dump/:
|
|
3760
|
+
|
|
3761
|
+
report log markdown agent
|
|
3762
|
+
|
|
3763
|
+
Init flags (--init):
|
|
3764
|
+
|
|
3765
|
+
--output <string> Target directory name (default: backtest-kit-project)
|
|
3766
|
+
|
|
3767
|
+
Scaffolds a project and runs scripts/fetch_docs.mjs to download library docs.
|
|
3768
|
+
|
|
3769
|
+
Module hooks (loaded automatically by each mode):
|
|
3770
|
+
|
|
3771
|
+
modules/backtest.module --backtest Broker adapter for backtest
|
|
3772
|
+
modules/walker.module --walker Broker adapter for walker comparison
|
|
3773
|
+
modules/paper.module --paper Broker adapter for paper trading
|
|
3774
|
+
modules/live.module --live Broker adapter for live trading
|
|
3775
|
+
modules/pine.module --pine Exchange schema for PineScript runs
|
|
3776
|
+
modules/editor.module --editor Exchange schema for the visual Pine editor
|
|
3777
|
+
modules/dump.module --dump Exchange schema for candle dumps
|
|
3778
|
+
modules/pnldebug.module --pnldebug Exchange schema for PnL debug runs
|
|
3779
|
+
modules/brokerdebug.module --brokerdebug Broker adapter used for broker commit testing
|
|
3780
|
+
|
|
3781
|
+
--flush has no associated module. It only removes dump subdirectories.
|
|
3782
|
+
|
|
3783
|
+
Extensions .ts, .mjs, .cjs are tried automatically. Missing module = soft warning.
|
|
3784
|
+
|
|
3785
|
+
Environment variables:
|
|
3786
|
+
|
|
3787
|
+
CC_TELEGRAM_TOKEN Telegram bot token (required for --telegram)
|
|
3788
|
+
CC_TELEGRAM_CHANNEL Telegram channel or chat ID (required for --telegram)
|
|
3789
|
+
CC_WWWROOT_HOST UI server bind address (default: 0.0.0.0)
|
|
3790
|
+
CC_WWWROOT_PORT UI server port (default: 60050)
|
|
3791
|
+
|
|
3792
|
+
Examples:
|
|
3793
|
+
|
|
3794
|
+
node ${ENTRY_PATH} --backtest ./content/feb_2026.strategy.ts
|
|
3795
|
+
node ${ENTRY_PATH} --backtest --symbol BTCUSDT --noCache --noFlush --ui ./content/feb_2026.strategy.ts
|
|
3796
|
+
node ${ENTRY_PATH} --walker ./content/feb_2026_v1.strategy.ts ./content/feb_2026_v2.strategy.ts ./content/feb_2026_v3.strategy.ts
|
|
3797
|
+
node ${ENTRY_PATH} --walker --symbol BTCUSDT --noCache --noFlush --markdown ./content/feb_2026_v1.ts ./content/feb_2026_v2.ts
|
|
3798
|
+
node ${ENTRY_PATH} --paper --symbol ETHUSDT ./content/feb_2026.strategy.ts
|
|
3799
|
+
node ${ENTRY_PATH} --live --ui --telegram ./content/feb_2026.strategy.ts
|
|
3800
|
+
node ${ENTRY_PATH} --pine ./math/feb_2026.pine --timeframe 15m --limit 500 --jsonl
|
|
3801
|
+
node ${ENTRY_PATH} --editor
|
|
3802
|
+
node ${ENTRY_PATH} --dump --symbol BTCUSDT --timeframe 15m --limit 500 --jsonl
|
|
3803
|
+
node ${ENTRY_PATH} --pnldebug --symbol BTCUSDT --priceopen 64069.50 --direction short --when "2025-02-25" --minutes 120
|
|
3804
|
+
node ${ENTRY_PATH} --pnldebug --priceopen 67956.73 --direction long --when 1772064000000 --minutes 60 --markdown
|
|
3805
|
+
node ${ENTRY_PATH} --brokerdebug --commit signal-open --symbol BTCUSDT
|
|
3806
|
+
node ${ENTRY_PATH} --brokerdebug --commit partial-profit --symbol ETHUSDT
|
|
3807
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts
|
|
3808
|
+
node ${ENTRY_PATH} --flush ./content/feb_2026.strategy/feb_2026.strategy.ts ./content/feb_2026.strategy/feb_2026.test.ts
|
|
3809
|
+
node ${ENTRY_PATH} --init --output my-trading-bot
|
|
3787
3810
|
`.trimStart();
|
|
3788
3811
|
const main$1 = async () => {
|
|
3789
3812
|
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)))) {
|
|
@@ -3793,7 +3816,7 @@ const main$1 = async () => {
|
|
|
3793
3816
|
if (!values.help) {
|
|
3794
3817
|
return;
|
|
3795
3818
|
}
|
|
3796
|
-
process.stdout.write(`@backtest-kit/cli ${"8.
|
|
3819
|
+
process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n\n`);
|
|
3797
3820
|
process.stdout.write(HELP_TEXT);
|
|
3798
3821
|
process.exit(0);
|
|
3799
3822
|
};
|
|
@@ -3807,7 +3830,7 @@ const main = async () => {
|
|
|
3807
3830
|
if (!values.version) {
|
|
3808
3831
|
return;
|
|
3809
3832
|
}
|
|
3810
|
-
process.stdout.write(`@backtest-kit/cli ${"8.
|
|
3833
|
+
process.stdout.write(`@backtest-kit/cli ${"8.2.0"}\n`);
|
|
3811
3834
|
process.exit(0);
|
|
3812
3835
|
};
|
|
3813
3836
|
main();
|