@backtest-kit/cli 7.1.0 → 7.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 +119 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776683700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776684600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776685500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776686400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776687300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776688200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776689100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776690000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776690900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776691800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776692700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776693600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776694500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776695400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776696300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776697200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776698100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776699000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776699900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776700800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776701700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776702600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776703500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776704400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776705300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776706200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776707100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776708000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776708900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776709800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776710700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776711600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776712500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776713400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776714300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776715200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776716100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776717000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776717900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776718800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776719700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776720600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776721500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776722400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776723300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776724200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776725100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776726000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776726900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776727800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776728700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776729600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776730500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776731400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776732300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776733200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776734100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776735000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776735900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776736800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776737700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776738600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776739500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776740400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776741300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776742200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776743100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776744000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776744900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776745800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776746700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776747600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776748500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776749400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776750300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776751200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776752100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776753000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776753900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776754800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776755700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776756600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776757500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776758400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776759300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776760200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776761100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776762000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776762900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776763800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776764700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776765600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776766500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776767400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776768300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776769200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776770100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776771000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776771900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776772800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776773700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776774600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776775500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776776400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776777300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776778200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776779100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776780000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776780900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776781800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776782700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776783600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776784500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776785400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776786300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776787200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776788100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776789000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776789900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776790800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776791700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776792600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776793500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776794400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776795300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776796200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776797100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776798000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776798900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776799800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776800700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776801600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776802500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776803400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776804300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776805200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776806100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776807000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776807900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776808800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776809700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776810600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776811500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776812400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776813300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776814200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776815100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776816000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776816900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776817800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776818700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776819600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776820500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776821400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776822300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776823200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776824100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776825000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776825900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776826800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776827700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776828600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776829500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776830400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776831300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776832200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776833100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776834000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776834900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776835800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776836700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776837600000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776838500000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776839400000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776840300000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776841200000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776842100000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776843000000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776843900000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776844800000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776845700000.json +1 -0
- package/build/dump/data/candle/default_exchange/BTCUSDT/15m/1776846600000.json +1 -0
- package/build/error.txt +770 -0
- package/build/index.cjs +356 -148
- package/build/index.mjs +359 -151
- package/config/notification.config.mjs +13 -0
- package/config/symbol.config.mjs +460 -0
- package/package.json +16 -15
- package/template/average-buy.mustache +2 -0
- package/template/breakeven.mustache +2 -0
- package/template/cancel-scheduled.mustache +1 -1
- package/template/cancelled.mustache +2 -0
- package/template/close-pending.mustache +2 -0
- package/template/closed.mustache +2 -0
- package/template/opened.mustache +2 -0
- package/template/partial-loss.mustache +2 -0
- package/template/partial-profit.mustache +2 -0
- package/template/project/package.mustache +7 -7
- package/template/scheduled.mustache +2 -0
- package/template/signal-close.mustache +2 -0
- package/template/signal-open.mustache +2 -0
- package/template/trailing-stop.mustache +2 -0
- package/template/trailing-take.mustache +2 -0
- package/types.d.ts +146 -38
- /package/template/project/config/{symbol.config.cjs → symbol.config.ts} +0 -0
package/build/index.cjs
CHANGED
|
@@ -88,6 +88,38 @@ var BacktestKitSignals__namespace = /*#__PURE__*/_interopNamespaceDefault(Backte
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
BacktestKit.setConfig({
|
|
92
|
+
CC_MAX_NOTIFICATIONS: 5000,
|
|
93
|
+
CC_MAX_SIGNALS: 750,
|
|
94
|
+
});
|
|
95
|
+
BacktestKit.setConfig({
|
|
96
|
+
CC_ENABLE_DCA_EVERYWHERE: true,
|
|
97
|
+
CC_ENABLE_PPPL_EVERYWHERE: true,
|
|
98
|
+
CC_ENABLE_TRAILING_EVERYWHERE: true,
|
|
99
|
+
});
|
|
100
|
+
BacktestKit.setConfig({
|
|
101
|
+
CC_MAX_SIGNAL_GENERATION_SECONDS: 15 * 60,
|
|
102
|
+
});
|
|
103
|
+
BacktestKit.setConfig({
|
|
104
|
+
CC_MAX_BACKTEST_MARKDOWN_ROWS: 1000,
|
|
105
|
+
CC_MAX_BREAKEVEN_MARKDOWN_ROWS: 1000,
|
|
106
|
+
CC_MAX_HEATMAP_MARKDOWN_ROWS: 1000,
|
|
107
|
+
CC_MAX_HIGHEST_PROFIT_MARKDOWN_ROWS: 1000,
|
|
108
|
+
CC_MAX_LIVE_MARKDOWN_ROWS: 1000,
|
|
109
|
+
CC_MAX_PARTIAL_MARKDOWN_ROWS: 1000,
|
|
110
|
+
CC_MAX_RISK_MARKDOWN_ROWS: 1000,
|
|
111
|
+
CC_MAX_SCHEDULE_MARKDOWN_ROWS: 1000,
|
|
112
|
+
CC_MAX_STRATEGY_MARKDOWN_ROWS: 1000,
|
|
113
|
+
CC_MAX_SYNC_MARKDOWN_ROWS: 1000,
|
|
114
|
+
CC_MAX_PERFORMANCE_MARKDOWN_ROWS: 1000,
|
|
115
|
+
});
|
|
116
|
+
BacktestKit.setConfig({
|
|
117
|
+
CC_MAX_SIGNAL_LIFETIME_MINUTES: Infinity,
|
|
118
|
+
});
|
|
119
|
+
BacktestKit.setConfig({
|
|
120
|
+
CC_WALKER_MARKDOWN_TOP_N: 10,
|
|
121
|
+
});
|
|
122
|
+
|
|
91
123
|
const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
|
|
92
124
|
function dumpStackTrace() {
|
|
93
125
|
const trace = stackTrace__namespace.get();
|
|
@@ -183,12 +215,16 @@ const apiServices$1 = {
|
|
|
183
215
|
const baseServices$1 = {
|
|
184
216
|
errorService: Symbol('errorService'),
|
|
185
217
|
loggerService: Symbol('loggerService'),
|
|
218
|
+
};
|
|
219
|
+
const coreServices$1 = {
|
|
186
220
|
resolveService: Symbol('resolveService'),
|
|
187
221
|
loaderService: Symbol('loaderService'),
|
|
222
|
+
configService: Symbol('configService'),
|
|
188
223
|
babelService: Symbol('babelService'),
|
|
189
224
|
};
|
|
190
225
|
const connectionServices$1 = {
|
|
191
226
|
moduleConnectionService: Symbol('moduleConnectionService'),
|
|
227
|
+
configConnectionService: Symbol('configConnectionService'),
|
|
192
228
|
};
|
|
193
229
|
const mainServices$1 = {
|
|
194
230
|
backtestMainService: Symbol('backtestMainService'),
|
|
@@ -218,6 +254,7 @@ const templateServices$1 = {
|
|
|
218
254
|
const TYPES = {
|
|
219
255
|
...apiServices$1,
|
|
220
256
|
...baseServices$1,
|
|
257
|
+
...coreServices$1,
|
|
221
258
|
...connectionServices$1,
|
|
222
259
|
...mainServices$1,
|
|
223
260
|
...logicServices$1,
|
|
@@ -238,8 +275,10 @@ class ResolveService {
|
|
|
238
275
|
this.loaderService = inject(TYPES.loaderService);
|
|
239
276
|
this.DEFAULT_TEMPLATE_DIR = path.resolve(__dirname$2, '..', 'template');
|
|
240
277
|
this.DEFAULT_MODULES_DIR = path.resolve(__dirname$2, '..', 'modules');
|
|
278
|
+
this.DEFAULT_CONFIG_DIR = path.resolve(__dirname$2, '..', 'config');
|
|
241
279
|
this.OVERRIDE_TEMPLATE_DIR = path.resolve(process.cwd(), 'template');
|
|
242
280
|
this.OVERRIDE_MODULES_DIR = path.resolve(process.cwd(), 'modules');
|
|
281
|
+
this.OVERRIDE_CONFIG_DIR = path.resolve(process.cwd(), 'config');
|
|
243
282
|
this.PROJECT_ROOT_DIR = process.cwd();
|
|
244
283
|
this.getIsLaunched = () => {
|
|
245
284
|
this.loggerService.log("resolveService getIsLaunched");
|
|
@@ -416,6 +455,10 @@ const ALLOWED_EXTENSIONS = [
|
|
|
416
455
|
const DISALLOWED_PATHS = [
|
|
417
456
|
"node_modules",
|
|
418
457
|
"@backtest-kit",
|
|
458
|
+
"build/index.mjs",
|
|
459
|
+
"build/index.js",
|
|
460
|
+
"build\\index.mjs",
|
|
461
|
+
"build\\index.js",
|
|
419
462
|
];
|
|
420
463
|
const getArgs = functoolsKit.singleshot(() => {
|
|
421
464
|
const { values, positionals } = util.parseArgs({
|
|
@@ -657,6 +700,105 @@ const notifyVerbose = functoolsKit.singleshot(() => {
|
|
|
657
700
|
});
|
|
658
701
|
});
|
|
659
702
|
|
|
703
|
+
class SetupUtils {
|
|
704
|
+
constructor() {
|
|
705
|
+
this.enable = functoolsKit.singleshot(() => {
|
|
706
|
+
cli.loggerService.debug("SetupUtils enable");
|
|
707
|
+
{
|
|
708
|
+
const config = cli.configService.getNotificationConfig();
|
|
709
|
+
BacktestKit.Notification.enable(config);
|
|
710
|
+
}
|
|
711
|
+
{
|
|
712
|
+
BacktestKit.Recent.enable();
|
|
713
|
+
BacktestKit.Storage.enable();
|
|
714
|
+
}
|
|
715
|
+
{
|
|
716
|
+
BacktestKit.Markdown.enable();
|
|
717
|
+
BacktestKit.Report.enable();
|
|
718
|
+
BacktestKit.Dump.enable();
|
|
719
|
+
BacktestKit.Memory.enable();
|
|
720
|
+
}
|
|
721
|
+
{
|
|
722
|
+
BacktestKit.Dump.useMarkdown();
|
|
723
|
+
BacktestKit.Memory.usePersist();
|
|
724
|
+
}
|
|
725
|
+
{
|
|
726
|
+
BacktestKit.StorageLive.usePersist();
|
|
727
|
+
BacktestKit.StorageBacktest.useMemory();
|
|
728
|
+
}
|
|
729
|
+
{
|
|
730
|
+
BacktestKit.RecentLive.usePersist();
|
|
731
|
+
BacktestKit.RecentBacktest.useMemory();
|
|
732
|
+
}
|
|
733
|
+
{
|
|
734
|
+
BacktestKit.NotificationLive.usePersist();
|
|
735
|
+
BacktestKit.NotificationBacktest.useMemory();
|
|
736
|
+
}
|
|
737
|
+
{
|
|
738
|
+
BacktestKit.Markdown.useDummy();
|
|
739
|
+
BacktestKit.Log.useJsonl();
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
this.clear = () => {
|
|
743
|
+
cli.loggerService.debug("SetupUtils clear");
|
|
744
|
+
if (!this.enable.hasValue()) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
this.enable.clear();
|
|
748
|
+
{
|
|
749
|
+
BacktestKit.Recent.disable();
|
|
750
|
+
BacktestKit.Storage.disable();
|
|
751
|
+
BacktestKit.Notification.disable();
|
|
752
|
+
}
|
|
753
|
+
{
|
|
754
|
+
BacktestKit.Markdown.disable();
|
|
755
|
+
BacktestKit.Report.disable();
|
|
756
|
+
BacktestKit.Dump.disable();
|
|
757
|
+
BacktestKit.Memory.disable();
|
|
758
|
+
}
|
|
759
|
+
{
|
|
760
|
+
BacktestKit.Markdown.clear();
|
|
761
|
+
BacktestKit.Report.clear();
|
|
762
|
+
BacktestKit.MarkdownWriter.clear();
|
|
763
|
+
BacktestKit.ReportWriter.clear();
|
|
764
|
+
}
|
|
765
|
+
{
|
|
766
|
+
BacktestKit.PersistSignalAdapter.clear();
|
|
767
|
+
BacktestKit.PersistRiskAdapter.clear();
|
|
768
|
+
BacktestKit.PersistScheduleAdapter.clear();
|
|
769
|
+
BacktestKit.PersistPartialAdapter.clear();
|
|
770
|
+
BacktestKit.PersistBreakevenAdapter.clear();
|
|
771
|
+
BacktestKit.PersistCandleAdapter.clear();
|
|
772
|
+
BacktestKit.PersistStorageAdapter.clear();
|
|
773
|
+
BacktestKit.PersistNotificationAdapter.clear();
|
|
774
|
+
BacktestKit.PersistLogAdapter.clear();
|
|
775
|
+
BacktestKit.PersistMeasureAdapter.clear();
|
|
776
|
+
BacktestKit.PersistIntervalAdapter.clear();
|
|
777
|
+
BacktestKit.PersistMemoryAdapter.clear();
|
|
778
|
+
BacktestKit.PersistRecentAdapter.clear();
|
|
779
|
+
}
|
|
780
|
+
{
|
|
781
|
+
BacktestKit.Dump.clear();
|
|
782
|
+
BacktestKit.Log.clear();
|
|
783
|
+
BacktestKit.Markdown.clear();
|
|
784
|
+
}
|
|
785
|
+
{
|
|
786
|
+
BacktestKit.StorageLive.clear();
|
|
787
|
+
BacktestKit.StorageBacktest.clear();
|
|
788
|
+
}
|
|
789
|
+
{
|
|
790
|
+
BacktestKit.NotificationLive.clear();
|
|
791
|
+
BacktestKit.NotificationBacktest.clear();
|
|
792
|
+
}
|
|
793
|
+
{
|
|
794
|
+
BacktestKit.RecentLive.clear();
|
|
795
|
+
BacktestKit.RecentBacktest.clear();
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const Setup = new SetupUtils();
|
|
801
|
+
|
|
660
802
|
const DEFAULT_CACHE_LIST$1 = ["1m", "15m", "30m", "1h", "4h"];
|
|
661
803
|
const GET_CACHE_INTERVAL_LIST_FN$1 = () => {
|
|
662
804
|
const { values } = getArgs();
|
|
@@ -671,6 +813,7 @@ class BacktestMainService {
|
|
|
671
813
|
constructor() {
|
|
672
814
|
this.loggerService = inject(TYPES.loggerService);
|
|
673
815
|
this.resolveService = inject(TYPES.resolveService);
|
|
816
|
+
this.configService = inject(TYPES.configService);
|
|
674
817
|
this.exchangeSchemaService = inject(TYPES.exchangeSchemaService);
|
|
675
818
|
this.frameSchemaService = inject(TYPES.frameSchemaService);
|
|
676
819
|
this.symbolSchemaService = inject(TYPES.symbolSchemaService);
|
|
@@ -682,6 +825,10 @@ class BacktestMainService {
|
|
|
682
825
|
this.loggerService.log("backtestMainService run", {
|
|
683
826
|
payload,
|
|
684
827
|
});
|
|
828
|
+
{
|
|
829
|
+
await this.configService.waitForInit();
|
|
830
|
+
Setup.enable();
|
|
831
|
+
}
|
|
685
832
|
{
|
|
686
833
|
this.frontendProviderService.connect();
|
|
687
834
|
this.telegramProviderService.connect();
|
|
@@ -784,12 +931,17 @@ class WalkerMainService {
|
|
|
784
931
|
constructor() {
|
|
785
932
|
this.loggerService = inject(TYPES.loggerService);
|
|
786
933
|
this.resolveService = inject(TYPES.resolveService);
|
|
934
|
+
this.configService = inject(TYPES.configService);
|
|
787
935
|
this.exchangeSchemaService = inject(TYPES.exchangeSchemaService);
|
|
788
936
|
this.symbolSchemaService = inject(TYPES.symbolSchemaService);
|
|
789
937
|
this.cacheLogicService = inject(TYPES.cacheLogicService);
|
|
790
938
|
this.moduleConnectionService = inject(TYPES.moduleConnectionService);
|
|
791
939
|
this.run = functoolsKit.singleshot(async (payload) => {
|
|
792
940
|
this.loggerService.log("walkerMainService run", { payload });
|
|
941
|
+
{
|
|
942
|
+
await this.configService.waitForInit();
|
|
943
|
+
Setup.enable();
|
|
944
|
+
}
|
|
793
945
|
const strategyMap = new Map();
|
|
794
946
|
const sessionMap = new Map();
|
|
795
947
|
const cwd = process.cwd();
|
|
@@ -995,6 +1147,7 @@ class LiveMainService {
|
|
|
995
1147
|
constructor() {
|
|
996
1148
|
this.loggerService = inject(TYPES.loggerService);
|
|
997
1149
|
this.resolveService = inject(TYPES.resolveService);
|
|
1150
|
+
this.configService = inject(TYPES.configService);
|
|
998
1151
|
this.exchangeSchemaService = inject(TYPES.exchangeSchemaService);
|
|
999
1152
|
this.symbolSchemaService = inject(TYPES.symbolSchemaService);
|
|
1000
1153
|
this.frontendProviderService = inject(TYPES.frontendProviderService);
|
|
@@ -1004,6 +1157,10 @@ class LiveMainService {
|
|
|
1004
1157
|
this.loggerService.log("liveMainService run", {
|
|
1005
1158
|
payload,
|
|
1006
1159
|
});
|
|
1160
|
+
{
|
|
1161
|
+
await this.configService.waitForInit();
|
|
1162
|
+
Setup.enable();
|
|
1163
|
+
}
|
|
1007
1164
|
{
|
|
1008
1165
|
this.frontendProviderService.connect();
|
|
1009
1166
|
this.telegramProviderService.connect();
|
|
@@ -1072,6 +1229,7 @@ class PaperMainService {
|
|
|
1072
1229
|
constructor() {
|
|
1073
1230
|
this.loggerService = inject(TYPES.loggerService);
|
|
1074
1231
|
this.resolveService = inject(TYPES.resolveService);
|
|
1232
|
+
this.configService = inject(TYPES.configService);
|
|
1075
1233
|
this.exchangeSchemaService = inject(TYPES.exchangeSchemaService);
|
|
1076
1234
|
this.symbolSchemaService = inject(TYPES.symbolSchemaService);
|
|
1077
1235
|
this.frontendProviderService = inject(TYPES.frontendProviderService);
|
|
@@ -1079,6 +1237,10 @@ class PaperMainService {
|
|
|
1079
1237
|
this.moduleConnectionService = inject(TYPES.moduleConnectionService);
|
|
1080
1238
|
this.run = functoolsKit.singleshot(async (payload) => {
|
|
1081
1239
|
this.loggerService.log("paperMainService init");
|
|
1240
|
+
{
|
|
1241
|
+
await this.configService.waitForInit();
|
|
1242
|
+
Setup.enable();
|
|
1243
|
+
}
|
|
1082
1244
|
{
|
|
1083
1245
|
this.frontendProviderService.connect();
|
|
1084
1246
|
this.telegramProviderService.connect();
|
|
@@ -1156,16 +1318,72 @@ const getEnv = functoolsKit.singleshot(() => {
|
|
|
1156
1318
|
};
|
|
1157
1319
|
});
|
|
1158
1320
|
|
|
1321
|
+
const GET_SYMBOL_EXPORTS_FN = async (self) => {
|
|
1322
|
+
const exports = await self.configConnectionService.loadConfig("symbol.config");
|
|
1323
|
+
if (!exports) {
|
|
1324
|
+
return null;
|
|
1325
|
+
}
|
|
1326
|
+
return "default" in exports
|
|
1327
|
+
? exports.default
|
|
1328
|
+
: exports;
|
|
1329
|
+
};
|
|
1330
|
+
const GET_SYMBOL_CONFIG_FN = async (self) => {
|
|
1331
|
+
const config = await GET_SYMBOL_EXPORTS_FN(self);
|
|
1332
|
+
if (!config) {
|
|
1333
|
+
throw new Error("FrontendProviderService getSymbolConfig `symbol.config` is not found");
|
|
1334
|
+
}
|
|
1335
|
+
if (Array.isArray(config)) {
|
|
1336
|
+
return config;
|
|
1337
|
+
}
|
|
1338
|
+
if ("symbol_list" in config) {
|
|
1339
|
+
return config.symbol_list;
|
|
1340
|
+
}
|
|
1341
|
+
throw new Error("FrontendProviderService getSymbolConfig `symbol.config` is not found");
|
|
1342
|
+
};
|
|
1343
|
+
const MAP_SYMBOL_CONFIG_FN = (config) => {
|
|
1344
|
+
const uniqueSymbols = new Set();
|
|
1345
|
+
const symbolList = config
|
|
1346
|
+
.filter((item) => {
|
|
1347
|
+
if (uniqueSymbols.has(item.symbol)) {
|
|
1348
|
+
return false;
|
|
1349
|
+
}
|
|
1350
|
+
uniqueSymbols.add(item.symbol);
|
|
1351
|
+
return true;
|
|
1352
|
+
})
|
|
1353
|
+
.map(({ priority, displayName, symbol, logo, icon, ...other }, idx) => ({
|
|
1354
|
+
symbol,
|
|
1355
|
+
icon,
|
|
1356
|
+
logo: logo ?? icon,
|
|
1357
|
+
priority: priority ?? idx,
|
|
1358
|
+
displayName: displayName ?? symbol,
|
|
1359
|
+
index: idx,
|
|
1360
|
+
...other,
|
|
1361
|
+
}));
|
|
1362
|
+
symbolList.sort(({ priority: a_p, index: a_x }, { priority: b_p, index: b_x }) => b_p - a_p || a_x - b_x);
|
|
1363
|
+
return symbolList;
|
|
1364
|
+
};
|
|
1159
1365
|
class FrontendProviderService {
|
|
1160
1366
|
constructor() {
|
|
1161
1367
|
this.loggerService = inject(TYPES.loggerService);
|
|
1162
1368
|
this.resolveService = inject(TYPES.resolveService);
|
|
1369
|
+
this.configConnectionService = inject(TYPES.configConnectionService);
|
|
1163
1370
|
this.enable = functoolsKit.singleshot(() => {
|
|
1164
1371
|
this.loggerService.log("frontendProviderService enable");
|
|
1165
1372
|
const { CC_WWWROOT_HOST, CC_WWWROOT_PORT } = getEnv();
|
|
1166
|
-
|
|
1373
|
+
let unServer;
|
|
1374
|
+
const init = async () => {
|
|
1375
|
+
{
|
|
1376
|
+
const config = await GET_SYMBOL_CONFIG_FN(this);
|
|
1377
|
+
if (config) {
|
|
1378
|
+
const symbolList = MAP_SYMBOL_CONFIG_FN(config);
|
|
1379
|
+
BacktestKitUi.lib.symbolConnectionService.getSymbolList.setValue(Promise.resolve(symbolList));
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
unServer = BacktestKitUi.serve(CC_WWWROOT_HOST, CC_WWWROOT_PORT, this.resolveService.PROJECT_ROOT_DIR);
|
|
1383
|
+
};
|
|
1384
|
+
init();
|
|
1167
1385
|
return () => {
|
|
1168
|
-
unServer();
|
|
1386
|
+
unServer && unServer();
|
|
1169
1387
|
this.enable.clear();
|
|
1170
1388
|
};
|
|
1171
1389
|
});
|
|
@@ -2083,7 +2301,7 @@ class ModuleConnectionService {
|
|
|
2083
2301
|
this.resolveService = inject(TYPES.resolveService);
|
|
2084
2302
|
this.loaderService = inject(TYPES.loaderService);
|
|
2085
2303
|
this.loadModule = async (fileName) => {
|
|
2086
|
-
this.loggerService.log("moduleConnectionService
|
|
2304
|
+
this.loggerService.log("moduleConnectionService loadModule", {
|
|
2087
2305
|
fileName,
|
|
2088
2306
|
});
|
|
2089
2307
|
return await LOAD_MODULE_MODULE_FN(fileName, this);
|
|
@@ -2130,6 +2348,19 @@ class BabelService {
|
|
|
2130
2348
|
}
|
|
2131
2349
|
}
|
|
2132
2350
|
|
|
2351
|
+
/**
|
|
2352
|
+
* This file is used to define any aliases for imports in the client code. This is useful for mocking modules during testing or for providing alternative implementations of certain modules.
|
|
2353
|
+
* For example, if we want to mock the "pinets" module during testing, we can add an entry to the IMPORT_ALIAS object that points to our mock implementation. Then, when the client code tries to import "pinets", it will receive our mock implementation instead of the actual "pinets" module.
|
|
2354
|
+
* This allows us to isolate the client code from external dependencies and test it more effectively.
|
|
2355
|
+
* Note that the keys in the IMPORT_ALIAS object should match the module names used in the client code, and the values should be the corresponding mock implementations or alternative modules.
|
|
2356
|
+
* @example
|
|
2357
|
+
* // To mock the "pinets" module, we can add the following entry to the IMPORT_ALIAS object:
|
|
2358
|
+
* Object.assign(IMPORT_ALIAS, {
|
|
2359
|
+
* "pinets": require("pinets/dist/pinets.min.browser.js"),
|
|
2360
|
+
* });
|
|
2361
|
+
*/
|
|
2362
|
+
const IMPORT_ALIAS = {};
|
|
2363
|
+
|
|
2133
2364
|
const USE_ESMODULE_DEFAULT = false;
|
|
2134
2365
|
const IMPORT_PATHS_EXCLUDE = new Set(["dump", "logs", "modules", "node_modules"]);
|
|
2135
2366
|
const TRANSPILE_FN = functoolsKit.memoize(([path]) => `${path}`, (path, code, self, require) => {
|
|
@@ -2249,6 +2480,8 @@ const CREATE_BASE_REQUIRE_FN = (self, seen) => {
|
|
|
2249
2480
|
return new Proxy(baseRequire, {
|
|
2250
2481
|
apply(_target, _this, args) {
|
|
2251
2482
|
const id = args[0];
|
|
2483
|
+
if (IMPORT_ALIAS[id])
|
|
2484
|
+
return IMPORT_ALIAS[id];
|
|
2252
2485
|
if (id === "backtest-kit")
|
|
2253
2486
|
return globalThis.BacktestKit;
|
|
2254
2487
|
if (id === "@backtest-kit/cli")
|
|
@@ -2352,6 +2585,26 @@ globalThis.BacktestKitOllama = BacktestKitOllama__namespace;
|
|
|
2352
2585
|
globalThis.BacktestKitPinets = BacktestKitPinets__namespace;
|
|
2353
2586
|
globalThis.BacktestKitSignals = BacktestKitSignals__namespace;
|
|
2354
2587
|
|
|
2588
|
+
const GET_ALIAS_EXPORTS_FN = (self) => {
|
|
2589
|
+
const instance = self.getInstance(self.resolveService.OVERRIDE_CONFIG_DIR);
|
|
2590
|
+
if (!instance.check("alias.module")) {
|
|
2591
|
+
return null;
|
|
2592
|
+
}
|
|
2593
|
+
const exports = instance.import("alias.module");
|
|
2594
|
+
return "default" in exports
|
|
2595
|
+
? exports.default
|
|
2596
|
+
: exports;
|
|
2597
|
+
};
|
|
2598
|
+
const INIT_ALIAS_FN = (self) => {
|
|
2599
|
+
const alias = GET_ALIAS_EXPORTS_FN(self);
|
|
2600
|
+
if (!alias) {
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
if (!functoolsKit.isObject(alias)) {
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
Object.assign(IMPORT_ALIAS, alias);
|
|
2607
|
+
};
|
|
2355
2608
|
class LoaderService {
|
|
2356
2609
|
constructor() {
|
|
2357
2610
|
this.babelService = inject(TYPES.babelService);
|
|
@@ -2379,6 +2632,90 @@ class LoaderService {
|
|
|
2379
2632
|
const instance = this.getInstance(basePath);
|
|
2380
2633
|
return instance.check(filePath);
|
|
2381
2634
|
};
|
|
2635
|
+
this.init = functoolsKit.singleshot(() => {
|
|
2636
|
+
this.loggerService.log("loaderService init");
|
|
2637
|
+
INIT_ALIAS_FN(this);
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
const GET_CONFIG_VARIANTS_FN = (fileName, self) => {
|
|
2643
|
+
const result = [];
|
|
2644
|
+
result.push({
|
|
2645
|
+
filePath: path.join(process.cwd(), "config", fileName),
|
|
2646
|
+
baseDir: path.join(process.cwd(), "config")
|
|
2647
|
+
});
|
|
2648
|
+
result.push({
|
|
2649
|
+
filePath: path.join(self.resolveService.OVERRIDE_CONFIG_DIR, fileName),
|
|
2650
|
+
baseDir: self.resolveService.OVERRIDE_CONFIG_DIR,
|
|
2651
|
+
});
|
|
2652
|
+
result.push({
|
|
2653
|
+
filePath: path.join(self.resolveService.DEFAULT_CONFIG_DIR, fileName),
|
|
2654
|
+
baseDir: self.resolveService.DEFAULT_CONFIG_DIR,
|
|
2655
|
+
});
|
|
2656
|
+
return result;
|
|
2657
|
+
};
|
|
2658
|
+
const LOAD_CONFIG_CONFIG_FN = async (fileName, self) => {
|
|
2659
|
+
for (const { filePath, baseDir } of GET_CONFIG_VARIANTS_FN(fileName, self)) {
|
|
2660
|
+
try {
|
|
2661
|
+
if (await self.loaderService.check(filePath, baseDir)) {
|
|
2662
|
+
return self.loaderService.import(filePath, baseDir);
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
catch {
|
|
2666
|
+
console.warn(`Module module import failed filePath=${filePath} baseDir=${baseDir}`);
|
|
2667
|
+
process.exit(-1);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
return null;
|
|
2671
|
+
};
|
|
2672
|
+
class ConfigConnectionService {
|
|
2673
|
+
constructor() {
|
|
2674
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
2675
|
+
this.resolveService = inject(TYPES.resolveService);
|
|
2676
|
+
this.loaderService = inject(TYPES.loaderService);
|
|
2677
|
+
this.loadConfig = (fileName) => {
|
|
2678
|
+
this.loggerService.log("configConnectionService loadConfig", {
|
|
2679
|
+
fileName,
|
|
2680
|
+
});
|
|
2681
|
+
return LOAD_CONFIG_CONFIG_FN(fileName, this);
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
const GET_NOTIFICATION_EXPORTS_FN = async (self) => {
|
|
2687
|
+
const exports = await self.configConnectionService.loadConfig("notification.config");
|
|
2688
|
+
if (!exports) {
|
|
2689
|
+
return null;
|
|
2690
|
+
}
|
|
2691
|
+
return "default" in exports
|
|
2692
|
+
? exports.default
|
|
2693
|
+
: exports;
|
|
2694
|
+
};
|
|
2695
|
+
const GET_NOTIFICATION_CONFIG_FN = async (self) => {
|
|
2696
|
+
const config = await GET_NOTIFICATION_EXPORTS_FN(self);
|
|
2697
|
+
if (!config) {
|
|
2698
|
+
throw new Error("ConfigService getNotificationConfig `notification.config` is not found");
|
|
2699
|
+
}
|
|
2700
|
+
if ("notification_config" in config) {
|
|
2701
|
+
return config.notification_config;
|
|
2702
|
+
}
|
|
2703
|
+
return config;
|
|
2704
|
+
};
|
|
2705
|
+
class ConfigService {
|
|
2706
|
+
constructor() {
|
|
2707
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
2708
|
+
this.configConnectionService = inject(TYPES.configConnectionService);
|
|
2709
|
+
this.getNotificationConfig = functoolsKit.singleshot(() => {
|
|
2710
|
+
throw new Error("ConfigService getNotificationConfig waitForInit is not called");
|
|
2711
|
+
});
|
|
2712
|
+
this.waitForInit = functoolsKit.singleshot(async () => {
|
|
2713
|
+
this.loggerService.log("configService waitForInit");
|
|
2714
|
+
{
|
|
2715
|
+
const config = await GET_NOTIFICATION_CONFIG_FN(this);
|
|
2716
|
+
this.getNotificationConfig.setValue(config);
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2382
2719
|
}
|
|
2383
2720
|
}
|
|
2384
2721
|
|
|
@@ -2389,12 +2726,16 @@ class LoaderService {
|
|
|
2389
2726
|
{
|
|
2390
2727
|
provide(TYPES.errorService, () => new ErrorService());
|
|
2391
2728
|
provide(TYPES.loggerService, () => new LoggerService());
|
|
2729
|
+
}
|
|
2730
|
+
{
|
|
2392
2731
|
provide(TYPES.resolveService, () => new ResolveService());
|
|
2393
2732
|
provide(TYPES.loaderService, () => new LoaderService());
|
|
2733
|
+
provide(TYPES.configService, () => new ConfigService());
|
|
2394
2734
|
provide(TYPES.babelService, () => new BabelService());
|
|
2395
2735
|
}
|
|
2396
2736
|
{
|
|
2397
2737
|
provide(TYPES.moduleConnectionService, () => new ModuleConnectionService());
|
|
2738
|
+
provide(TYPES.configConnectionService, () => new ConfigConnectionService());
|
|
2398
2739
|
}
|
|
2399
2740
|
{
|
|
2400
2741
|
provide(TYPES.backtestMainService, () => new BacktestMainService());
|
|
@@ -2429,12 +2770,16 @@ const apiServices = {
|
|
|
2429
2770
|
const baseServices = {
|
|
2430
2771
|
errorService: inject(TYPES.errorService),
|
|
2431
2772
|
loggerService: inject(TYPES.loggerService),
|
|
2773
|
+
};
|
|
2774
|
+
const coreServices = {
|
|
2432
2775
|
resolveService: inject(TYPES.resolveService),
|
|
2433
2776
|
loaderService: inject(TYPES.loaderService),
|
|
2777
|
+
configService: inject(TYPES.configService),
|
|
2434
2778
|
babelService: inject(TYPES.babelService),
|
|
2435
2779
|
};
|
|
2436
2780
|
const connectionServices = {
|
|
2437
2781
|
moduleConnectionService: inject(TYPES.moduleConnectionService),
|
|
2782
|
+
configConnectionService: inject(TYPES.configConnectionService),
|
|
2438
2783
|
};
|
|
2439
2784
|
const mainServices = {
|
|
2440
2785
|
backtestMainService: inject(TYPES.backtestMainService),
|
|
@@ -2464,6 +2809,7 @@ const templateServices = {
|
|
|
2464
2809
|
const cli = {
|
|
2465
2810
|
...apiServices,
|
|
2466
2811
|
...baseServices,
|
|
2812
|
+
...coreServices,
|
|
2467
2813
|
...connectionServices,
|
|
2468
2814
|
...mainServices,
|
|
2469
2815
|
...logicServices,
|
|
@@ -2474,148 +2820,6 @@ const cli = {
|
|
|
2474
2820
|
};
|
|
2475
2821
|
init();
|
|
2476
2822
|
|
|
2477
|
-
const NOTIFICATION_CONFIG = {
|
|
2478
|
-
signal: true,
|
|
2479
|
-
risk: true,
|
|
2480
|
-
info: true,
|
|
2481
|
-
breakeven: true,
|
|
2482
|
-
common_error: true,
|
|
2483
|
-
critical_error: true,
|
|
2484
|
-
validation_error: true,
|
|
2485
|
-
partial_loss: false,
|
|
2486
|
-
partial_profit: false,
|
|
2487
|
-
signal_sync: false,
|
|
2488
|
-
strategy_commit: true,
|
|
2489
|
-
};
|
|
2490
|
-
class SetupUtils {
|
|
2491
|
-
constructor() {
|
|
2492
|
-
this.enable = functoolsKit.singleshot(() => {
|
|
2493
|
-
cli.loggerService.debug("SetupUtils enable");
|
|
2494
|
-
BacktestKit.Notification.enable(NOTIFICATION_CONFIG);
|
|
2495
|
-
{
|
|
2496
|
-
BacktestKit.Recent.enable();
|
|
2497
|
-
BacktestKit.Storage.enable();
|
|
2498
|
-
}
|
|
2499
|
-
{
|
|
2500
|
-
BacktestKit.Markdown.enable();
|
|
2501
|
-
BacktestKit.Report.enable();
|
|
2502
|
-
BacktestKit.Dump.enable();
|
|
2503
|
-
BacktestKit.Memory.enable();
|
|
2504
|
-
}
|
|
2505
|
-
{
|
|
2506
|
-
BacktestKit.Dump.useMarkdown();
|
|
2507
|
-
BacktestKit.Memory.usePersist();
|
|
2508
|
-
}
|
|
2509
|
-
{
|
|
2510
|
-
BacktestKit.StorageLive.usePersist();
|
|
2511
|
-
BacktestKit.StorageBacktest.useMemory();
|
|
2512
|
-
}
|
|
2513
|
-
{
|
|
2514
|
-
BacktestKit.RecentLive.usePersist();
|
|
2515
|
-
BacktestKit.RecentBacktest.useMemory();
|
|
2516
|
-
}
|
|
2517
|
-
{
|
|
2518
|
-
BacktestKit.NotificationLive.usePersist();
|
|
2519
|
-
BacktestKit.NotificationBacktest.useMemory();
|
|
2520
|
-
}
|
|
2521
|
-
{
|
|
2522
|
-
BacktestKit.Markdown.useDummy();
|
|
2523
|
-
BacktestKit.Log.useJsonl();
|
|
2524
|
-
}
|
|
2525
|
-
});
|
|
2526
|
-
this.clear = () => {
|
|
2527
|
-
cli.loggerService.debug("SetupUtils clear");
|
|
2528
|
-
if (!this.enable.hasValue()) {
|
|
2529
|
-
return;
|
|
2530
|
-
}
|
|
2531
|
-
this.enable.clear();
|
|
2532
|
-
{
|
|
2533
|
-
BacktestKit.Recent.disable();
|
|
2534
|
-
BacktestKit.Storage.disable();
|
|
2535
|
-
BacktestKit.Notification.disable();
|
|
2536
|
-
}
|
|
2537
|
-
{
|
|
2538
|
-
BacktestKit.Markdown.disable();
|
|
2539
|
-
BacktestKit.Report.disable();
|
|
2540
|
-
BacktestKit.Dump.disable();
|
|
2541
|
-
BacktestKit.Memory.disable();
|
|
2542
|
-
}
|
|
2543
|
-
{
|
|
2544
|
-
BacktestKit.Markdown.clear();
|
|
2545
|
-
BacktestKit.Report.clear();
|
|
2546
|
-
BacktestKit.MarkdownWriter.clear();
|
|
2547
|
-
BacktestKit.ReportWriter.clear();
|
|
2548
|
-
}
|
|
2549
|
-
{
|
|
2550
|
-
BacktestKit.PersistSignalAdapter.clear();
|
|
2551
|
-
BacktestKit.PersistRiskAdapter.clear();
|
|
2552
|
-
BacktestKit.PersistScheduleAdapter.clear();
|
|
2553
|
-
BacktestKit.PersistPartialAdapter.clear();
|
|
2554
|
-
BacktestKit.PersistBreakevenAdapter.clear();
|
|
2555
|
-
BacktestKit.PersistCandleAdapter.clear();
|
|
2556
|
-
BacktestKit.PersistStorageAdapter.clear();
|
|
2557
|
-
BacktestKit.PersistNotificationAdapter.clear();
|
|
2558
|
-
BacktestKit.PersistLogAdapter.clear();
|
|
2559
|
-
BacktestKit.PersistMeasureAdapter.clear();
|
|
2560
|
-
BacktestKit.PersistIntervalAdapter.clear();
|
|
2561
|
-
BacktestKit.PersistMemoryAdapter.clear();
|
|
2562
|
-
BacktestKit.PersistRecentAdapter.clear();
|
|
2563
|
-
}
|
|
2564
|
-
{
|
|
2565
|
-
BacktestKit.Dump.clear();
|
|
2566
|
-
BacktestKit.Log.clear();
|
|
2567
|
-
BacktestKit.Markdown.clear();
|
|
2568
|
-
}
|
|
2569
|
-
{
|
|
2570
|
-
BacktestKit.StorageLive.clear();
|
|
2571
|
-
BacktestKit.StorageBacktest.clear();
|
|
2572
|
-
}
|
|
2573
|
-
{
|
|
2574
|
-
BacktestKit.NotificationLive.clear();
|
|
2575
|
-
BacktestKit.NotificationBacktest.clear();
|
|
2576
|
-
}
|
|
2577
|
-
{
|
|
2578
|
-
BacktestKit.RecentLive.clear();
|
|
2579
|
-
BacktestKit.RecentBacktest.clear();
|
|
2580
|
-
}
|
|
2581
|
-
};
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
const Setup = new SetupUtils();
|
|
2585
|
-
|
|
2586
|
-
Setup.enable();
|
|
2587
|
-
BacktestKit.setConfig({
|
|
2588
|
-
CC_MAX_NOTIFICATIONS: 5000,
|
|
2589
|
-
CC_MAX_SIGNALS: 750,
|
|
2590
|
-
});
|
|
2591
|
-
BacktestKit.setConfig({
|
|
2592
|
-
CC_ENABLE_DCA_EVERYWHERE: true,
|
|
2593
|
-
CC_ENABLE_PPPL_EVERYWHERE: true,
|
|
2594
|
-
CC_ENABLE_TRAILING_EVERYWHERE: true,
|
|
2595
|
-
});
|
|
2596
|
-
BacktestKit.setConfig({
|
|
2597
|
-
CC_MAX_SIGNAL_GENERATION_SECONDS: 15 * 60,
|
|
2598
|
-
});
|
|
2599
|
-
BacktestKit.setConfig({
|
|
2600
|
-
CC_MAX_BACKTEST_MARKDOWN_ROWS: 1000,
|
|
2601
|
-
CC_MAX_BREAKEVEN_MARKDOWN_ROWS: 1000,
|
|
2602
|
-
CC_MAX_HEATMAP_MARKDOWN_ROWS: 1000,
|
|
2603
|
-
CC_MAX_HIGHEST_PROFIT_MARKDOWN_ROWS: 1000,
|
|
2604
|
-
CC_MAX_LIVE_MARKDOWN_ROWS: 1000,
|
|
2605
|
-
CC_MAX_PARTIAL_MARKDOWN_ROWS: 1000,
|
|
2606
|
-
CC_MAX_RISK_MARKDOWN_ROWS: 1000,
|
|
2607
|
-
CC_MAX_SCHEDULE_MARKDOWN_ROWS: 1000,
|
|
2608
|
-
CC_MAX_STRATEGY_MARKDOWN_ROWS: 1000,
|
|
2609
|
-
CC_MAX_SYNC_MARKDOWN_ROWS: 1000,
|
|
2610
|
-
CC_MAX_PERFORMANCE_MARKDOWN_ROWS: 1000,
|
|
2611
|
-
});
|
|
2612
|
-
BacktestKit.setConfig({
|
|
2613
|
-
CC_MAX_SIGNAL_LIFETIME_MINUTES: Infinity,
|
|
2614
|
-
});
|
|
2615
|
-
BacktestKit.setConfig({
|
|
2616
|
-
CC_WALKER_MARKDOWN_TOP_N: 10,
|
|
2617
|
-
});
|
|
2618
|
-
|
|
2619
2823
|
const MODES = ["backtest", "walker", "paper", "live", "pine", "editor", "dump", "flush", "init", "help", "version"];
|
|
2620
2824
|
const ENTRY_PATH$1 = "./node_modules/@backtest-kit/cli/build/index.mjs";
|
|
2621
2825
|
const HELP_TEXT$1 = `
|
|
@@ -2631,7 +2835,7 @@ const main$d = async () => {
|
|
|
2631
2835
|
if (MODES.some((mode) => values[mode])) {
|
|
2632
2836
|
return;
|
|
2633
2837
|
}
|
|
2634
|
-
process.stdout.write(`@backtest-kit/cli ${"7.
|
|
2838
|
+
process.stdout.write(`@backtest-kit/cli ${"7.2.0"}\n`);
|
|
2635
2839
|
process.stdout.write("\n");
|
|
2636
2840
|
process.stdout.write(`Run with --help to see available commands.\n`);
|
|
2637
2841
|
process.stdout.write("\n");
|
|
@@ -2962,6 +3166,10 @@ const main$4 = async () => {
|
|
|
2962
3166
|
console.warn("--editor and --pine are mutually exclusive. Use one at a time.");
|
|
2963
3167
|
process.exit(1);
|
|
2964
3168
|
}
|
|
3169
|
+
{
|
|
3170
|
+
await cli.configService.waitForInit();
|
|
3171
|
+
Setup.enable();
|
|
3172
|
+
}
|
|
2965
3173
|
await cli.moduleConnectionService.loadModule("./editor.module");
|
|
2966
3174
|
{
|
|
2967
3175
|
await cli.exchangeSchemaService.addSchema();
|
|
@@ -3291,7 +3499,7 @@ const main$1 = async () => {
|
|
|
3291
3499
|
if (!values.help) {
|
|
3292
3500
|
return;
|
|
3293
3501
|
}
|
|
3294
|
-
process.stdout.write(`@backtest-kit/cli ${"7.
|
|
3502
|
+
process.stdout.write(`@backtest-kit/cli ${"7.2.0"}\n\n`);
|
|
3295
3503
|
process.stdout.write(HELP_TEXT);
|
|
3296
3504
|
process.exit(0);
|
|
3297
3505
|
};
|
|
@@ -3305,7 +3513,7 @@ const main = async () => {
|
|
|
3305
3513
|
if (!values.version) {
|
|
3306
3514
|
return;
|
|
3307
3515
|
}
|
|
3308
|
-
process.stdout.write(`@backtest-kit/cli ${"7.
|
|
3516
|
+
process.stdout.write(`@backtest-kit/cli ${"7.2.0"}\n`);
|
|
3309
3517
|
process.exit(0);
|
|
3310
3518
|
};
|
|
3311
3519
|
main();
|