@backtest-kit/ui 7.8.0 → 8.1.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 (38) hide show
  1. package/build/index.cjs +439 -6
  2. package/build/index.mjs +440 -7
  3. package/build/modules/frontend/build/assets/{Article-Z1gwQi4C.js → Article-CSnuOtt-.js} +1 -1
  4. package/build/modules/frontend/build/assets/{Background-DS1gKl45.js → Background-D1mqn4gC.js} +1 -1
  5. package/build/modules/frontend/build/assets/{IconPhoto-BitDk5sL.js → IconPhoto-CVGPKzLi.js} +1 -1
  6. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-BT0IHVDD.js → KeyboardArrowLeft-C-M8f-Ur.js} +1 -1
  7. package/build/modules/frontend/build/assets/PictureAsPdfOutlined-CZkqJLpJ.js +1 -0
  8. package/build/modules/frontend/build/assets/{Refresh-BgupECvn.js → Refresh-CtGZrED0.js} +1 -1
  9. package/build/modules/frontend/build/assets/emitters-Br6yILIn.js +1 -0
  10. package/build/modules/frontend/build/assets/hasRouteMatch-DGBSTuX4.js +1 -0
  11. package/build/modules/frontend/build/assets/{html2canvas-CxpxaxUC.js → html2canvas-DlSSsS0f.js} +1 -1
  12. package/build/modules/frontend/build/assets/{index-9YHmY3Zv.js → index-4KQpRnrd.js} +1 -1
  13. package/build/modules/frontend/build/assets/index-B4Q-NOtD.js +1 -0
  14. package/build/modules/frontend/build/assets/index-BHEHgIB5.js +1 -0
  15. package/build/modules/frontend/build/assets/index-Bdcw-1Ng.js +1 -0
  16. package/build/modules/frontend/build/assets/{index-C4dzv30q.js → index-Bj-wHWIg.js} +1 -1
  17. package/build/modules/frontend/build/assets/{index-nfZ8sdZp.js → index-C89D7bRW.js} +1 -1
  18. package/build/modules/frontend/build/assets/index-C_cnWIeH.js +1 -0
  19. package/build/modules/frontend/build/assets/index-CnKAzZmr.js +1 -0
  20. package/build/modules/frontend/build/assets/{index-DzrwP4k5.js → index-D7dmwadC.js} +56 -56
  21. package/build/modules/frontend/build/assets/index-D9ArSAzF.js +1 -0
  22. package/build/modules/frontend/build/assets/{index-CnRuFJIf.js → index-DGlc-QFZ.js} +1 -1
  23. package/build/modules/frontend/build/assets/index-k7MV_uNi.js +1 -0
  24. package/build/modules/frontend/build/assets/index-zr1XroNq.js +1 -0
  25. package/build/modules/frontend/build/assets/{index.es-Du6U2Hyj.js → index.es-CuYxvewv.js} +1 -1
  26. package/build/modules/frontend/build/index.html +1 -1
  27. package/package.json +3 -3
  28. package/types.d.ts +41 -0
  29. package/build/modules/frontend/build/assets/emitters-BJfdDGbd.js +0 -1
  30. package/build/modules/frontend/build/assets/hasRouteMatch-CcXyiBjV.js +0 -1
  31. package/build/modules/frontend/build/assets/index-1kyziIc7.js +0 -1
  32. package/build/modules/frontend/build/assets/index-3ZYgMfYi.js +0 -1
  33. package/build/modules/frontend/build/assets/index-BR0aHfoe.js +0 -1
  34. package/build/modules/frontend/build/assets/index-Bg2qm7TJ.js +0 -1
  35. package/build/modules/frontend/build/assets/index-C8Wdopwt.js +0 -1
  36. package/build/modules/frontend/build/assets/index-CWErSuod.js +0 -1
  37. package/build/modules/frontend/build/assets/index-J3hGIAw0.js +0 -1
  38. package/build/modules/frontend/build/assets/markdownit-SQF1Xc8y.js +0 -1
package/build/index.mjs CHANGED
@@ -6,7 +6,7 @@ import finalhandler from 'finalhandler';
6
6
  import serveHandler from 'serve-handler';
7
7
  import os from 'os';
8
8
  import { createActivator } from 'di-kit';
9
- import { alignToInterval, Exchange, listExchangeSchema, Backtest, Live, Notification, Storage, Log, lib, Heat, Strategy, Breakeven, Risk, Partial, HighestProfit, MaxDrawdown, Schedule, Performance, Sync, Walker, StorageLive, StorageBacktest } from 'backtest-kit';
9
+ import { alignToInterval, Exchange, listExchangeSchema, Backtest, Live, Notification, Storage, Log, lib, Heat, Strategy, Breakeven, Risk, Partial, HighestProfit, MaxDrawdown, Schedule, Performance, Sync, Walker, StorageLive, StorageBacktest, Broker, Dump, Markdown, Memory, Recent, Report, State, getConfig } from 'backtest-kit';
10
10
  import fs, { readdir, readFile } from 'fs/promises';
11
11
  import path, { join, dirname } from 'path';
12
12
  import mime from 'mime-types';
@@ -17,6 +17,8 @@ import { existsSync } from 'fs';
17
17
  const CC_WWWROOT_PATH = process.env.CC_WWWROOT_PATH || "";
18
18
  const CC_WWWROOT_HOST = process.env.CC_WWWROOT_HOST || "0.0.0.0";
19
19
  const CC_WWWROOT_PORT = parseInt(process.env.CC_WWWROOT_PORT) || 60050;
20
+ const CC_TELEGRAM_CHANNEL = process.env.CC_TELEGRAM_CHANNEL || "";
21
+ const CC_QUICKCHART_HOST = process.env.CC_QUICKCHART_HOST || "";
20
22
  const CC_ENABLE_MOCK = !!parseInt(process.env.CC_ENABLE_MOCK) || false;
