@backtest-kit/ui 11.8.0 → 12.0.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.
Files changed (48) hide show
  1. package/README.md +254 -254
  2. package/build/index.cjs +137 -10
  3. package/build/index.mjs +137 -10
  4. package/build/modules/frontend/build/3rdparty/ace_1.4.12/ace.js +21337 -21337
  5. package/build/modules/frontend/build/3rdparty/ace_1.4.12/mode-javascript.js +797 -797
  6. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-chrome.js +137 -137
  7. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-twilight.js +115 -115
  8. package/build/modules/frontend/build/3rdparty/ace_1.4.12/worker-javascript.js +15012 -15012
  9. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/echarts.min.js +45 -45
  10. package/build/modules/frontend/build/assets/{Article-BldQ_H8I.js → Article-Cep1zZez.js} +1 -1
  11. package/build/modules/frontend/build/assets/{Background-D6xcxEbi.js → Background-DI4TR0l_.js} +1 -1
  12. package/build/modules/frontend/build/assets/{IconPhoto-CM6ubSCe.js → IconPhoto-BV2g32_b.js} +1 -1
  13. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-C-mzFglu.js → KeyboardArrowLeft-uHSkdvcT.js} +1 -1
  14. package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-FxrCBqkC.js → PictureAsPdfOutlined-DWr8-Wu_.js} +1 -1
  15. package/build/modules/frontend/build/assets/{Refresh-BGJUioLp.js → Refresh-DDS1Dl8a.js} +1 -1
  16. package/build/modules/frontend/build/assets/emitters-D_sqmu3L.js +1 -0
  17. package/build/modules/frontend/build/assets/hasRouteMatch-DTIimlwJ.js +1 -0
  18. package/build/modules/frontend/build/assets/{html2canvas-8DZCOHpl.js → html2canvas-jxBuh7xH.js} +1 -1
  19. package/build/modules/frontend/build/assets/index-BV8dzBt8.js +1 -0
  20. package/build/modules/frontend/build/assets/{index-Ci6Sa86c.js → index-CAZyhcV6.js} +1 -1
  21. package/build/modules/frontend/build/assets/index-Cgi9Q7Z8.js +1 -0
  22. package/build/modules/frontend/build/assets/{index-fSeYRlLH.js → index-CjbnzV4W.js} +1 -1
  23. package/build/modules/frontend/build/assets/index-D9wmaFsM.js +1 -0
  24. package/build/modules/frontend/build/assets/index-DFqeL1wo.js +1 -0
  25. package/build/modules/frontend/build/assets/{index-DFGpC_id.js → index-DMjmH2fE.js} +60 -60
  26. package/build/modules/frontend/build/assets/index-DjRBVBQG.js +1 -0
  27. package/build/modules/frontend/build/assets/index-DkEgiru5.js +1 -0
  28. package/build/modules/frontend/build/assets/{index-FnuTsM2k.js → index-FTZ3DZOP.js} +1 -1
  29. package/build/modules/frontend/build/assets/index-ZVDIT3wc.js +1 -0
  30. package/build/modules/frontend/build/assets/index-_NbOxv95.js +1 -0
  31. package/build/modules/frontend/build/assets/index-uZ6nksDu.js +1 -0
  32. package/build/modules/frontend/build/assets/{index.es-DtImoYbN.js → index.es-R8OIqeA_.js} +1 -1
  33. package/build/modules/frontend/build/assets/{markdownit-C5YxinP2.js → markdownit-3n_Nebne.js} +1 -1
  34. package/build/modules/frontend/build/index.html +87 -87
  35. package/build/modules/frontend/build/manifest.json +23 -23
  36. package/package.json +118 -118
  37. package/types.d.ts +14 -1
  38. package/build/modules/frontend/build/assets/emitters-DHUyBH6m.js +0 -1
  39. package/build/modules/frontend/build/assets/hasRouteMatch-2KWvqpEf.js +0 -1
  40. package/build/modules/frontend/build/assets/index-B5-6nnKB.js +0 -1
  41. package/build/modules/frontend/build/assets/index-BGhP8I63.js +0 -1
  42. package/build/modules/frontend/build/assets/index-BIGGWGiC.js +0 -1
  43. package/build/modules/frontend/build/assets/index-BL4ImOSk.js +0 -1
  44. package/build/modules/frontend/build/assets/index-BLTTcFqj.js +0 -1
  45. package/build/modules/frontend/build/assets/index-BPDS1doI.js +0 -1
  46. package/build/modules/frontend/build/assets/index-Cv7RePv9.js +0 -1
  47. package/build/modules/frontend/build/assets/index-DRQ75_P8.js +0 -1
  48. package/build/modules/frontend/build/assets/index-Df7slJni.js +0 -1
package/build/index.cjs CHANGED
@@ -107,6 +107,7 @@ const mockServices$1 = {
107
107
  performanceMockService: Symbol("performanceMockService"),
108
108
  environmentMockService: Symbol("environmentMockService"),
109
109
  setupMockService: Symbol("setupMockService"),
110
+ runtimeMockService: Symbol("runtimeMockService"),
110
111
  };
111
112
  const viewServices$1 = {
112
113
  notificationViewService: Symbol("notificationViewService"),
@@ -121,6 +122,7 @@ const viewServices$1 = {
121
122
  performanceViewService: Symbol("performanceViewService"),
122
123
  environmentViewService: Symbol("environmentViewService"),
123
124
  setupViewService: Symbol("setupViewService"),
125
+ runtimeViewService: Symbol("runtimeViewService"),
124
126
  };
125
127
  const TYPES = {
126
128
  ...baseServices$1,
@@ -801,10 +803,10 @@ class SignalMockService {
801
803
  }
802
804
  }
803
805
 
804
- const MOCK_DATA_PATH$3 = "./mock/heat.json";
806
+ const MOCK_DATA_PATH$4 = "./mock/heat.json";
805
807
  const MOCK_REPORT_PATH$1 = "./mock/heat-report.md";
806
808
  const READ_HEAT_DATA_FN = functoolsKit.singleshot(async () => {
807
- const data = await fs.readFile(MOCK_DATA_PATH$3, "utf-8");
809
+ const data = await fs.readFile(MOCK_DATA_PATH$4, "utf-8");
808
810
  return JSON.parse(data);
809
811
  });
810
812
  const READ_HEAT_REPORT_FN = functoolsKit.singleshot(async () => {
@@ -1268,7 +1270,7 @@ class StatusViewService {
1268
1270
  portfolioCertaintyRatio: currentHeat.portfolioCertaintyRatio,
1269
1271
  portfolioExpectedYearlyReturns: currentHeat.portfolioExpectedYearlyReturns,
1270
1272
  portfolioTradesPerYear: currentHeat.portfolioTradesPerYear,
1271
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, }) => ({
1273
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, medianStepSize, buyerPressure, sellerPressure, buyerStrength, sellerStrength, pressureImbalance, trend, trendStrength, trendConfidence, }) => ({
1272
1274
  symbol,
1273
1275
  totalPnl,
1274
1276
  winRate,
@@ -1300,6 +1302,15 @@ class StatusViewService {
1300
1302
  avgConsecutiveLossPnl,
1301
1303
  avgWinDuration,
1302
1304
  avgLossDuration,
1305
+ medianStepSize,
1306
+ buyerPressure,
1307
+ sellerPressure,
1308
+ buyerStrength,
1309
+ sellerStrength,
1310
+ pressureImbalance,
1311
+ trend,
1312
+ trendStrength,
1313
+ trendConfidence,
1303
1314
  })),
1304
1315
  backtest: true,
1305
1316
  };
@@ -1341,7 +1352,7 @@ class StatusViewService {
1341
1352
  portfolioCertaintyRatio: currentHeat.portfolioCertaintyRatio,
1342
1353
  portfolioExpectedYearlyReturns: currentHeat.portfolioExpectedYearlyReturns,
1343
1354
  portfolioTradesPerYear: currentHeat.portfolioTradesPerYear,
1344
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, }) => ({
1355
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, medianStepSize, buyerPressure, sellerPressure, buyerStrength, sellerStrength, pressureImbalance, trend, trendStrength, trendConfidence, }) => ({
1345
1356
  symbol,
1346
1357
  totalPnl,
1347
1358
  winRate,
@@ -1373,6 +1384,15 @@ class StatusViewService {
1373
1384
  avgConsecutiveLossPnl,
1374
1385
  avgWinDuration,
1375
1386
  avgLossDuration,
1387
+ medianStepSize,
1388
+ buyerPressure,
1389
+ sellerPressure,
1390
+ buyerStrength,
1391
+ sellerStrength,
1392
+ pressureImbalance,
1393
+ trend,
1394
+ trendStrength,
1395
+ trendConfidence,
1376
1396
  })),