21
23
 
22
24
  const serveSubject = new BehaviorSubject();
@@ -76,6 +78,9 @@ const mockServices$1 = {
76
78
  explorerMockService: Symbol("explorerMockService"),
77
79
  signalMockService: Symbol("signalMockService"),
78
80
  heatMockService: Symbol("heatMockService"),
81
+ performanceMockService: Symbol("performanceMockService"),
82
+ environmentMockService: Symbol("environmentMockService"),
83
+ setupMockService: Symbol("setupMockService"),
79
84
  };
80
85
  const viewServices$1 = {
81
86
  notificationViewService: Symbol("notificationViewService"),
@@ -87,6 +92,9 @@ const viewServices$1 = {
87
92
  explorerViewService: Symbol("explorerViewService"),
88
93
  signalViewService: Symbol("signalViewService"),
89
94
  heatViewService: Symbol("heatViewService"),
95
+ performanceViewService: Symbol("performanceViewService"),
96
+ environmentViewService: Symbol("environmentViewService"),
97
+ setupViewService: Symbol("setupViewService"),
90
98
  };
91
99
  const TYPES = {
92
100
  ...baseServices$1,
@@ -767,14 +775,14 @@ class SignalMockService {
767
775
  }
768
776
  }
769
777
 
770
- const MOCK_DATA_PATH = "./mock/heat.json";
771
- const MOCK_REPORT_PATH = "./mock/heat-report.md";
778
+ const MOCK_DATA_PATH$3 = "./mock/heat.json";
779
+ const MOCK_REPORT_PATH$1 = "./mock/heat-report.md";
772
780
  const READ_HEAT_DATA_FN = singleshot(async () => {
773
- const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
781
+ const data = await fs.readFile(MOCK_DATA_PATH$3, "utf-8");
774
782
  return JSON.parse(data);
775
783
  });
776
784
  const READ_HEAT_REPORT_FN = singleshot(async () => {
777
- return await fs.readFile(MOCK_REPORT_PATH, "utf-8");
785
+ return await fs.readFile(MOCK_REPORT_PATH$1, "utf-8");
778
786
  });
779
787
  class HeatMockService {
780
788
  constructor() {
@@ -1215,7 +1223,7 @@ class StatusViewService {
1215
1223
  portfolioTotalPnl: currentHeat.portfolioTotalPnl,
1216
1224
  portfolioSharpeRatio: currentHeat.portfolioSharpeRatio,
1217
1225
  portfolioTotalTrades: currentHeat.portfolioTotalTrades,
1218
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades }) => ({
1226
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor }) => ({
1219
1227
  symbol,
1220
1228
  totalPnl,
1221
1229
  winRate,
@@ -1223,6 +1231,9 @@ class StatusViewService {
1223
1231
  maxDrawdown,
1224
1232
  expectancy,
1225
1233
  totalTrades,
1234
+ sortinoRatio,
1235
+ calmarRatio,
1236
+ recoveryFactor,
1226
1237
  })),
1227
1238
  backtest: true,
1228
1239
  };
@@ -1245,7 +1256,7 @@ class StatusViewService {
1245
1256
  portfolioTotalPnl: currentHeat.portfolioTotalPnl,
1246
1257
  portfolioSharpeRatio: currentHeat.portfolioSharpeRatio,
1247
1258
  portfolioTotalTrades: currentHeat.portfolioTotalTrades,
1248
- symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades }) => ({
1259
+ symbols: currentHeat.symbols.map(({ symbol, totalPnl, winRate, profitFactor, maxDrawdown, expectancy, totalTrades, sortinoRatio, calmarRatio, recoveryFactor }) => ({
1249
1260
  symbol,
1250
1261
  totalPnl,
1251
1262
  winRate,
@@ -1253,6 +1264,9 @@ class StatusViewService {
1253
1264
  maxDrawdown,
1254
1265
  expectancy,
1255
1266
  totalTrades,
1267
+ sortinoRatio,
1268
+ calmarRatio,
1269
+ recoveryFactor,
1256
1270
  })),
1257
1271
  backtest: false,
1258
1272
  };
@@ -1833,6 +1847,183 @@ class LiveMetaService {
1833
1847
  }
1834
1848
  }
1835
1849
 
1850
+ const MOCK_DATA_PATH$2 = "./mock/performance.json";
1851
+ const MOCK_REPORT_PATH = "./mock/performance-report.md";
1852
+ const READ_PERFORMANCE_DATA_FN = singleshot(async () => {
1853
+ const data = await fs.readFile(MOCK_DATA_PATH$2, "utf-8");
1854
+ return JSON.parse(data);
1855
+ });
1856
+ const READ_PERFORMANCE_REPORT_FN = singleshot(async () => {
1857
+ return await fs.readFile(MOCK_REPORT_PATH, "utf-8");
1858
+ });
1859
+ class PerformanceMockService {
1860
+ constructor() {
1861
+ this.loggerService = inject(TYPES.loggerService);
1862
+ this.getPerformanceData = async () => {
1863
+ this.loggerService.log("performanceMockService getPerformanceData");
1864
+ return await READ_PERFORMANCE_DATA_FN();
1865
+ };
1866
+ this.getPerformanceReport = async () => {
1867
+ this.loggerService.log("performanceMockService getPerformanceReport");
1868
+ return await READ_PERFORMANCE_REPORT_FN();
1869
+ };
1870
+ }
1871
+ }
1872
+
1873
+ const MOCK_DATA_PATH$1 = "./mock/environment.json";
1874
+ const READ_ENVIRONMENT_DATA_FN = singleshot(async () => {
1875
+ const data = await fs.readFile(MOCK_DATA_PATH$1, "utf-8");
1876
+ return JSON.parse(data);
1877
+ });
1878
+ class EnvironmentMockService {
1879
+ constructor() {
1880
+ this.loggerService = inject(TYPES.loggerService);
1881
+ this.getEnvironmentData = async () => {
1882
+ this.loggerService.log("environmentMockService getEnvironmentData");
1883
+ return await READ_ENVIRONMENT_DATA_FN();
1884
+ };
1885
+ }
1886
+ }
1887
+
1888
+ const MOCK_DATA_PATH = "./mock/setup.json";
1889
+ const READ_SETUP_DATA_FN = singleshot(async () => {
1890
+ const data = await fs.readFile(MOCK_DATA_PATH, "utf-8");
1891
+ return JSON.parse(data);
1892
+ });
1893
+ class SetupMockService {
1894
+ constructor() {
1895
+ this.loggerService = inject(TYPES.loggerService);
1896
+ this.getSetupData = async () => {
1897
+ this.loggerService.log("setupMockService getSetupData");
1898
+ return await READ_SETUP_DATA_FN();
1899
+ };
1900
+ }
1901
+ }
1902
+
1903
+ class PerformanceViewService {
1904
+ constructor() {
1905
+ this.loggerService = inject(TYPES.loggerService);
1906
+ this.performanceMockService = inject(TYPES.performanceMockService);
1907
+ this.getPerformanceData = async () => {
1908
+ this.loggerService.log("performanceViewService getPerformanceData");
1909
+ if (CC_ENABLE_MOCK) {
1910
+ return await this.performanceMockService.getPerformanceData();
1911
+ }
1912
+ const [backtestItem] = await Backtest.list();
1913
+ const [liveItem] = await Live.list();
1914
+ if (backtestItem) {
1915
+ return await Performance.getData(backtestItem.symbol, {
1916
+ strategyName: backtestItem.strategyName,
1917
+ exchangeName: backtestItem.exchangeName,
1918
+ frameName: backtestItem.frameName,
1919
+ }, true);
1920
+ }
1921
+ if (liveItem) {
1922
+ return await Performance.getData(liveItem.symbol, {
1923
+ strategyName: liveItem.strategyName,
1924
+ exchangeName: liveItem.exchangeName,
1925
+ frameName: "",
1926
+ }, false);
1927
+ }
1928
+ return null;
1929
+ };
1930
+ this.getPerformanceReport = async () => {
1931
+ this.loggerService.log("performanceViewService getPerformanceReport");
1932
+ if (CC_ENABLE_MOCK) {
1933
+ return await this.performanceMockService.getPerformanceReport();
1934
+ }
1935
+ const [backtestItem] = await Backtest.list();
1936
+ const [liveItem] = await Live.list();
1937
+ if (backtestItem) {
1938
+ return await Performance.getReport(backtestItem.symbol, {
1939
+ strategyName: backtestItem.strategyName,
1940
+ exchangeName: backtestItem.exchangeName,
1941
+ frameName: backtestItem.frameName,
1942
+ }, true);
1943
+ }
1944
+ if (liveItem) {
1945
+ return await Performance.getReport(liveItem.symbol, {
1946
+ strategyName: liveItem.strategyName,
1947
+ exchangeName: liveItem.exchangeName,
1948
+ frameName: "",
1949
+ }, false);
1950
+ }
1951
+ return null;
1952
+ };
1953
+ }
1954
+ }
1955
+
1956
+ class EnvironmentViewService {
1957
+ constructor() {
1958
+ this.loggerService = inject(TYPES.loggerService);
1959
+ this.enviromentMockService = inject(TYPES.environmentMockService);
1960
+ this.getEnvironmentData = async () => {
1961
+ this.loggerService.log("environmentViewService getEnvironmentData");
1962
+ if (CC_ENABLE_MOCK) {
1963
+ return await this.enviromentMockService.getEnvironmentData();
1964
+ }
1965
+ return {
1966
+ quickchart_host: CC_QUICKCHART_HOST,
1967
+ telegram_channel: CC_TELEGRAM_CHANNEL,
1968
+ wwwroot_host: CC_WWWROOT_HOST,
1969
+ wwwroot_path: CC_WWWROOT_PATH,
1970
+ wwwroot_port: CC_WWWROOT_PORT,
1971
+ };
1972
+ };
1973
+ }
1974
+ }
1975
+
1976
+ const GET_MODE_FN = async () => {
1977
+ const [backtestTarget = null] = await Backtest.list();
1978
+ if (backtestTarget) {
1979
+ return "backtest";
1980
+ }
1981
+ const [liveTarget = null] = await Live.list();
1982
+ if (liveTarget) {
1983
+ return "live";
1984
+ }
1985
+ return "none";
1986
+ };
1987
+ class SetupViewService {
1988
+ constructor() {
1989
+ this.loggerService = inject(TYPES.loggerService);
1990
+ this.setupMockService = inject(TYPES.setupMockService);
1991
+ this.getSetupData = async () => {
1992
+ this.loggerService.log("setupViewService getSetupData");
1993
+ if (CC_ENABLE_MOCK) {
1994
+ return await this.setupMockService.getSetupData();
1995
+ }
1996
+ const broker_enabled = Broker.enable.hasValue();
1997
+ const dump_enabled = Dump.enable.hasValue();
1998
+ const markdown_enabled = Markdown.enable.hasValue();
1999
+ const memory_enabled = Memory.enable.hasValue();
2000
+ const notification_enabled = Notification.enable.hasValue();
2001
+ const recent_enabled = Recent.enable.hasValue();
2002
+ const report_enabled = Report.enable.hasValue();
2003
+ const state_enabled = State.enable.hasValue();
2004
+ const storage_enabled = Storage.enable.hasValue();
2005
+ const running_mode = await GET_MODE_FN();
2006
+ const config = await getConfig();
2007
+ const enable_long = config.CC_ENABLE_LONG_SIGNAL;
2008
+ const enable_short = config.CC_ENABLE_SHORT_SIGNAL;
2009
+ return {
2010
+ broker_enabled,
2011
+ dump_enabled,
2012
+ markdown_enabled,
2013
+ memory_enabled,
2014
+ notification_enabled,
2015
+ recent_enabled,
2016
+ report_enabled,
2017
+ state_enabled,
2018
+ storage_enabled,
2019
+ running_mode,
2020
+ enable_long,
2021
+ enable_short,
2022
+ };
2023
+ };
2024
+ }
2025
+ }
2026
+
1836
2027
  {
1837
2028
  provide(TYPES.loggerService, () => new LoggerService());
1838
2029
  provide(TYPES.exchangeService, () => new ExchangeService());
@@ -1856,6 +2047,9 @@ class LiveMetaService {
1856
2047
  provide(TYPES.explorerMockService, () => new ExplorerMockService());
1857
2048
  provide(TYPES.signalMockService, () => new SignalMockService());
1858
2049
  provide(TYPES.heatMockService, () => new HeatMockService());
2050
+ provide(TYPES.performanceMockService, () => new PerformanceMockService());
2051
+ provide(TYPES.environmentMockService, () => new EnvironmentMockService());
2052
+ provide(TYPES.setupMockService, () => new SetupMockService());
1859
2053
  }
1860
2054
  {
1861
2055
  provide(TYPES.notificationViewService, () => new NotificationViewService());
@@ -1867,6 +2061,9 @@ class LiveMetaService {
1867
2061
  provide(TYPES.explorerViewService, () => new ExplorerViewService());
1868
2062
  provide(TYPES.signalViewService, () => new SignalViewService());
1869
2063
  provide(TYPES.heatViewService, () => new HeatViewService());
2064
+ provide(TYPES.performanceViewService, () => new PerformanceViewService());
2065
+ provide(TYPES.environmentViewService, () => new EnvironmentViewService());
2066
+ provide(TYPES.setupViewService, () => new SetupViewService());
1870
2067
  }
1871
2068
 
1872
2069
  const baseServices = {
@@ -1892,6 +2089,9 @@ const mockServices = {
1892
2089
  explorerMockService: inject(TYPES.explorerMockService),
1893
2090
  signalMockService: inject(TYPES.signalMockService),
1894
2091
  heatMockService: inject(TYPES.heatMockService),
2092
+ performanceMockService: inject(TYPES.performanceMockService),
2093
+ environmentMockService: inject(TYPES.environmentMockService),
2094
+ setupMockService: inject(TYPES.setupMockService),
1895
2095
  };
1896
2096
  const viewServices = {
1897
2097
  notificationViewService: inject(TYPES.notificationViewService),
@@ -1903,6 +2103,9 @@ const viewServices = {
1903
2103
  explorerViewService: inject(TYPES.explorerViewService),
1904
2104
  signalViewService: inject(TYPES.signalViewService),
1905
2105
  heatViewService: inject(TYPES.heatViewService),
2106
+ performanceViewService: inject(TYPES.performanceViewService),
2107
+ environmentViewService: inject(TYPES.environmentViewService),
2108
+ setupViewService: inject(TYPES.setupViewService),
1906
2109
  };
1907
2110
  const ioc = {
1908
2111
  ...baseServices,
@@ -1916,6 +2119,35 @@ init();
1916
2119
  const router$a = Router({
1917
2120
  params: true,
1918
2121
  });
2122
+ // SetupMockService endpoints
2123
+ router$a.post("/api/v1/mock/setup_data", async (req, res) => {
2124
+ try {
2125
+ const request = await micro.json(req);
2126
+ const { requestId, serviceName } = request;
2127
+ const data = await ioc.setupMockService.getSetupData();
2128
+ const result = {
2129
+ data,
2130
+ status: "ok",
2131
+ error: "",
2132
+ requestId,
2133
+ serviceName,
2134
+ };
2135
+ ioc.loggerService.log("/api/v1/mock/setup_data ok", {
2136
+ request,
2137
+ result: omit(result, "data"),
2138
+ });
2139
+ return await micro.send(res, 200, result);
2140
+ }
2141
+ catch (error) {
2142
+ ioc.loggerService.log("/api/v1/mock/setup_data error", {
2143
+ error: errorData(error),
2144
+ });
2145
+ return await micro.send(res, 200, {
2146
+ status: "error",
2147
+ error: getErrorMessage(error),
2148
+ });
2149
+ }
2150
+ });
1919
2151
  // ExchangeMockService endpoints
1920
2152
  router$a.post("/api/v1/mock/candles_signal", async (req, res) => {
1921
2153
  try {
@@ -2527,10 +2759,125 @@ router$a.post("/api/v1/mock/status_info", async (req, res) => {
2527
2759
  });
2528
2760
  }
2529
2761
  });
2762
+ // PerformanceMockService endpoints
2763
+ router$a.post("/api/v1/mock/performance_data", async (req, res) => {
2764
+ try {
2765
+ const request = await micro.json(req);
2766
+ const { requestId, serviceName } = request;
2767
+ const data = await ioc.performanceMockService.getPerformanceData();
2768
+ const result = {
2769
+ data,
2770
+ status: "ok",
2771
+ error: "",
2772
+ requestId,
2773
+ serviceName,
2774
+ };
2775
+ ioc.loggerService.log("/api/v1/mock/performance_data ok", {
2776
+ request,
2777
+ result: omit(result, "data"),
2778
+ });
2779
+ return await micro.send(res, 200, result);
2780
+ }
2781
+ catch (error) {
2782
+ ioc.loggerService.log("/api/v1/mock/performance_data error", {
2783
+ error: errorData(error),
2784
+ });
2785
+ return await micro.send(res, 200, {
2786
+ status: "error",
2787
+ error: getErrorMessage(error),
2788
+ });
2789
+ }
2790
+ });
2791
+ router$a.post("/api/v1/mock/performance_report", async (req, res) => {
2792
+ try {
2793
+ const request = await micro.json(req);
2794
+ const { requestId, serviceName } = request;
2795
+ const data = await ioc.performanceMockService.getPerformanceReport();
2796
+ const result = {
2797
+ data,
2798
+ status: "ok",
2799
+ error: "",
2800
+ requestId,
2801
+ serviceName,
2802
+ };
2803
+ ioc.loggerService.log("/api/v1/mock/performance_report ok", {
2804
+ request,
2805
+ result: omit(result, "data"),
2806
+ });
2807
+ return await micro.send(res, 200, result);
2808
+ }
2809
+ catch (error) {
2810
+ ioc.loggerService.log("/api/v1/mock/performance_report error", {
2811
+ error: errorData(error),
2812
+ });
2813
+ return await micro.send(res, 200, {
2814
+ status: "error",
2815
+ error: getErrorMessage(error),
2816
+ });
2817
+ }
2818
+ });
2819
+ // EnvironmentMockService endpoints
2820
+ router$a.post("/api/v1/mock/environment_data", async (req, res) => {
2821
+ try {
2822
+ const request = await micro.json(req);
2823
+ const { requestId, serviceName } = request;
2824
+ const data = await ioc.environmentMockService.getEnvironmentData();
2825
+ const result = {
2826
+ data,
2827
+ status: "ok",
2828
+ error: "",
2829
+ requestId,
2830
+ serviceName,
2831
+ };
2832
+ ioc.loggerService.log("/api/v1/mock/environment_data ok", {
2833
+ request,
2834
+ result: omit(result, "data"),
2835
+ });
2836
+ return await micro.send(res, 200, result);
2837
+ }
2838
+ catch (error) {
2839
+ ioc.loggerService.log("/api/v1/mock/environment_data error", {
2840
+ error: errorData(error),
2841
+ });
2842
+ return await micro.send(res, 200, {
2843
+ status: "error",
2844
+ error: getErrorMessage(error),
2845
+ });
2846
+ }
2847
+ });
2530
2848
 
2531
2849
  const router$9 = Router({
2532
2850
  params: true,
2533
2851
  });
2852
+ // SetupViewService endpoints
2853
+ router$9.post("/api/v1/view/setup_data", async (req, res) => {
2854
+ try {
2855
+ const request = await micro.json(req);
2856
+ const { requestId, serviceName } = request;
2857
+ const data = await ioc.setupViewService.getSetupData();
2858
+ const result = {
2859
+ data,
2860
+ status: "ok",
2861
+ error: "",
2862
+ requestId,
2863
+ serviceName,
2864
+ };
2865
+ ioc.loggerService.log("/api/v1/view/setup_data ok", {
2866
+ request,
2867
+ result: omit(result, "data"),
2868
+ });
2869
+ return await micro.send(res, 200, result);
2870
+ }
2871
+ catch (error) {
2872
+ ioc.loggerService.log("/api/v1/view/setup_data error", {
2873
+ error: errorData(error),
2874
+ });
2875
+ return await micro.send(res, 200, {
2876
+ status: "error",
2877
+ error: getErrorMessage(error),
2878
+ });
2879
+ }
2880
+ });
2534
2881
  // ExchangeViewService endpoints
2535
2882
  router$9.post("/api/v1/view/candles_signal", async (req, res) => {
2536
2883
  try {
@@ -3142,6 +3489,92 @@ router$9.post("/api/v1/view/status_info", async (req, res) => {
3142
3489
  });
3143
3490
  }
3144
3491
  });
3492
+ // PerformanceViewService endpoints
3493
+ router$9.post("/api/v1/view/performance_data", async (req, res) => {
3494
+ try {
3495
+ const request = await micro.json(req);
3496
+ const { requestId, serviceName } = request;
3497
+ const data = await ioc.performanceViewService.getPerformanceData();
3498
+ const result = {
3499
+ data,
3500
+ status: "ok",
3501
+ error: "",
3502
+ requestId,
3503
+ serviceName,
3504
+ };
3505
+ ioc.loggerService.log("/api/v1/view/performance_data ok", {
3506
+ request,
3507
+ result: omit(result, "data"),
3508
+ });
3509
+ return await micro.send(res, 200, result);
3510
+ }
3511
+ catch (error) {
3512
+ ioc.loggerService.log("/api/v1/view/performance_data error", {
3513
+ error: errorData(error),
3514
+ });
3515
+ return await micro.send(res, 200, {
3516
+ status: "error",
3517
+ error: getErrorMessage(error),
3518
+ });
3519
+ }
3520
+ });
3521
+ router$9.post("/api/v1/view/performance_report", async (req, res) => {
3522
+ try {
3523
+ const request = await micro.json(req);
3524
+ const { requestId, serviceName } = request;
3525
+ const data = await ioc.performanceViewService.getPerformanceReport();
3526
+ const result = {
3527
+ data,
3528
+ status: "ok",
3529
+ error: "",
3530
+ requestId,
3531
+ serviceName,
3532
+ };
3533
+ ioc.loggerService.log("/api/v1/view/performance_report ok", {
3534
+ request,
3535
+ result: omit(result, "data"),
3536
+ });
3537
+ return await micro.send(res, 200, result);
3538
+ }
3539
+ catch (error) {
3540
+ ioc.loggerService.log("/api/v1/view/performance_report error", {
3541
+ error: errorData(error),
3542
+ });
3543
+ return await micro.send(res, 200, {
3544
+ status: "error",
3545
+ error: getErrorMessage(error),
3546
+ });
3547
+ }
3548
+ });
3549
+ // EnvironmentViewService endpoints
3550
+ router$9.post("/api/v1/view/environment_data", async (req, res) => {
3551
+ try {
3552
+ const request = await micro.json(req);
3553
+ const { requestId, serviceName } = request;
3554
+ const data = await ioc.environmentViewService.getEnvironmentData();
3555
+ const result = {
3556
+ data,
3557
+ status: "ok",
3558
+ error: "",
3559
+ requestId,
3560
+ serviceName,
3561
+ };
3562
+ ioc.loggerService.log("/api/v1/view/environment_data ok", {
3563
+ request,
3564
+ result: omit(result, "data"),
3565
+ });
3566
+ return await micro.send(res, 200, result);
3567
+ }
3568
+ catch (error) {
3569
+ ioc.loggerService.log("/api/v1/view/environment_data error", {
3570
+ error: errorData(error),
3571
+ });
3572
+ return await micro.send(res, 200, {
3573
+ status: "error",
3574
+ error: getErrorMessage(error),
3575
+ });
3576
+ }
3577
+ });
3145
3578
 
3146
3579
  const require$1 = createRequire(import.meta.url);
3147
3580
  function getModulesPath() {
@@ -1 +1 @@
1
- import{b as c,f as v}from"./index-DzrwP4k5.js";const h=c(v("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}),"Article");export{h as A};
1
+ import{b as c,f as v}from"./index-D7dmwadC.js";const h=c(v("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}),"Article");export{h as A};
@@ -1 +1 @@
1
- import{f as n,S as o}from"./index-DzrwP4k5.js";const d=()=>n(o,{children:"\n body {\n background-color: #ddd !important;\n }\n "});export{d as B};
1
+ import{f as n,S as o}from"./index-D7dmwadC.js";const d=()=>n(o,{children:"\n body {\n background-color: #ddd !important;\n }\n "});export{d as B};
@@ -1 +1 @@
1
- import{f as e,i as t,B as r,J as s}from"./index-DzrwP4k5.js";const o=({className:o,symbol:i,style:a,sx:n})=>e(s,{children:async()=>{try{const s=(await t.symbolGlobalService.getSymbolMap())[i],l=(null==s?void 0:s.logo)||(null==s?void 0:s.icon),c=(null==s?void 0:s.color)||"#ccc";return e(r,{className:o,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:l?"transparent":c,...n},style:a,children:l?e("img",{loading:"lazy",crossOrigin:"anonymous",src:l,alt:i,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"},onError:e=>{const t=e.target,r=t.parentElement;r&&(r.style.background=c,t.style.display="none")}}):e(r,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}catch(s){return e(r,{className:o,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"#ccc",...n},style:a,children:e(r,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}}});export{o as I};
1
+ import{f as e,i as t,B as r,J as s}from"./index-D7dmwadC.js";const o=({className:o,symbol:i,style:a,sx:n})=>e(s,{children:async()=>{try{const s=(await t.symbolGlobalService.getSymbolMap())[i],l=(null==s?void 0:s.logo)||(null==s?void 0:s.icon),c=(null==s?void 0:s.color)||"#ccc";return e(r,{className:o,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:l?"transparent":c,...n},style:a,children:l?e("img",{loading:"lazy",crossOrigin:"anonymous",src:l,alt:i,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"},onError:e=>{const t=e.target,r=t.parentElement;r&&(r.style.background=c,t.style.display="none")}}):e(r,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}catch(s){return e(r,{className:o,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"#ccc",...n},style:a,children:e(r,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}}});export{o as I};
@@ -1 +1 @@
1
- import{b as o,f as r}from"./index-DzrwP4k5.js";const a=o(r("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"}),"KeyboardArrowLeft");export{a as K};
1
+ import{b as o,f as r}from"./index-D7dmwadC.js";const a=o(r("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"}),"KeyboardArrowLeft");export{a as K};
@@ -0,0 +1 @@
1
+ import{b as h,f as c}from"./index-D7dmwadC.js";const v=h(c("path",{d:"M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12zM4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm12 6V9c0-.55-.45-1-1-1h-2v5h2c.55 0 1-.45 1-1zm-2-3h1v3h-1V9zm4 2h1v-1h-1V9h1V8h-2v5h1zm-8 0h1c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9v5h1v-2zm0-2h1v1h-1V9z"}),"PictureAsPdfOutlined");export{v as P};
@@ -1 +1 @@
1
- import{bq as e,d as t,r as a,_ as s,f as i,br as n,j as o,bs as r,k as d,bt as m,g as u,u as p,s as x,b as c}from"./index-DzrwP4k5.js";const h=e(),b=["className","component","disableGutters","fixed","maxWidth","classes"],l=m(),f=h("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${o(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),g=e=>r({props:e,name:"MuiContainer",defaultTheme:l});const W=function(e={}){const{createStyledComponent:r=f,useThemeProps:m=g,componentName:p="MuiContainer"}=e,x=r(({theme:e,ownerState:a})=>t({width:"100%",marginLeft:"auto",boxSizing:"border-box",marginRight:"auto",display:"block"},!a.disableGutters&&{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up("sm")]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}),({theme:e,ownerState:t})=>t.fixed&&Object.keys(e.breakpoints.values).reduce((t,a)=>{const s=a,i=e.breakpoints.values[s];return 0!==i&&(t[e.breakpoints.up(s)]={maxWidth:`${i}${e.breakpoints.unit}`}),t},{}),({theme:e,ownerState:a})=>t({},"xs"===a.maxWidth&&{[e.breakpoints.up("xs")]:{maxWidth:Math.max(e.breakpoints.values.xs,444)}},a.maxWidth&&"xs"!==a.maxWidth&&{[e.breakpoints.up(a.maxWidth)]:{maxWidth:`${e.breakpoints.values[a.maxWidth]}${e.breakpoints.unit}`}}));return a.forwardRef(function(e,a){const r=m(e),{className:c,component:h="div",disableGutters:l=!1,fixed:f=!1,maxWidth:g="lg"}=r,W=s(r,b),k=t({},r,{component:h,disableGutters:l,fixed:f,maxWidth:g}),S=((e,t)=>{const{classes:a,fixed:s,disableGutters:i,maxWidth:n}=e,r={root:["root",n&&`maxWidth${o(String(n))}`,s&&"fixed",i&&"disableGutters"]};return d(r,e=>u(t,e),a)})(k,p);return i(x,t({as:h,ownerState:k,className:n(S.root,c),ref:a},W))})}({createStyledComponent:x("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${o(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),useThemeProps:e=>p({props:e,name:"MuiContainer"})}),k=c(i("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),"Refresh");export{W as C,k as R};
1
+ import{bt as e,d as t,r as a,_ as s,f as i,bu as n,j as o,bv as r,k as d,bw as m,g as u,u as p,s as x,b as c}from"./index-D7dmwadC.js";const h=e(),b=["className","component","disableGutters","fixed","maxWidth","classes"],l=m(),f=h("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${o(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),g=e=>r({props:e,name:"MuiContainer",defaultTheme:l});const W=function(e={}){const{createStyledComponent:r=f,useThemeProps:m=g,componentName:p="MuiContainer"}=e,x=r(({theme:e,ownerState:a})=>t({width:"100%",marginLeft:"auto",boxSizing:"border-box",marginRight:"auto",display:"block"},!a.disableGutters&&{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up("sm")]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}),({theme:e,ownerState:t})=>t.fixed&&Object.keys(e.breakpoints.values).reduce((t,a)=>{const s=a,i=e.breakpoints.values[s];return 0!==i&&(t[e.breakpoints.up(s)]={maxWidth:`${i}${e.breakpoints.unit}`}),t},{}),({theme:e,ownerState:a})=>t({},"xs"===a.maxWidth&&{[e.breakpoints.up("xs")]:{maxWidth:Math.max(e.breakpoints.values.xs,444)}},a.maxWidth&&"xs"!==a.maxWidth&&{[e.breakpoints.up(a.maxWidth)]:{maxWidth:`${e.breakpoints.values[a.maxWidth]}${e.breakpoints.unit}`}}));return a.forwardRef(function(e,a){const r=m(e),{className:c,component:h="div",disableGutters:l=!1,fixed:f=!1,maxWidth:g="lg"}=r,W=s(r,b),k=t({},r,{component:h,disableGutters:l,fixed:f,maxWidth:g}),v=((e,t)=>{const{classes:a,fixed:s,disableGutters:i,maxWidth:n}=e,r={root:["root",n&&`maxWidth${o(String(n))}`,s&&"fixed",i&&"disableGutters"]};return d(r,e=>u(t,e),a)})(k,p);return i(x,t({as:h,ownerState:k,className:n(v.root,c),ref:a},W))})}({createStyledComponent:x("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${o(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),useThemeProps:e=>p({props:e,name:"MuiContainer"})}),k=c(i("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),"Refresh");export{W as C,k as R};
@@ -0,0 +1 @@
1
+ import{Z as o}from"./index-D7dmwadC.js";const r=new o;export{r};
@@ -0,0 +1 @@
1
+ import{i as a,br as e,bs as r}from"./index-D7dmwadC.js";const s=(s,t=a.routerService.location.pathname)=>!!e(r.filter(({path:a})=>s.includes(a)),t);export{s as h};
@@ -1 +1 @@
1
- import{bu as e,bw as t}from"./index-DzrwP4k5.js";function r(e,t){for(var r=0;r<t.length;r++){const o=t[r];if("string"!=typeof o&&!Array.isArray(o))for(const t in o)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(o,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var o=t();const n=r({__proto__:null,default:e(o)},[o]);export{n as h};
1
+ import{bx as e,by as t}from"./index-D7dmwadC.js";function r(e,t){for(var r=0;r<t.length;r++){const o=t[r];if("string"!=typeof o&&!Array.isArray(o))for(const t in o)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(o,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var o=t();const n=r({__proto__:null,default:e(o)},[o]);export{n as h};
@@ -1 +1 @@
1
- import{b as a,f as e,aM as t,B as o,N as r,az as n,T as i,ae as s,K as c,F as l,aA as d,P as h,aB as p,aO as u,aP as w,ap as b,X as f,i as x,aq as g,$ as v,aw as y,v as m,w as S,aQ as k,aN as L,D as j,z}from"./index-DzrwP4k5.js";import{A}from"./Article-Z1gwQi4C.js";import{C as R,R as H}from"./Refresh-BgupECvn.js";import{K as B}from"./KeyboardArrowLeft-BT0IHVDD.js";const C=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),M=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(C,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(A,{sx:t})}},D=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:M(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),E=[{action:"download-action",label:"Download",icon:()=>e(z,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(z,{icon:H,color:"#4caf50"})}],F=[{type:S.Link,action:"back-action",label:e(B,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:k,action:"search-action",label:"Search"}],N=new f,O=()=>{const[a,o]=w(""),{data:r,hasMore:n,loading:i,onSkip:s}=b({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:N}),c=v(r),{execute:l}=y(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:F,actions:E,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await N.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void N.next();o(""),N.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:L,hasMore:n,children:r.map(a=>e(D,{data:a,sx:{mb:1}},a.id))})]})};export{O as LogPage,O as default};
1
+ import{b as a,f as e,aQ as t,B as o,N as r,$ as n,T as i,al as s,K as c,F as l,aE as d,P as h,aF as p,aS as u,aT as w,av as b,Z as f,i as x,aw as g,a8 as v,aB as y,v as m,w as S,aU as k,aR as L,D as j,z}from"./index-D7dmwadC.js";import{A}from"./Article-CSnuOtt-.js";import{C as R,R as H}from"./Refresh-CtGZrED0.js";import{K as B}from"./KeyboardArrowLeft-C-M8f-Ur.js";const C=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),E=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(C,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(A,{sx:t})}},F=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:E(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),D=[{action:"download-action",label:"Download",icon:()=>e(z,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(z,{icon:H,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(B,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:k,action:"search-action",label:"Search"}],U=new f,Y=()=>{const[a,o]=w(""),{data:r,hasMore:n,loading:i,onSkip:s}=b({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:U}),c=v(r),{execute:l}=y(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:M,actions:D,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await U.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void U.next();o(""),U.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:L,hasMore:n,children:r.map(a=>e(F,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
@@ -0,0 +1 @@
1
+ import{f as t,T as e,L as a,bj as o,H as n,P as i,p as l,X as r,i as c,Y as s,v as d,w as p,y as m,z as y,A as h,E as u,G as w,x,b0 as f,q as b,a6 as g}from"./index-D7dmwadC.js";import{h as v}from"./hasRouteMatch-DGBSTuX4.js";import{r as R}from"./emitters-Br6yILIn.js";import{I as S}from"./IconPhoto-CVGPKzLi.js";import{P as F}from"./PictureAsPdfOutlined-CZkqJLpJ.js";import{C as L,R as A}from"./Refresh-CtGZrED0.js";import{K as N}from"./KeyboardArrowLeft-C-M8f-Ur.js";const j=l()(t=>({root:{position:"relative",background:"#0001",overflow:"clip"},header:{position:"absolute",top:0,left:0,height:"48px",width:"calc(100% - 16px)",display:"flex",alignItems:"center",justifyContent:"space-between",marginLeft:"8px",marginRight:"8px"},container:{marginTop:"48px",width:"100%",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center"},content:{display:"flex",width:"100%",padding:t.spacing(1),paddingBottom:t.spacing(2),gap:10,flexDirection:"column"},avatar:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"128px",minWidth:"128px"}})),k=[{type:n.Text,name:"totalPnl",title:"Total PNL",compute:t=>null!==t.totalPnl?`${t.totalPnl.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"winRate",title:"Win Rate",compute:t=>null!==t.winRate?`${t.winRate.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"profitFactor",title:"Profit Factor",compute:t=>null!==t.profitFactor?t.profitFactor.toFixed(2):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"maxDrawdown",title:"Max Drawdown",compute:t=>null!==t.maxDrawdown?`${t.maxDrawdown.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"expectancy",title:"Expectancy",compute:t=>null!==t.expectancy?`${t.expectancy.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"sortinoRatio",title:"Sortino Ratio",compute:t=>null!==t.sortinoRatio?t.sortinoRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"calmarRatio",title:"Calmar Ratio",compute:t=>null!==t.calmarRatio?t.calmarRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"recoveryFactor",title:"Recovery Factor",compute:t=>null!==t.recoveryFactor?t.recoveryFactor.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"totalTrades",title:"Trades",readonly:!0}],D=({row:n})=>{const{classes:l}=j();return t(i,{className:l.root,children:[t("div",{className:l.header,children:t(e,{variant:"h6",sx:{opacity:.8},children:`${a.bullet} ${n.symbol}`})}),t("div",{className:l.container,children:t("div",{className:l.content,children:[t("div",{className:l.avatar,children:t(S,{symbol:n.symbol,sx:{width:128,height:128}})}),t(o,{handler:()=>n,fields:k,sx:{mb:2}})]})})]})},T=[{type:p.Link,action:"back-action",label:t(N,{sx:{display:"block"}})},{type:p.Link,action:"back-action",label:"Dashboard"},{type:p.Link,action:"back-action",label:"Heatmap"},{type:p.Button,action:"download-pdf",label:"Download PDF",icon:F}],P=[{action:"download-json",label:"Download JSON",icon:()=>t(y,{icon:m,color:"#4caf50"})},{action:"download-markdown",label:"Download Markdown",icon:()=>t(y,{icon:h,color:"#4caf50"})},{action:"download-pdf",label:"Download PDF",icon:()=>t(y,{icon:u,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>t(y,{icon:A,color:"#4caf50"})}],C=[{id:"main",element:()=>{const[e,{loading:a,execute:o}]=r(async()=>(e=>{if(!e.length)return[{type:n.Typography,typoVariant:"h6",placeholder:"No data",sx:{textAlign:"center",opacity:.5,mt:4}}];const a=e.map(e=>({type:n.Group,desktopColumns:"4",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",child:{type:n.Component,element:()=>t(D,{row:e})}}));return a.length>2?a:[{type:n.Center,sx:t=>({[t.breakpoints.up("lg")]:{"@media (min-height: 900px)":{height:"calc(100dvh - 165px)","& > *":{transform:"translateY(-56px)"}}}}),fields:a}]})((await c.heatViewService.getStrategyHeatData()).symbols),{onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1)});s(()=>R.subscribe(o));return t(L,{children:[t(d,{items:T,actions:P,onAction:async t=>{"back-action"===t&&c.routerService.push("/"),"update-now"===t&&await R.next(),"download-markdown"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport(),e=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(e);c.layoutService.downloadFile(a,`heat_${Date.now()}.md`)})(),"download-pdf"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport();await b(t)})(),"download-json"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatData(),e=JSON.stringify(t,null,2),a=new Blob([e],{type:"text/plain"}),o=URL.createObjectURL(a);c.layoutService.downloadFile(o,`heat_${Date.now()}.md`)})()}}),!e||a?t(w,{sx:{height:"calc(100dvh - 165px)"}}):t(f,{withScrollbar:!0,sx:{height:"calc(100dvh - 165px)"},hideOverflowX:!0,children:t(x,{fields:e})})]})},isActive:t=>v(["/heat"],t)}],$=({id:e})=>t(g,{history:c.routerService,onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1),routes:C,params:{id:e}});export{$ as HeatPage,$ as default};