1377
1397
  backtest: false,
1378
1398
  };
@@ -1953,10 +1973,10 @@ class LiveMetaService {
1953
1973
  }
1954
1974
  }
1955
1975
 
1956
- const MOCK_DATA_PATH$2 = "./mock/performance.json";
1976
+ const MOCK_DATA_PATH$3 = "./mock/performance.json";
1957
1977
  const MOCK_REPORT_PATH = "./mock/performance-report.md";
1958
1978
  const READ_PERFORMANCE_DATA_FN = functoolsKit.singleshot(async () => {
1959
- const data = await fs.readFile(MOCK_DATA_PATH$2, "utf-8");
1979
+ const data = await fs.readFile(MOCK_DATA_PATH$3, "utf-8");
1960
1980
  return JSON.parse(data);
1961
1981
  });
1962
1982
  const READ_PERFORMANCE_REPORT_FN = functoolsKit.singleshot(async () => {
@@ -1976,9 +1996,9 @@ class PerformanceMockService {
1976
1996
  }
1977
1997
  }
1978
1998
 
1979
- const MOCK_DATA_PATH$1 = "./mock/environment.json";
1999
+ const MOCK_DATA_PATH$2 = "./mock/environment.json";
1980
2000
  const READ_ENVIRONMENT_DATA_FN = functoolsKit.singleshot(async () => {
1981
- const data = await fs.readFile(MOCK_DATA_PATH$1, "utf-8");
2001
+ const data = await fs.readFile(MOCK_DATA_PATH$2, "utf-8");
1982
2002
  return JSON.parse(data);
1983
2003
  });
1984
2004
  class EnvironmentMockService {
@@ -1991,9 +2011,9 @@ class EnvironmentMockService {
1991
2011
  }
1992
2012
  }
1993
2013
 
1994
- const MOCK_DATA_PATH = "./mock/setup.json";
2014
+ const MOCK_DATA_PATH$1 = "./mock/setup.json";
1995
2015
  const READ_SETUP_DATA_FN = functoolsKit.singleshot(async () => {
1996
- const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
2016
+ const data = await fs.readFile(MOCK_DATA_PATH$1, "utf-8");
1997
2017
  return JSON.parse(data);
1998
2018
  });
1999
2019
  class SetupMockService {
@@ -2006,6 +2026,21 @@ class SetupMockService {
2006
2026
  }
2007
2027
  }
2008
2028
 
2029
+ const MOCK_DATA_PATH = "./mock/runtime.json";
2030
+ const READ_RUNTIME_INFO_FN = functoolsKit.singleshot(async () => {
2031
+ const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
2032
+ return JSON.parse(data);
2033
+ });
2034
+ class RuntimeMockService {
2035
+ constructor() {
2036
+ this.loggerService = inject(TYPES.loggerService);
2037
+ this.getRuntimeInfo = async () => {
2038
+ this.loggerService.log("runtimeMockService getRuntimeInfo");
2039
+ return await READ_RUNTIME_INFO_FN();
2040
+ };
2041
+ }
2042
+ }
2043
+
2009
2044
  class PerformanceViewService {
2010
2045
  constructor() {
2011
2046
  this.loggerService = inject(TYPES.loggerService);
@@ -2131,6 +2166,36 @@ class SetupViewService {
2131
2166
  }
2132
2167
  }
2133
2168
 
2169
+ class RuntimeViewService {
2170
+ constructor() {
2171
+ this.loggerService = inject(TYPES.loggerService);
2172
+ this.runtimeMockService = inject(TYPES.runtimeMockService);
2173
+ this.getRuntimeInfo = async () => {
2174
+ this.loggerService.log("runtimeViewService getRuntimeInfo");
2175
+ if (CC_ENABLE_MOCK) {
2176
+ return await this.runtimeMockService.getRuntimeInfo();
2177
+ }
2178
+ const [backtestItem] = await BacktestKit.Backtest.list();
2179
+ const [liveItem] = await BacktestKit.Live.list();
2180
+ if (backtestItem) {
2181
+ return await BacktestKit.lib.runtimeMetaService.getRuntimeInfo(backtestItem.symbol, {
2182
+ strategyName: backtestItem.strategyName,
2183
+ exchangeName: backtestItem.exchangeName,
2184
+ frameName: backtestItem.frameName,
2185
+ }, true);
2186
+ }
2187
+ if (liveItem) {
2188
+ return await BacktestKit.lib.runtimeMetaService.getRuntimeInfo(liveItem.symbol, {
2189
+ strategyName: liveItem.strategyName,
2190
+ exchangeName: liveItem.exchangeName,
2191
+ frameName: "",
2192
+ }, false);
2193
+ }
2194
+ return null;
2195
+ };
2196
+ }
2197
+ }
2198
+
2134
2199
  {
2135
2200
  provide(TYPES.loggerService, () => new LoggerService());
2136
2201
  provide(TYPES.exchangeService, () => new ExchangeService());
@@ -2157,6 +2222,7 @@ class SetupViewService {
2157
2222
  provide(TYPES.performanceMockService, () => new PerformanceMockService());
2158
2223
  provide(TYPES.environmentMockService, () => new EnvironmentMockService());
2159
2224
  provide(TYPES.setupMockService, () => new SetupMockService());
2225
+ provide(TYPES.runtimeMockService, () => new RuntimeMockService());
2160
2226
  }
2161
2227
  {
2162
2228
  provide(TYPES.notificationViewService, () => new NotificationViewService());
@@ -2171,6 +2237,7 @@ class SetupViewService {
2171
2237
  provide(TYPES.performanceViewService, () => new PerformanceViewService());
2172
2238
  provide(TYPES.environmentViewService, () => new EnvironmentViewService());
2173
2239
  provide(TYPES.setupViewService, () => new SetupViewService());
2240
+ provide(TYPES.runtimeViewService, () => new RuntimeViewService());
2174
2241
  }
2175
2242
 
2176
2243
  const baseServices = {
@@ -2199,6 +2266,7 @@ const mockServices = {
2199
2266
  performanceMockService: inject(TYPES.performanceMockService),
2200
2267
  environmentMockService: inject(TYPES.environmentMockService),
2201
2268
  setupMockService: inject(TYPES.setupMockService),
2269
+ runtimeMockService: inject(TYPES.runtimeMockService),
2202
2270
  };
2203
2271
  const viewServices = {
2204
2272
  notificationViewService: inject(TYPES.notificationViewService),
@@ -2213,6 +2281,7 @@ const viewServices = {
2213
2281
  performanceViewService: inject(TYPES.performanceViewService),
2214
2282
  environmentViewService: inject(TYPES.environmentViewService),
2215
2283
  setupViewService: inject(TYPES.setupViewService),
2284
+ runtimeViewService: inject(TYPES.runtimeViewService),
2216
2285
  };
2217
2286
  const ioc = {
2218
2287
  ...baseServices,
@@ -2952,6 +3021,35 @@ router$b.post("/api/v1/mock/environment_data", async (req, res) => {
2952
3021
  });
2953
3022
  }
2954
3023
  });
3024
+ // RuntimeMockService endpoints
3025
+ router$b.post("/api/v1/mock/runtime_info", async (req, res) => {
3026
+ try {
3027
+ const request = await micro.json(req);
3028
+ const { requestId, serviceName } = request;
3029
+ const data = await ioc.runtimeMockService.getRuntimeInfo();
3030
+ const result = {
3031
+ data,
3032
+ status: "ok",
3033
+ error: "",
3034
+ requestId,
3035
+ serviceName,
3036
+ };
3037
+ ioc.loggerService.log("/api/v1/mock/runtime_info ok", {
3038
+ request,
3039
+ result: omit(result, "data"),
3040
+ });
3041
+ return await micro.send(res, 200, result);
3042
+ }
3043
+ catch (error) {
3044
+ ioc.loggerService.log("/api/v1/mock/runtime_info error", {
3045
+ error: functoolsKit.errorData(error),
3046
+ });
3047
+ return await micro.send(res, 200, {
3048
+ status: "error",
3049
+ error: functoolsKit.getErrorMessage(error),
3050
+ });
3051
+ }
3052
+ });
2955
3053
 
2956
3054
  const router$a = Router({
2957
3055
  params: true,
@@ -3682,6 +3780,35 @@ router$a.post("/api/v1/view/environment_data", async (req, res) => {
3682
3780
  });
3683
3781
  }
3684
3782
  });
3783
+ // RuntimeViewService endpoints
3784
+ router$a.post("/api/v1/view/runtime_info", async (req, res) => {
3785
+ try {
3786
+ const request = await micro.json(req);
3787
+ const { requestId, serviceName } = request;
3788
+ const data = await ioc.runtimeViewService.getRuntimeInfo();
3789
+ const result = {
3790
+ data,
3791
+ status: "ok",
3792
+ error: "",
3793
+ requestId,
3794
+ serviceName,
3795
+ };
3796
+ ioc.loggerService.log("/api/v1/view/runtime_info ok", {
3797
+ request,
3798
+ result: omit(result, "data"),
3799
+ });
3800
+ return await micro.send(res, 200, result);
3801
+ }
3802
+ catch (error) {
3803
+ ioc.loggerService.log("/api/v1/view/runtime_info error", {
3804
+ error: functoolsKit.errorData(error),
3805
+ });
3806
+ return await micro.send(res, 200, {
3807
+ status: "error",
3808
+ error: functoolsKit.getErrorMessage(error),
3809
+ });
3810
+ }
3811
+ });
3685
3812
 
3686
3813
  const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
3687
3814
  function getModulesPath() {
package/build/index.mjs CHANGED
@@ -86,6 +86,7 @@ const mockServices$1 = {
86
86
  performanceMockService: Symbol("performanceMockService"),
87
87
  environmentMockService: Symbol("environmentMockService"),
88
88
  setupMockService: Symbol("setupMockService"),
89
+ runtimeMockService: Symbol("runtimeMockService"),
89
90
  };
90
91
  const viewServices$1 = {
91
92
  notificationViewService: Symbol("notificationViewService"),
@@ -100,6 +101,7 @@ const viewServices$1 = {
100
101
  performanceViewService: Symbol("performanceViewService"),
101
102
  environmentViewService: Symbol("environmentViewService"),
102
103
  setupViewService: Symbol("setupViewService"),
104
+ runtimeViewService: Symbol("runtimeViewService"),
103
105
  };
104
106
  const TYPES = {
105
107
  ...baseServices$1,
@@ -780,10 +782,10 @@ class SignalMockService {
780
782
  }
781
783
  }
782
784
 
783
- const MOCK_DATA_PATH$3 = "./mock/heat.json";
785
+ const MOCK_DATA_PATH$4 = "./mock/heat.json";
784
786
  const MOCK_REPORT_PATH$1 = "./mock/heat-report.md";
785
787
  const READ_HEAT_DATA_FN = singleshot(async () => {
786
- const data = await fs.readFile(MOCK_DATA_PATH$3, "utf-8");
788
+ const data = await fs.readFile(MOCK_DATA_PATH$4, "utf-8");
787
789
  return JSON.parse(data);
788
790
  });
789
791
  const READ_HEAT_REPORT_FN = singleshot(async () => {
@@ -1247,7 +1249,7 @@ class StatusViewService {
1247
1249
  portfolioCertaintyRatio: currentHeat.portfolioCertaintyRatio,
1248
1250
  portfolioExpectedYearlyReturns: currentHeat.portfolioExpectedYearlyReturns,
1249
1251
  portfolioTradesPerYear: currentHeat.portfolioTradesPerYear,
1250
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, }) => ({
1252
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, medianStepSize, buyerPressure, sellerPressure, buyerStrength, sellerStrength, pressureImbalance, trend, trendStrength, trendConfidence, }) => ({
1251
1253
  symbol,
1252
1254
  totalPnl,
1253
1255
  winRate,
@@ -1279,6 +1281,15 @@ class StatusViewService {
1279
1281
  avgConsecutiveLossPnl,
1280
1282
  avgWinDuration,
1281
1283
  avgLossDuration,
1284
+ medianStepSize,
1285
+ buyerPressure,
1286
+ sellerPressure,
1287
+ buyerStrength,
1288
+ sellerStrength,
1289
+ pressureImbalance,
1290
+ trend,
1291
+ trendStrength,
1292
+ trendConfidence,
1282
1293
  })),
1283
1294
  backtest: true,
1284
1295
  };
@@ -1320,7 +1331,7 @@ class StatusViewService {
1320
1331
  portfolioCertaintyRatio: currentHeat.portfolioCertaintyRatio,
1321
1332
  portfolioExpectedYearlyReturns: currentHeat.portfolioExpectedYearlyReturns,
1322
1333
  portfolioTradesPerYear: currentHeat.portfolioTradesPerYear,
1323
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, }) => ({
1334
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor, sharpeRatio, annualizedSharpeRatio, certaintyRatio, expectedYearlyReturns, tradesPerYear, avgPnl, stdDev, avgWin, avgLoss, maxWinStreak, maxLossStreak, avgPeakPnl, avgFallPnl, peakProfitPnl, maxDrawdownPnl, avgDuration, medianPnl, avgConsecutiveWinPnl, avgConsecutiveLossPnl, avgWinDuration, avgLossDuration, medianStepSize, buyerPressure, sellerPressure, buyerStrength, sellerStrength, pressureImbalance, trend, trendStrength, trendConfidence, }) => ({
1324
1335
  symbol,
1325
1336
  totalPnl,
1326
1337
  winRate,
@@ -1352,6 +1363,15 @@ class StatusViewService {
1352
1363
  avgConsecutiveLossPnl,
1353
1364
  avgWinDuration,
1354
1365
  avgLossDuration,
1366
+ medianStepSize,
1367
+ buyerPressure,
1368
+ sellerPressure,
1369
+ buyerStrength,
1370
+ sellerStrength,
1371
+ pressureImbalance,
1372
+ trend,
1373
+ trendStrength,
1374
+ trendConfidence,
1355
1375
  })),
1356
1376
  backtest: false,
1357
1377
  };
@@ -1932,10 +1952,10 @@ class LiveMetaService {
1932
1952
  }
1933
1953
  }
1934
1954
 
1935
- const MOCK_DATA_PATH$2 = "./mock/performance.json";
1955
+ const MOCK_DATA_PATH$3 = "./mock/performance.json";
1936
1956
  const MOCK_REPORT_PATH = "./mock/performance-report.md";
1937
1957
  const READ_PERFORMANCE_DATA_FN = singleshot(async () => {
1938
- const data = await fs.readFile(MOCK_DATA_PATH$2, "utf-8");
1958
+ const data = await fs.readFile(MOCK_DATA_PATH$3, "utf-8");
1939
1959
  return JSON.parse(data);
1940
1960
  });
1941
1961
  const READ_PERFORMANCE_REPORT_FN = singleshot(async () => {
@@ -1955,9 +1975,9 @@ class PerformanceMockService {
1955
1975
  }
1956
1976
  }
1957
1977
 
1958
- const MOCK_DATA_PATH$1 = "./mock/environment.json";
1978
+ const MOCK_DATA_PATH$2 = "./mock/environment.json";
1959
1979
  const READ_ENVIRONMENT_DATA_FN = singleshot(async () => {
1960
- const data = await fs.readFile(MOCK_DATA_PATH$1, "utf-8");
1980
+ const data = await fs.readFile(MOCK_DATA_PATH$2, "utf-8");
1961
1981
  return JSON.parse(data);
1962
1982
  });
1963
1983
  class EnvironmentMockService {
@@ -1970,9 +1990,9 @@ class EnvironmentMockService {
1970
1990
  }
1971
1991
  }
1972
1992
 
1973
- const MOCK_DATA_PATH = "./mock/setup.json";
1993
+ const MOCK_DATA_PATH$1 = "./mock/setup.json";
1974
1994
  const READ_SETUP_DATA_FN = singleshot(async () => {
1975
- const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
1995
+ const data = await fs.readFile(MOCK_DATA_PATH$1, "utf-8");
1976
1996
  return JSON.parse(data);
1977
1997
  });
1978
1998
  class SetupMockService {
@@ -1985,6 +2005,21 @@ class SetupMockService {
1985
2005
  }
1986
2006
  }
1987
2007
 
2008
+ const MOCK_DATA_PATH = "./mock/runtime.json";
2009
+ const READ_RUNTIME_INFO_FN = singleshot(async () => {
2010
+ const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
2011
+ return JSON.parse(data);
2012
+ });
2013
+ class RuntimeMockService {
2014
+ constructor() {
2015
+ this.loggerService = inject(TYPES.loggerService);
2016
+ this.getRuntimeInfo = async () => {
2017
+ this.loggerService.log("runtimeMockService getRuntimeInfo");
2018
+ return await READ_RUNTIME_INFO_FN();
2019
+ };
2020
+ }
2021
+ }
2022
+
1988
2023
  class PerformanceViewService {
1989
2024
  constructor() {
1990
2025
  this.loggerService = inject(TYPES.loggerService);
@@ -2110,6 +2145,36 @@ class SetupViewService {
2110
2145
  }
2111
2146
  }
2112
2147
 
2148
+ class RuntimeViewService {
2149
+ constructor() {
2150
+ this.loggerService = inject(TYPES.loggerService);
2151
+ this.runtimeMockService = inject(TYPES.runtimeMockService);
2152
+ this.getRuntimeInfo = async () => {
2153
+ this.loggerService.log("runtimeViewService getRuntimeInfo");
2154
+ if (CC_ENABLE_MOCK) {
2155
+ return await this.runtimeMockService.getRuntimeInfo();
2156
+ }
2157
+ const [backtestItem] = await Backtest.list();
2158
+ const [liveItem] = await Live.list();
2159
+ if (backtestItem) {
2160
+ return await lib.runtimeMetaService.getRuntimeInfo(backtestItem.symbol, {
2161
+ strategyName: backtestItem.strategyName,
2162
+ exchangeName: backtestItem.exchangeName,
2163
+ frameName: backtestItem.frameName,
2164
+ }, true);
2165
+ }
2166
+ if (liveItem) {
2167
+ return await lib.runtimeMetaService.getRuntimeInfo(liveItem.symbol, {
2168
+ strategyName: liveItem.strategyName,
2169
+ exchangeName: liveItem.exchangeName,
2170
+ frameName: "",
2171
+ }, false);
2172
+ }
2173
+ return null;
2174
+ };
2175
+ }
2176
+ }
2177
+
2113
2178
  {
2114
2179
  provide(TYPES.loggerService, () => new LoggerService());
2115
2180
  provide(TYPES.exchangeService, () => new ExchangeService());
@@ -2136,6 +2201,7 @@ class SetupViewService {
2136
2201
  provide(TYPES.performanceMockService, () => new PerformanceMockService());
2137
2202
  provide(TYPES.environmentMockService, () => new EnvironmentMockService());
2138
2203
  provide(TYPES.setupMockService, () => new SetupMockService());
2204
+ provide(TYPES.runtimeMockService, () => new RuntimeMockService());
2139
2205
  }
2140
2206
  {
2141
2207
  provide(TYPES.notificationViewService, () => new NotificationViewService());
@@ -2150,6 +2216,7 @@ class SetupViewService {
2150
2216
  provide(TYPES.performanceViewService, () => new PerformanceViewService());
2151
2217
  provide(TYPES.environmentViewService, () => new EnvironmentViewService());
2152
2218
  provide(TYPES.setupViewService, () => new SetupViewService());
2219
+ provide(TYPES.runtimeViewService, () => new RuntimeViewService());
2153
2220
  }
2154
2221
 
2155
2222
  const baseServices = {
@@ -2178,6 +2245,7 @@ const mockServices = {
2178
2245
  performanceMockService: inject(TYPES.performanceMockService),
2179
2246
  environmentMockService: inject(TYPES.environmentMockService),
2180
2247
  setupMockService: inject(TYPES.setupMockService),
2248
+ runtimeMockService: inject(TYPES.runtimeMockService),
2181
2249
  };
2182
2250
  const viewServices = {
2183
2251
  notificationViewService: inject(TYPES.notificationViewService),
@@ -2192,6 +2260,7 @@ const viewServices = {
2192
2260
  performanceViewService: inject(TYPES.performanceViewService),
2193
2261
  environmentViewService: inject(TYPES.environmentViewService),
2194
2262
  setupViewService: inject(TYPES.setupViewService),
2263
+ runtimeViewService: inject(TYPES.runtimeViewService),
2195
2264
  };
2196
2265
  const ioc = {
2197
2266
  ...baseServices,
@@ -2931,6 +3000,35 @@ router$b.post("/api/v1/mock/environment_data", async (req, res) => {
2931
3000
  });
2932
3001
  }
2933
3002
  });
3003
+ // RuntimeMockService endpoints
3004
+ router$b.post("/api/v1/mock/runtime_info", async (req, res) => {
3005
+ try {
3006
+ const request = await micro.json(req);
3007
+ const { requestId, serviceName } = request;
3008
+ const data = await ioc.runtimeMockService.getRuntimeInfo();
3009
+ const result = {
3010
+ data,
3011
+ status: "ok",
3012
+ error: "",
3013
+ requestId,
3014
+ serviceName,
3015
+ };
3016
+ ioc.loggerService.log("/api/v1/mock/runtime_info ok", {
3017
+ request,
3018
+ result: omit(result, "data"),
3019
+ });
3020
+ return await micro.send(res, 200, result);
3021
+ }
3022
+ catch (error) {
3023
+ ioc.loggerService.log("/api/v1/mock/runtime_info error", {
3024
+ error: errorData(error),
3025
+ });
3026
+ return await micro.send(res, 200, {
3027
+ status: "error",
3028
+ error: getErrorMessage(error),
3029
+ });
3030
+ }
3031
+ });
2934
3032
 
2935
3033
  const router$a = Router({
2936
3034
  params: true,
@@ -3661,6 +3759,35 @@ router$a.post("/api/v1/view/environment_data", async (req, res) => {
3661
3759
  });
3662
3760
  }
3663
3761
  });
3762
+ // RuntimeViewService endpoints
3763
+ router$a.post("/api/v1/view/runtime_info", async (req, res) => {
3764
+ try {
3765
+ const request = await micro.json(req);
3766
+ const { requestId, serviceName } = request;
3767
+ const data = await ioc.runtimeViewService.getRuntimeInfo();
3768
+ const result = {
3769
+ data,
3770
+ status: "ok",
3771
+ error: "",
3772
+ requestId,
3773
+ serviceName,
3774
+ };
3775
+ ioc.loggerService.log("/api/v1/view/runtime_info ok", {
3776
+ request,
3777
+ result: omit(result, "data"),
3778
+ });
3779
+ return await micro.send(res, 200, result);
3780
+ }
3781
+ catch (error) {
3782
+ ioc.loggerService.log("/api/v1/view/runtime_info error", {
3783
+ error: errorData(error),
3784
+ });
3785
+ return await micro.send(res, 200, {
3786
+ status: "error",
3787
+ error: getErrorMessage(error),
3788
+ });
3789
+ }
3790
+ });
3664
3791
 
3665
3792
  const require$1 = createRequire(import.meta.url);
3666
3793
  function getModulesPath() {