@backtest-kit/ui 3.3.2 → 3.5.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/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 { Exchange, Notification, Storage, listenSignal } from 'backtest-kit';
9
+ import { Exchange, Notification, Storage, Log, listenSignal } from 'backtest-kit';
10
10
  import fs, { readdir, readFile } from 'fs/promises';
11
11
  import path, { join, dirname } from 'path';
12
12
  import { createRequire } from 'module';
@@ -64,11 +64,13 @@ const mockServices$1 = {
64
64
  notificationMockService: Symbol("notificationMockService"),
65
65
  storageMockService: Symbol("storageMockService"),
66
66
  exchangeMockService: Symbol("exchangeMockService"),
67
+ logMockService: Symbol("logMockService"),
67
68
  };
68
69
  const viewServices$1 = {
69
70
  notificationViewService: Symbol("notificationViewService"),
70
71
  storageViewService: Symbol("storageViewService"),
71
72
  exchangeViewService: Symbol("exchangeViewService"),
73
+ logViewService: Symbol("logViewService"),
72
74
  };
73
75
  const TYPES = {
74
76
  ...baseServices$1,
@@ -171,25 +173,25 @@ class LoggerService {
171
173
  }
172
174
  }
173
175
 
174
- const MOCK_PATH$1 = "./mock/notifications.json";
176
+ const MOCK_PATH$2 = "./mock/notifications.json";
175
177
  const READ_NOTIFICATION_LIST_FN = singleshot(async () => {
176
- const data = await fs.readFile(MOCK_PATH$1, "utf-8");
178
+ const data = await fs.readFile(MOCK_PATH$2, "utf-8");
177
179
  return JSON.parse(data);
178
180
  });
179
- const DEFAULT_LIMIT$1 = 25;
180
- const DEFAULT_OFFSET$1 = 0;
181
- const CREATE_FILTER_LIST_FN$1 = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
181
+ const DEFAULT_LIMIT$3 = 25;
182
+ const DEFAULT_OFFSET$3 = 0;
183
+ const CREATE_FILTER_LIST_FN$3 = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
182
184
  class NotificationMockService {
183
185
  constructor() {
184
186
  this.loggerService = inject(TYPES.loggerService);
185
- this.findByFilter = async (filterData, limit = DEFAULT_LIMIT$1, offset = DEFAULT_OFFSET$1) => {
187
+ this.findByFilter = async (filterData, limit = DEFAULT_LIMIT$3, offset = DEFAULT_OFFSET$3) => {
186
188
  this.loggerService.log("notificationMockService findByFilter", {
187
189
  filterData,
188
190
  limit,
189
191
  offset,
190
192
  });
191
193
  const iter = pickDocuments(limit, offset);
192
- const filterList = CREATE_FILTER_LIST_FN$1(filterData);
194
+ const filterList = CREATE_FILTER_LIST_FN$3(filterData);
193
195
  for (const notification of await this.getList()) {
194
196
  let isOk = true;
195
197
  for (const filterFn of filterList) {
@@ -233,9 +235,9 @@ class NotificationMockService {
233
235
  }
234
236
  }
235
237
 
236
- const MOCK_PATH = "./mock/db";
238
+ const MOCK_PATH$1 = "./mock/db";
237
239
  const READ_BACKTEST_STORAGE_FN = singleshot(async () => {
238
- const dbPath = join(process.cwd(), MOCK_PATH);
240
+ const dbPath = join(process.cwd(), MOCK_PATH$1);
239
241
  const files = await readdir(dbPath);
240
242
  const signals = [];
241
243
  for (const file of files) {
@@ -296,14 +298,64 @@ class ExchangeMockService {
296
298
  }
297
299
  }
298
300
 
299
- const DEFAULT_LIMIT = 25;
300
- const DEFAULT_OFFSET = 0;
301
- const CREATE_FILTER_LIST_FN = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
301
+ const MOCK_PATH = "./mock/logs.json";
302
+ const READ_LOG_LIST_FN = singleshot(async () => {
303
+ const data = await fs.readFile(MOCK_PATH, "utf-8");
304
+ return JSON.parse(data);
305
+ });
306
+ const DEFAULT_LIMIT$2 = 25;
307
+ const DEFAULT_OFFSET$2 = 0;
308
+ const CREATE_FILTER_LIST_FN$2 = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
309
+ class LogMockService {
310
+ constructor() {
311
+ this.loggerService = inject(TYPES.loggerService);
312
+ this.findByFilter = async (filterData, limit = DEFAULT_LIMIT$2, offset = DEFAULT_OFFSET$2) => {
313
+ this.loggerService.log("logMockService findByFilter", {
314
+ filterData,
315
+ limit,
316
+ offset,
317
+ });
318
+ const iter = pickDocuments(limit, offset);
319
+ const filterList = CREATE_FILTER_LIST_FN$2(filterData);
320
+ for (const entry of await this.getList()) {
321
+ let isOk = true;
322
+ for (const filterFn of filterList) {
323
+ isOk = isOk && filterFn(entry);
324
+ }
325
+ if (!isOk) {
326
+ continue;
327
+ }
328
+ if (iter([entry]).done) {
329
+ break;
330
+ }
331
+ }
332
+ return iter().rows;
333
+ };
334
+ this.getList = async () => {
335
+ this.loggerService.log("logMockService getList");
336
+ const logList = [];
337
+ for (const entry of await READ_LOG_LIST_FN()) {
338
+ logList.push(entry);
339
+ }
340
+ logList.sort((a, b) => b.timestamp - a.timestamp);
341
+ return logList;
342
+ };
343
+ this.getOne = async (id) => {
344
+ this.loggerService.log("logMockService getOne");
345
+ const logList = await this.getList();
346
+ return logList.find((item) => item.id === id) ?? null;
347
+ };
348
+ }
349
+ }
350
+
351
+ const DEFAULT_LIMIT$1 = 25;
352
+ const DEFAULT_OFFSET$1 = 0;
353
+ const CREATE_FILTER_LIST_FN$1 = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
302
354
  class NotificationViewService {
303
355
  constructor() {
304
356
  this.loggerService = inject(TYPES.loggerService);
305
357
  this.notificationMockService = inject(TYPES.notificationMockService);
306
- this.findByFilter = async (filterData, limit = DEFAULT_LIMIT, offset = DEFAULT_OFFSET) => {
358
+ this.findByFilter = async (filterData, limit = DEFAULT_LIMIT$1, offset = DEFAULT_OFFSET$1) => {
307
359
  this.loggerService.log("notificationViewService findByFilter", {
308
360
  filterData,
309
361
  limit,
@@ -313,7 +365,7 @@ class NotificationViewService {
313
365
  return await this.notificationMockService.findByFilter(filterData, limit, offset);
314
366
  }
315
367
  const iter = pickDocuments(limit, offset);
316
- const filterList = CREATE_FILTER_LIST_FN(filterData);
368
+ const filterList = CREATE_FILTER_LIST_FN$1(filterData);
317
369
  for (const notification of await this.getList()) {
318
370
  let isOk = true;
319
371
  for (const filterFn of filterList) {
@@ -470,6 +522,61 @@ class ExchangeViewService {
470
522
  }
471
523
  }
472
524
 
525
+ const DEFAULT_LIMIT = 25;
526
+ const DEFAULT_OFFSET = 0;
527
+ const CREATE_FILTER_LIST_FN = (filterData) => Object.keys(filterData).map((key) => (row) => new RegExp(filterData[key], "i").test(row[key]));
528
+ class LogViewService {
529
+ constructor() {
530
+ this.loggerService = inject(TYPES.loggerService);
531
+ this.logMockService = inject(TYPES.logMockService);
532
+ this.findByFilter = async (filterData, limit = DEFAULT_LIMIT, offset = DEFAULT_OFFSET) => {
533
+ this.loggerService.log("logViewService findByFilter", {
534
+ filterData,
535
+ limit,
536
+ offset,
537
+ });
538
+ if (CC_ENABLE_MOCK) {
539
+ return await this.logMockService.findByFilter(filterData, limit, offset);
540
+ }
541
+ const iter = pickDocuments(limit, offset);
542
+ const filterList = CREATE_FILTER_LIST_FN(filterData);
543
+ for (const entry of await this.getList()) {
544
+ let isOk = true;
545
+ for (const filterFn of filterList) {
546
+ isOk = isOk && filterFn(entry);
547
+ }
548
+ if (!isOk) {
549
+ continue;
550
+ }
551
+ if (iter([entry]).done) {
552
+ break;
553
+ }
554
+ }
555
+ return iter().rows;
556
+ };
557
+ this.getList = async () => {
558
+ this.loggerService.log("logViewService getList");
559
+ if (CC_ENABLE_MOCK) {
560
+ return await this.logMockService.getList();
561
+ }
562
+ const logList = await Log.getList();
563
+ logList.sort((a, b) => b.timestamp - a.timestamp);
564
+ return logList;
565
+ };
566
+ this.getOne = async (id) => {
567
+ this.loggerService.log("logViewService getOne", { id });
568
+ if (CC_ENABLE_MOCK) {
569
+ return await this.logMockService.getOne(id);
570
+ }
571
+ const logList = await this.getList();
572
+ return logList.find((item) => item.id === id) ?? null;
573
+ };
574
+ this.init = singleshot(async () => {
575
+ this.loggerService.log("logViewService init");
576
+ });
577
+ }
578
+ }
579
+
473
580
  const symbol_list = [
474
581
  {
475
582
  icon: "/icon/btc.png",
@@ -653,11 +760,13 @@ class PriceConnectionService {
653
760
  provide(TYPES.notificationMockService, () => new NotificationMockService());
654
761
  provide(TYPES.storageMockService, () => new StorageMockService());
655
762
  provide(TYPES.exchangeMockService, () => new ExchangeMockService());
763
+ provide(TYPES.logMockService, () => new LogMockService());
656
764
  }
657
765
  {
658
766
  provide(TYPES.notificationViewService, () => new NotificationViewService());
659
767
  provide(TYPES.storageViewService, () => new StorageViewService());
660
768
  provide(TYPES.exchangeViewService, () => new ExchangeViewService());
769
+ provide(TYPES.logViewService, () => new LogViewService());
661
770
  }
662
771
 
663
772
  const baseServices = {
@@ -675,11 +784,13 @@ const mockServices = {
675
784
  notificationMockService: inject(TYPES.notificationMockService),
676
785
  storageMockService: inject(TYPES.storageMockService),
677
786
  exchangeMockService: inject(TYPES.exchangeMockService),
787
+ logMockService: inject(TYPES.logMockService),
678
788
  };
679
789
  const viewServices = {
680
790
  notificationViewService: inject(TYPES.notificationViewService),
681
791
  storageViewService: inject(TYPES.storageViewService),
682
792
  exchangeViewService: inject(TYPES.exchangeViewService),
793
+ logViewService: inject(TYPES.logViewService),
683
794
  };
684
795
  const ioc = {
685
796
  ...baseServices,
@@ -927,6 +1038,92 @@ router$6.post("/api/v1/mock/storage_list/backtest", async (req, res) => {
927
1038
  });
928
1039
  }
929
1040
  });
1041
+ // LogMockService endpoints
1042
+ router$6.post("/api/v1/mock/log_list", async (req, res) => {
1043
+ try {
1044
+ const request = await micro.json(req);
1045
+ const { requestId, serviceName } = request;
1046
+ const data = await ioc.logMockService.getList();
1047
+ const result = {
1048
+ data,
1049
+ status: "ok",
1050
+ error: "",
1051
+ requestId,
1052
+ serviceName,
1053
+ };
1054
+ ioc.loggerService.log("/api/v1/mock/log_list ok", {
1055
+ request,
1056
+ result: omit(result, "data"),
1057
+ });
1058
+ return await micro.send(res, 200, result);
1059
+ }
1060
+ catch (error) {
1061
+ ioc.loggerService.log("/api/v1/mock/log_list error", {
1062
+ error: errorData(error),
1063
+ });
1064
+ return await micro.send(res, 200, {
1065
+ status: "error",
1066
+ error: getErrorMessage(error),
1067
+ });
1068
+ }
1069
+ });
1070
+ router$6.post("/api/v1/mock/log_one/:id", async (req, res) => {
1071
+ try {
1072
+ const request = await micro.json(req);
1073
+ const { requestId, serviceName } = request;
1074
+ const id = req.params.id;
1075
+ const data = await ioc.logMockService.getOne(id);
1076
+ const result = {
1077
+ data,
1078
+ status: "ok",
1079
+ error: "",
1080
+ requestId,
1081
+ serviceName,
1082
+ };
1083
+ ioc.loggerService.log("/api/v1/mock/log_one/:id ok", {
1084
+ request,
1085
+ result: omit(result, "data"),
1086
+ });
1087
+ return await micro.send(res, 200, result);
1088
+ }
1089
+ catch (error) {
1090
+ ioc.loggerService.log("/api/v1/mock/log_one/:id error", {
1091
+ error: errorData(error),
1092
+ });
1093
+ return await micro.send(res, 200, {
1094
+ status: "error",
1095
+ error: getErrorMessage(error),
1096
+ });
1097
+ }
1098
+ });
1099
+ router$6.post("/api/v1/mock/log_filter", async (req, res) => {
1100
+ try {
1101
+ const request = await micro.json(req);
1102
+ const { requestId, serviceName, filterData, limit, offset } = request;
1103
+ const data = await ioc.logMockService.findByFilter(filterData, limit, offset);
1104
+ const result = {
1105
+ data,
1106
+ status: "ok",
1107
+ error: "",
1108
+ requestId,
1109
+ serviceName,
1110
+ };
1111
+ ioc.loggerService.log("/api/v1/mock/log_filter ok", {
1112
+ request,
1113
+ result: omit(result, "data"),
1114
+ });
1115
+ return await micro.send(res, 200, result);
1116
+ }
1117
+ catch (error) {
1118
+ ioc.loggerService.log("/api/v1/mock/log_filter error", {
1119
+ error: errorData(error),
1120
+ });
1121
+ return await micro.send(res, 200, {
1122
+ status: "error",
1123
+ error: getErrorMessage(error),
1124
+ });
1125
+ }
1126
+ });
930
1127
 
931
1128
  const router$5 = Router({
932
1129
  params: true,
@@ -1165,6 +1362,92 @@ router$5.post("/api/v1/view/storage_list/backtest", async (req, res) => {
1165
1362
  });
1166
1363
  }
1167
1364
  });
1365
+ // LogViewService endpoints
1366
+ router$5.post("/api/v1/view/log_list", async (req, res) => {
1367
+ try {
1368
+ const request = await micro.json(req);
1369
+ const { requestId, serviceName } = request;
1370
+ const data = await ioc.logViewService.getList();
1371
+ const result = {
1372
+ data,
1373
+ status: "ok",
1374
+ error: "",
1375
+ requestId,
1376
+ serviceName,
1377
+ };
1378
+ ioc.loggerService.log("/api/v1/view/log_list ok", {
1379
+ request,
1380
+ result: omit(result, "data"),
1381
+ });
1382
+ return await micro.send(res, 200, result);
1383
+ }
1384
+ catch (error) {
1385
+ ioc.loggerService.log("/api/v1/view/log_list error", {
1386
+ error: errorData(error),
1387
+ });
1388
+ return await micro.send(res, 200, {
1389
+ status: "error",
1390
+ error: getErrorMessage(error),
1391
+ });
1392
+ }
1393
+ });
1394
+ router$5.post("/api/v1/view/log_one/:id", async (req, res) => {
1395
+ try {
1396
+ const request = await micro.json(req);
1397
+ const { requestId, serviceName } = request;
1398
+ const id = req.params.id;
1399
+ const data = await ioc.logViewService.getOne(id);
1400
+ const result = {
1401
+ data,
1402
+ status: "ok",
1403
+ error: "",
1404
+ requestId,
1405
+ serviceName,
1406
+ };
1407
+ ioc.loggerService.log("/api/v1/view/log_one/:id ok", {
1408
+ request,
1409
+ result: omit(result, "data"),
1410
+ });
1411
+ return await micro.send(res, 200, result);
1412
+ }
1413
+ catch (error) {
1414
+ ioc.loggerService.log("/api/v1/view/log_one/:id error", {
1415
+ error: errorData(error),
1416
+ });
1417
+ return await micro.send(res, 200, {
1418
+ status: "error",
1419
+ error: getErrorMessage(error),
1420
+ });
1421
+ }
1422
+ });
1423
+ router$5.post("/api/v1/view/log_filter", async (req, res) => {
1424
+ try {
1425
+ const request = await micro.json(req);
1426
+ const { requestId, serviceName, filterData, limit, offset } = request;
1427
+ const data = await ioc.logViewService.findByFilter(filterData, limit, offset);
1428
+ const result = {
1429
+ data,
1430
+ status: "ok",
1431
+ error: "",
1432
+ requestId,
1433
+ serviceName,
1434
+ };
1435
+ ioc.loggerService.log("/api/v1/view/log_filter ok", {
1436
+ request,
1437
+ result: omit(result, "data"),
1438
+ });
1439
+ return await micro.send(res, 200, result);
1440
+ }
1441
+ catch (error) {
1442
+ ioc.loggerService.log("/api/v1/view/log_filter error", {
1443
+ error: errorData(error),
1444
+ });
1445
+ return await micro.send(res, 200, {
1446
+ status: "error",
1447
+ error: getErrorMessage(error),
1448
+ });
1449
+ }
1450
+ });
1168
1451
 
1169
1452
  const require$1 = createRequire(import.meta.url);
1170
1453
  function getModulesPath() {
@@ -0,0 +1 @@
1
+ import{f as e,i as t,B as r,J as s}from"./index-zBOUVifH.js";const a=({className:a,symbol:i,style:o,sx:n})=>e(s,{children:async()=>{try{const s=(await t.symbolGlobalService.getSymbolMap())[i],l=null==s?void 0:s.icon,c=(null==s?void 0:s.color)||"#ccc";return e(r,{className:a,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:l?"transparent":c,...n},style:o,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:a,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"#ccc",...n},style:o,children:e(r,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}}});export{a as I};
@@ -0,0 +1 @@
1
+ import{c as o,f as r}from"./index-zBOUVifH.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{ae as e,af as t,w as a,ag as s,f as i,ah as n,ai as o,aj as r,ak as d,al as m,am as u,an as p,ao as x,c}from"./index-zBOUVifH.js";const h=e(),l=["className","component","disableGutters","fixed","maxWidth","classes"],b=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:b});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:b=!1,fixed:f=!1,maxWidth:g="lg"}=r,W=s(r,l),k=t({},r,{component:h,disableGutters:b,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};
@@ -0,0 +1 @@
1
+ import{c as e,f as a,a as t,Z as o,q as n,D as i,I as s,b as r,k as l,i as c,z as d,X as p,R as h,J as u,L as b,d as m,e as g,B as y,T as v,v as x,g as f,l as k,h as w,j as S,m as L,n as R,o as z,p as F,r as j,F as D,S as P,x as W,s as $}from"./index-zBOUVifH.js";import{R as C,C as T}from"./Refresh-CEQ_0ArO.js";import{I as A}from"./IconPhoto-h4iJtQiA.js";const B=e(a("path",{d:"M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"}),"Dashboard"),H=e(a("path",{d:"M3 10h11v2H3v-2zm0-2h11V6H3v2zm0 8h7v-2H3v2zm15.01-3.13.71-.71c.39-.39 1.02-.39 1.41 0l.71.71c.39.39.39 1.02 0 1.41l-.71.71-2.12-2.12zm-.71.71-5.3 5.3V21h2.12l5.3-5.3-2.12-2.12z"}),"EditNote"),M=new t,N=[{type:o.Link,action:"back-action",label:"Main"},{type:o.Link,action:"back-action",label:"Dashboard"}],V=[{action:"download-action",label:"Download",icon:()=>a(s,{icon:i,color:"#4caf50"})},{divider:!0},{action:"dashboard-action",label:"Dashboard",icon:()=>a(s,{icon:B,color:"#4caf50"})},{action:"logs-action",label:"Logs",icon:()=>a(s,{icon:H,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>a(s,{icon:C,color:"#4caf50"})}],I=()=>a(n,{items:N,actions:V,onAction:M.next});const O=({data:{type:e},setLoading:t})=>{const{elementRef:o,size:n}=r({closest:".MuiContainer-root",compute:e=>(e.height-=150,e)}),[i,{loading:s,execute:P}]=l(async()=>{if("live"===e){return(await c.storageViewService.listSignalLive()).filter(e=>"closed"===e.status)}return(await c.storageViewService.listSignalBacktest()).filter(e=>"closed"===e.status)},{onLoadStart:()=>t(!0),onLoadEnd:()=>t(!1),deps:[e]}),W=d(i),$=d(e);p(()=>M.subscribe(e=>{if("update-now"===e&&P(),"download-action"===e){const e=new Blob([JSON.stringify(W.current,null,2)],{type:"application/json"}),a=URL.createObjectURL(e);c.layoutService.downloadFile(a,`signals_${$.current}_${Date.now()}.json`)}"dashboard-action"===e&&c.routerService.push(`/dashboard/${$.current}`),"logs-action"===e&&c.routerService.push("/logs")}));const C=h.useMemo(()=>i?i.reduce((e,a)=>(e[a.symbol]||(e[a.symbol]=[]),e[a.symbol].push(a),e),{}):{},[i]),T=e=>{const t=C[e]||[];return t.length?a(D,{children:t.map((t,o)=>{return a(L,{sx:{background:e=>o%2==1?z(e.palette.getContrastText(e.palette.background.paper),.02):void 0},onClick:()=>c.layoutService.pickSignal(t.id),children:[a(m,{primary:a(y,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center"},children:[a(v,{variant:"body2",component:"span",sx:{fontWeight:"bold",px:1,py:.5,borderRadius:1,background:"long"===t.position?"#1976D2":"#F57C00",color:"white"},children:"long"===t.position?"LONG":"SHORT"}),a(v,{variant:"body2",component:"span",sx:{fontWeight:"medium"},children:[a(y,{component:"span",sx:{color:"text.secondary",mr:.5},children:"Entry:"}),R(t.priceOpen),"$"]}),a(v,{variant:"body2",component:"span",sx:{fontWeight:"medium",color:"success.main"},children:[a(y,{component:"span",sx:{color:"text.secondary",mr:.5},children:"TP:"}),R(t.priceTakeProfit),"$"]}),a(v,{variant:"body2",component:"span",sx:{fontWeight:"medium",color:"error.main"},children:[a(y,{component:"span",sx:{color:"text.secondary",mr:.5},children:"SL:"}),R(t.priceStopLoss),"$"]}),"pnl"in t&&a(v,{variant:"body2",component:"span",sx:{fontWeight:"bold",px:1,py:.5,borderRadius:1,background:t.pnl.pnlPercentage>=0?z("#4caf50",.15):z("#f44336",.15),color:t.pnl.pnlPercentage>=0?"#2e7d32":"#c62828"},children:["PNL: ",t.pnl.pnlPercentage>=0?"+":"",t.pnl.pnlPercentage.toFixed(2),"%"]}),a(v,{variant:"caption",component:"span",sx:{px:1,py:.25,borderRadius:.5,background:"opened"===t.status?z("#4caf50",.2):"scheduled"===t.status?z("#ff9800",.2):"closed"===t.status?z("#9e9e9e",.2):z("#f44336",.2),color:"opened"===t.status?"#2e7d32":"scheduled"===t.status?"#e65100":"closed"===t.status?"#616161":"#c62828"},children:t.status})]}),secondary:a(v,{pt:.5,variant:"subtitle2",sx:{opacity:.5},children:(n=t.createdAt||t.pendingAt,new Date(n).toLocaleString([],{year:"numeric",month:"numeric",day:"numeric",hourCycle:"h24",hour:"2-digit",minute:"2-digit",second:"2-digit"}))})}),a(F,{disableRipple:!0,children:a(j,{})})]},`item-${e}-${t.id}`);var n})}):a(b,{children:a(m,{sx:{"& .MuiTypography-body2":{maxWidth:"435px"}},primary:"No signals",secondary:"Signals will be displayed here after they appear"})})};return s?null:a(w,{ref:o,sx:{width:"100%",maxHeight:n.height,overflowX:"hidden",overflowY:"auto",scrollbarWidth:"thin",bgcolor:"background.paper",position:"relative","& ul":{padding:0}},subheader:a("li",{}),children:a(u,{deps:[C],children:async()=>{const t=Object.keys(C),o=await c.symbolGlobalService.getSymbolMap();return t.length?t.map(e=>{var t,n,i;const s=null==(t=o[e])?void 0:t.color,r=(null==(n=C[e])?void 0:n.length)||0;return a("li",{children:a("ul",{children:[a(g,{sx:{background:(l=s,S(l,"#000000")>S(l,"#FFFFFF")?f(s,.1):k(s,.1)),color:"white !important",zIndex:9,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a(y,{sx:{position:"relative",paddingRight:"8px"},children:a(A,{symbol:e})}),(null==(i=o[e])?void 0:i.displayName)||e,a(y,{flex:1}),a(v,{variant:"body2",sx:{fontWeight:"medium"},children:x(r,{one:"Signal",two:"Signals",many:"Signals"})})]}),a(y,{sx:{marginTop:"16px",marginBottom:"16px"},children:T(e)})]})},`section-${e}`);var l}):a(b,{children:a(m,{primary:"No signals yet",secondary:"live"===e?"Live signals will be displayed here":"Backtest signals will be displayed here"})})}})})},E=()=>a(P,{children:"\n body {\n background-color: #ddd !important;\n }\n "}),G=$(),J=(e,a)=>e.some(e=>e.includes(a)),U=[{id:"backtest",element:O,isActive:e=>J(["/backtest"],e)},{id:"live",element:O,isActive:e=>J(["/live"],e)}],X=[{id:"backtest",label:"Backtest"},{id:"live",label:"Live"}],_=({symbol:e})=>{p(()=>G.replace("/backtest"));return a(T,{children:[a(W,{withScroll:!0,sx:{height:"calc(100vh - 105px)"},BeforePaper:I,onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1),routes:U,tabs:X,history:G,initialData:()=>({backtest:{type:"backtest"},live:{type:"live"}}),payload:()=>({symbol:e}),onTabChange:(e,a)=>{"backtest"===e&&a.replace("/backtest"),"live"===e&&a.replace("/live")}}),a(E,{})]})};export{_ as MainPage,_ as default};
@@ -0,0 +1 @@
1
+ import{c as e,f as t,i as o,Y as a,t as n,u as i,w as r,y as l,A as s,T as c,n as d,C as u,P as p,F as m,E as h,G as g,H as f,B as v,d as y,K as b,M as x,N as C,U as k,O as w,Q as S,V as L,W as P,_ as M,$ as N,a0 as R,I as D,J as T,a1 as $,p as j,a2 as B,a3 as V,a4 as I,k as A,a5 as O,X as z,a as E,q as F,Z as U,D as H,a6 as W}from"./index-zBOUVifH.js";import{I as G}from"./IconPhoto-h4iJtQiA.js";import{C as _,R as Y}from"./Refresh-CEQ_0ArO.js";import{K}from"./KeyboardArrowLeft-lQZO05jc.js";const q=e(t("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 10V8h-2v4H8l4 4 4-4h-3z"}),"ArrowCircleDown"),X=e(t("path",{d:"M12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0 2c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10zm-1-10v4h2v-4h3l-4-4-4 4h3z"}),"ArrowCircleUp"),J=e(t("path",{d:"M7.5 5.6 10 7 8.6 4.5 10 2 7.5 3.4 5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.9959.9959 0 0 0-1.41 0L1.29 18.96c-.39.39-.39 1.02 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05c.39-.39.39-1.02 0-1.41l-2.33-2.35zm-1.03 5.49-2.12-2.12 2.44-2.44 2.12 2.12-2.44 2.44z"}),"AutoFixHigh"),Q=e(t("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2z"}),"Circle"),Z=e(t("path",{d:"m6 2 .01 6L10 12l-3.99 4.01L6 22h12v-6l-4-4 4-3.99V2H6zm10 14.5V20H8v-3.5l4-4 4 4z"}),"HourglassTop"),ee=e(t("path",{d:"M21 6h-7.59l3.29-3.29L16 2l-4 4-4-4-.71.71L10.59 6H3c-1.1 0-2 .89-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.11-.9-2-2-2zm0 14H3V8h18v12zM9 10v8l7-4z"}),"LiveTv"),te=i(async e=>"live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),{key:([e])=>`${e}`,timeout:45e3}),oe=async(e,t)=>(await te(t)).filter(t=>"closed"===t.status&&t.symbol===e),ae=async(e,t)=>{const o=await oe(e,t);return{total:o.length,resolvedCount:o.filter(e=>e.pnl.pnlPercentage>0).length,rejectedCount:o.filter(e=>e.pnl.pnlPercentage<=0).length}},ne=async(e,t)=>{const o=await oe(e,t),a=e=>Math.abs(e.pnl.priceClose-e.originalPriceTakeProfit)/e.originalPriceTakeProfit<.005,n=e=>Math.abs(e.pnl.priceClose-e.originalPriceStopLoss)/e.originalPriceStopLoss<.005;return{resolvedTakeProfitCount:o.filter(e=>e.pnl.pnlPercentage>0&&a(e)).length,rejectedStopLossCount:o.filter(e=>e.pnl.pnlPercentage<=0&&n(e)).length,resolvedCloseCount:o.filter(e=>e.pnl.pnlPercentage>0&&!a(e)).length,rejectedCloseCount:o.filter(e=>e.pnl.pnlPercentage<=0&&!n(e)).length}},ie=async(e,t)=>{const o=await oe(e,t),i=new Map;for(const r of o){const e=a(n(r.updatedAt)),t=i.get(e)??{resolved:0,rejected:0};r.pnl.pnlPercentage>0?i.set(e,{...t,resolved:t.resolved+1}):i.set(e,{...t,rejected:t.rejected+1})}return Array.from(i.entries()).map(([e,{resolved:t,rejected:o}])=>({stamp:e,count:t+o,resolved:t,rejected:o}))},re=async(e,t)=>{const o=await oe(e,t),a="backtest"===t&&o.length?o.reduce((e,t)=>Math.max(e,t.updatedAt),0):Date.now(),i=n(a).startOf("day").valueOf(),r=i-864e5,l=i-6048e5,s=i-26784e5,c=e=>e.reduce((e,t)=>e+t.pnl.pnlPercentage,0),d=o.filter(e=>e.updatedAt>=i),u=o.filter(e=>e.updatedAt>=r&&e.updatedAt<i),p=o.filter(e=>e.updatedAt>=l),m=o.filter(e=>e.updatedAt>=s);return{symbol:e,todayRevenue:c(d),yesterdayRevenue:c(u),sevenDaysRevenue:c(p),thirtyOneDaysRevenue:c(m),todayCount:d.length,yesterdayCount:u.length,sevenDaysCount:p.length,thirtyOneDaysCount:m.length}};var le=(e=>(e.Red="#DD4049",e.Orange="#F3A43A",e.Green="#2EA96F",e.Blue="#2979ff",e.Violet="#d500f9",e))(le||{});const se=r.createContext(null),ce=({value:e,children:o})=>t(se.Provider,{value:e,children:o}),de=()=>r.useContext(se);var ue=(e=>(e.Semi="semi",e.Solid="solid",e.Unset="unset",e))(ue||{});const pe=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"stretch",whiteSpace:"nowrap",gap:"8px",overflow:"hidden",padding:"10px",borderTop:`1px solid ${e.palette.divider}`,"& > *":{flex:1}},solidBackground:{color:"#fff","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}},semiBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}}})),me=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=pe(),{footerLabel:i,backgroundMode:s=ue.Solid}=de(),c=r.useMemo(()=>({...o,...s===ue.Solid&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:l(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:i})},he=(e,t=2)=>{let o=1;for(let a=0;a<t;a++)o*=10;return Math.round(e*o)/o},ge=s()({root:{position:"relative",width:"100%",height:"0px"},container:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center"}}),fe=({caption:e})=>{const{classes:o}=ge();return t("div",{className:o.root,children:t("div",{className:o.container,children:t(c,{variant:"caption",sx:{opacity:.5,fontSize:12,textAlign:"center",padding:"0 8px"},children:e})})})},ve=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},solidBackground:{"& > :first-of-type":{color:"#fff",fontWeight:"bold"},"& > :last-of-type":{color:"#fff"}},unsetBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},semiBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},content:{display:"flex",alignItems:"baseline",flexDirection:"row",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),ye=u(e=>t("div",{className:e.v0,style:e.v1,children:[t("div",{className:e.v2,children:[e.v3,e.v4]}),e.v5]}),{name:"Content_1",portals:["v3","v4","v5"]}),be=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=ve(),{backgroundMode:i=ue.Solid,roundDigits:s=2,value:u,caption:p,valueUnit:m="Unit"}=de(),h=r.useMemo(()=>({...o,...i===ue.Solid&&{backgroundColor:a}}),[a,i,o]);return t(ye,{v0:l(e,n.root),v1:h,v2:l(n.content,{[n.solidBackground]:i===ue.Solid,[n.unsetBackground]:i===ue.Unset,[n.semiBackground]:i===ue.Semi}),v3:t(c,{fontWeight:"bold",children:d(he(u,s))}),v4:t(c,{children:m}),v5:!!p&&t(fe,{caption:p})})},xe=s()(e=>({root:{display:"flex",alignItems:"center",whiteSpace:"nowrap",fontWeight:700,fontSize:"18px",paddingLeft:"8px",gap:"8px",overflow:"hidden",borderBottom:`1px solid ${e.palette.divider}`},solidBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},semiBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,padding:"10px","& svg":{fill:e.palette.text.primary}}})),Ce=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=xe(),{headerLabel:i,backgroundMode:s=ue.Solid}=de(),c=r.useMemo(()=>({...o,...(s===ue.Solid||s===ue.Semi)&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:l(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:i})},ke=s()({root:{overflow:"hidden",height:"100%",width:"100%",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},click:{cursor:"pointer"},header:{minHeight:"36px"},content:{flex:1},footer:{minHeight:"32px"}}),we=({className:e,style:o})=>{const{classes:a}=ke(),{backgroundColor:n,onClick:i,footerLabel:r}=de();return t(p,{className:l(e,a.root,{[a.click]:!!i}),onClick:i,style:o,children:[t(Ce,{backgroundColor:n}),t(be,{backgroundColor:n,className:a.content}),!!r&&t(me,{backgroundColor:n,className:a.footer})]})},Se=r.memo(({className:e,style:o,...a})=>t(ce,{value:a,children:t(we,{className:e,style:o})})),Le=(e,{one:t,many:o,two:a=o})=>`${(()=>{if(0===e||e>=11&&e<20)return o;let n=e%10;return 0===n?o:1===n?t:n<5?a:o})()}`,Pe=r.createContext(null),Me=({value:e,children:o})=>t(Pe.Provider,{value:e,children:o}),Ne=()=>r.useContext(Pe),Re=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",paddingLeft:"20px",paddingRight:"20px",overflow:"hidden"},container:{flex:1,display:"flex",alignItems:"stretch",justifyContent:"center",gap:"40px"},item:{gap:"4px",display:"flex",alignItems:"center",justifyContent:"center","& > span":{fontWeight:500,fontSize:"12px",color:"var(--black-6)",whiteSpace:"nowrap"}},circle:{borderRadius:"50%",height:"8px",width:"8px"}}),De=u(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Footer_1",portals:["v3"]}),Te=({className:e,style:o})=>{const{classes:a}=Re(),{items:n}=Ne();return t(De,{v0:l(e,a.root),v1:o,v2:a.container,v3:[...n].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,o)=>t("div",{className:a.item,children:[t("div",{className:a.circle,style:{background:e.color}}),t("span",{children:[e.label," ",e.value?e.value():e.maxValue]})]},o))})},$e=s()(()=>({circle:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%","& > div":{borderRadius:"50%"}}})),je=u(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{style:e.v2})}),{name:"Circle_1"}),Be=({className:e,style:o,lineWidth:a,side:n,color:i,rotate:r})=>{const{classes:s}=$e();return t(je,{v0:l(e,s.circle),v1:{...o},v2:{borderTop:`${a}px solid ${i}`,borderLeft:`${a}px solid ${i}`,borderRight:`${a}px solid transparent`,borderBottom:`${a}px solid transparent`,transform:`rotate(${r}deg)`,height:n,width:n}})},Ve=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",background:e.palette.background.paper}})),Ie=({side:e})=>{const{classes:o}=Ve();return t("div",{className:o.dot,style:{height:e,width:e}})},Ae=s()(e=>({line:{position:"absolute",background:e.palette.background.paper,height:"100%",width:"1px",left:"50%",transformOrigin:"center bottom"}})),Oe=({angle:e})=>{const{classes:o}=Ae();return t("div",{className:o.line,style:{transform:`rotate(${e}deg)`}})},ze=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",outline:`100vmax solid ${e.palette.background.paper}`}})),Ee=({side:e})=>{const{classes:o}=ze();return t("div",{className:o.dot,style:{height:e,width:e}})},Fe=s()(e=>({pointer:{position:"absolute",left:"21%",width:"29%",bottom:"0%",zIndex:1,transformOrigin:"right center",fill:e.palette.text.primary}})),Ue=u(e=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 87 8",className:e.v0,style:e.v1,...e.v2,children:[t("rect",{x:"0.5",y:"2.5",width:"79",height:"3"}),t("circle",{cx:"82.5",cy:"4",r:"4"})]}),{name:"Pointer_1",svg:!0}),He=({className:e,style:o,angle:a,scale:n=1,...i})=>{const{classes:r}=Fe();return t(Ue,{v0:l(e,r.pointer),v1:{...o,transform:`rotate(${a}deg) scale(${n}) translateX(5px)`},v2:i})},We=e=>e*Math.PI/180,Ge=(e,t)=>({left:t*Math.cos(We(e))+t,top:t*Math.sin(We(e))+t}),_e=s()(e=>({root:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",display:"flex",alignItems:"stretch",justifyContent:"stretch"},container:{flex:1,position:"relative"},label:{position:"absolute",transform:"translate(-50%, -50%)",color:e.palette.text.primary,zIndex:2}})),Ye=u(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Labels_1",portals:["v3"]}),Ke=({items:e,side:o})=>{const{classes:a}=_e(),n=r.useMemo(()=>Math.floor(o/2),[o]);return t(Ye,{v0:a.root,v1:{height:o,width:o},v2:a.container,v3:e.slice(0,e.length-1).map(({angle:e,value:o},i)=>t("span",{className:a.label,style:{...Ge(e+180,n),...e<90&&{marginLeft:10},...e>90&&{marginLeft:-10},...e>15&&e<165&&{marginTop:5}},children:o},i))})},qe=({width:e,side:o,chunks:a,maxValue:n,minValue:i,value:l})=>{const s=r.useMemo(()=>.5*o,[o]),c=r.useMemo(()=>.63*o,[o]),d=r.useMemo(()=>.58*o,[o]),u=r.useCallback(e=>180/(n-i)*(e.minValue-i)+45,[n,i]),p=r.useMemo(()=>Math.min(l/n*180,180),[n,l]),h=r.useMemo(()=>e>o?c/e*1.5:1,[c,e,o]),g=r.useMemo(()=>[...a].sort(({maxValue:e},{maxValue:t})=>e-t).slice(0,a.length-1).map(e=>({angle:180/n*e.maxValue,value:e.maxValue})),[a,n]),f=r.useMemo(()=>[{angle:0,value:0},...g,{angle:180,value:n}],[g,n]);return t(m,{children:[t(He,{angle:p,scale:h}),[...a].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,a)=>t(Be,{rotate:u(e),color:e.color,side:o,lineWidth:s},`${e.color}-${a}`)),g.map(({angle:e},o)=>t(Oe,{angle:e-90},`${e}-${o}`)),t(Ee,{side:o}),t(Ie,{side:c}),t(Ke,{items:f,side:d})]})},Xe=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",overflow:"hidden"},container:{flex:1,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},bottomCenterLabel:{position:"absolute",zIndex:2,bottom:"0",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:"4px","& > *":{fontSize:"20px",lineHeight:"24px"},"& > :first-of-type":{fontWeight:"bold"},"& > :last-of-type":{color:"var(--black-6)"}}}),Je=({className:e,height:o,width:a})=>{const{classes:n}=Xe(),{value:i,items:s}=Ne(),c=Math.min(2*o,a),d=r.useMemo(()=>[...s].filter(e=>!e.hidden).sort(({maxValue:e},{maxValue:t})=>t-e).map((e,t,o)=>{const a=o[t+1],n=a?a.maxValue:0;return{...e,minValue:n,value:e.maxValue-n}}),[s]),u=r.useMemo(()=>{const e=d.find(({minValue:e,maxValue:t})=>i>=e&&i<=t);if(e)return e.color;return d.reduce((e,t)=>t.minValue>=e.minValue?t:e).color},[d,i]),p=r.useMemo(()=>d.reduce((e,{minValue:t})=>Math.min(e,t),Number.POSITIVE_INFINITY),[d]),m=r.useMemo(()=>d.reduce((e,{maxValue:t})=>Math.max(e,t),Number.NEGATIVE_INFINITY),[d]);return t("div",{className:l(e,n.root),children:t("div",{className:n.container,children:t(qe,{chunks:d,value:i,minValue:p,maxValue:m,side:c,width:a,color:u})})})},Qe=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",borderLeft:0,borderRight:0,borderWidth:"1px 0",borderStyle:"solid",borderColor:e.palette.divider},container:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row"},content:{display:"flex",alignItems:"baseline",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),Ze=u(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:t("div",{className:e.v3,children:[e.v4,e.v5]})})}),{name:"Note_1",portals:["v4","v5"]}),et=({className:e,style:o})=>{const{classes:a}=Qe(),{value:n,roundDigits:i=3,valueUnit:r="Unit"}=Ne();return t(Ze,{v0:l(e,a.root),v1:o,v2:a.container,v3:a.content,v4:t(c,{children:he(n,i)}),v5:t(c,{children:r})})},tt=s()(e=>({root:{position:"relative",overflow:"hidden",height:"100%",width:"100%",background:e.palette.background.paper},container:{position:"absolute",top:"0",left:"0"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},chart:{flex:1,paddingTop:"6px",paddingBottom:"6px"},footer:{minHeight:"32px"},note:{minHeight:"60px"}})),ot=({className:e,style:o})=>{const{classes:a}=tt(),n=e=>{let t=e;return t-=32,t-=12,t-=60,t},i=e=>{let t=e;return t-=12,t};return t(p,{className:l(e,a.root),style:o,children:t(h,{className:a.container,children:({height:e=0,width:o=0})=>t("div",{className:a.content,style:{height:e,width:o},children:[t(Je,{className:a.chart,height:n(e),width:i(o)}),t(et,{className:a.note}),t(Te,{className:a.footer})]})})})},at=r.memo(({className:e,style:o,...a})=>t(Me,{value:a,children:t(ot,{className:e,style:o})})),nt=s()({root:{position:"relative",height:10,flex:1},bar:{position:"absolute !important",top:"42%",left:0,right:10}}),it=e=>{const{classes:o}=nt(),a=["done","inprogress","waiting","archive"],n=t=>{var o;return null==(o=e.data[t])?void 0:o.value},i=a.map(t=>{const o=n(t);var a,i;return`${a=t,(null==(i=e.data[a])?void 0:i.title)||t} - ${o}`}).join(" | "),r=a.map(t=>{const o=(t=>{var o;return null==(o=e.data[t])?void 0:o.color})(t);return{color:o,value:n(t),key:t}}).map(({color:e,value:t,key:o},i)=>{let r=0;if(0!==i)for(let l=i-1;l>=0;l--)r+=n(a[l]);return{value:t>0?t+r:t,key:o,color:e}}).sort(({value:e},{value:t})=>t-e),l=Math.max(...r.map(({value:e})=>e));return t(f,{title:i,arrow:!0,children:t("div",{className:o.root,children:r.map(({color:e,value:a,key:n},i)=>{const r=((e,t=100)=>Math.min(100,Math.round(Math.max(Number(e),0)/t*100)))(a,l);return t(g,{sx:{height:"10px !important",zIndex:`${i+1} !important`,backgroundColor:"transparent !important","& .MuiLinearProgress-bar":{borderTopRightRadius:5,borderBottomRightRadius:5,backgroundColor:`${e} !important`}},variant:"determinate",className:o.bar,value:r},`${i}-${n}`)})})})},rt=s()({root:{display:"flex"},work:{display:"flex",alignItems:"center"},row:{flex:1,paddingLeft:5,paddingRight:5,paddingBottom:15}}),lt=({title:e,description:o,avatar:a,done:n,inprogress:i,waiting:r,archive:l})=>{const{classes:s}=rt();return t(v,{className:s.root,children:t(v,{className:s.row,children:[t(v,{className:s.work,children:[t(a,{}),t(y,{primary:e,secondary:o,sx:{flex:"none",marginLeft:"0.5em"}})]}),t(v,{flex:"1",children:t(it,{data:{done:{color:"#7FB537",title:"Take profit",value:n},inprogress:{color:"#4FC0E8",title:"Resolved",value:i},waiting:{color:"#FE9B31",title:"Rejected",value:r},archive:{color:"#FA5F5A",title:"Stop loss",value:l}}})})]})})},st=s()({root:{position:"relative",width:"100%"},container:{position:"absolute",top:0,height:"100%",width:"100%",overflowY:"auto",overflowX:"hidden"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"}}),ct=({items:e,sx:o})=>{const{classes:a}=st();return t(p,{className:a.root,sx:o,children:[t(b,{disableRight:!0,color:"#fff",className:a.container,children:t("div",{className:a.content,children:e.map((e,o)=>t(lt,{...e},o))})}),t(v,{sx:{position:"absolute",bottom:10,right:10,zIndex:10,pointerEvents:"auto",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(10px)",borderRadius:"12px",border:"1px solid rgba(255, 255, 255, 0.2)",padding:"12px 16px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.1)",opacity:.35,transition:"opacity 0.3s ease","&:hover":{opacity:1}},children:[t(v,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#7FB537",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Take profit"})]}),t(v,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#4FC0E8",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Resolved"})]}),t(v,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FE9B31",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Rejected"})]}),t(v,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FA5F5A",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Stop loss"})]})]})]})},dt=s()({root:{position:"relative"},tooltip:{position:"absolute",color:"gray",margin:0,left:5,top:5}}),ut={layout:{textColor:"#d1d4dc",backgroundColor:"#0000"},rightPriceScale:{scaleMargins:{top:.3,bottom:.25}},crosshair:{vertLine:{width:4,color:"#ebe0e301",style:0},horzLine:{visible:!1,labelVisible:!1}},grid:{vertLines:{color:"#f8b3"},horzLines:{color:"#f8b3"}},handleScroll:{vertTouchDrag:!1}},pt={color:"#90cbfa",lineWidth:2,crosshairMarkerVisible:!1,lastValueVisible:!1,priceLineVisible:!1},mt=({height:e,width:o,items:a})=>{const{classes:n}=dt(),i=r.useRef(void 0),l=r.useRef(void 0);return r.useLayoutEffect(()=>{const{current:t}=i,{current:n}=l,r=x(t,{...ut,height:e,width:o});r.addLineSeries({...pt}).setData(a);const s=({time:e})=>{if(e)try{const{day:t,month:o,year:i}=e,r=a.find(({time:e})=>e.day===t&&e.month===o&&e.year===i);if(r){const e=Math.round(Math.round(100*r.value)/100);n.innerHTML=`${C("Total")}: ${e}, ${C("Resolved")}: ${r.resolved}, ${C("Rejected")}: ${r.rejected}`}else n.innerHTML=""}catch(t){console.log(t),n.innerHTML=""}else n.innerHTML=""};return r.timeScale().fitContent(),r.subscribeCrosshairMove(s),()=>{r.unsubscribeCrosshairMove(s),r.remove()}},[e,o,a]),t("div",{ref:i,className:n.root,children:t("p",{ref:l,className:n.tooltip})})},ht=({items:e})=>t(h,{children:({height:o,width:a})=>t(mt,{height:o,width:a,items:e})}),gt=s()({root:{},container:{position:"relative",margin:0,padding:0,overflow:"hidden"},editor:{position:"absolute",top:0,left:0,right:0,bottom:0}}),ft=({items:e,sx:o})=>{const{classes:a}=gt(),n=r.useMemo(()=>[...e].sort(({stamp:e},{stamp:t})=>e-t).map(({count:e,rejected:t,resolved:o,stamp:a})=>{const n=k(a);return{time:{year:n.get("year"),month:n.get("month")+1,day:n.get("date")},rejected:t,resolved:o,value:e}}),[e]);return t(p,{className:a.container,sx:o,children:t("div",{className:a.editor,children:t(ht,{items:n})})})},vt=.1,yt=e=>w(async()=>{const t="live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),a=t.filter(e=>"closed"===e.status).map(e=>({id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:e.pnl.pnlPercentage,buyPrice:e.pnl.priceOpen,originalBuyPrice:e.originalPriceOpen,totalEntries:e.totalEntries,quantity:0,date:new Date(e.createdAt).toISOString(),status:"finished"}));if("backtest"===e)return a;return[...await Promise.all(t.filter(e=>"opened"===e.status).map(async e=>{let t=0;try{t=((e,t)=>{const{position:o,priceOpen:a,_partial:n}=e,i="long"===o?1.001*a:.999*a;if(n&&n.length>0){let e=0,a=vt;for(const t of n){const n="long"===o?.999*t.price:1.001*t.price,r="long"===o?(n-i)/i*100:(i-n)/i*100;e+=t.percent/100*r,a+=vt*(t.percent/100)*(n/i)}const r=100-n.reduce((e,t)=>e+t.percent,0);if(r>0){const n="long"===o?.999*t:1.001*t;e+=r/100*("long"===o?(n-i)/i*100:(i-n)/i*100),a+=vt*(r/100)*(n/i)}return e-a}const r="long"===o?.999*t:1.001*t,l=vt*(1+r/i);return"long"===o?(r-i)/i*100-l:(i-r)/i*100-l})(e,await o.priceGlobalService.getSignalPendingPrice(e.symbol,e.strategyName,e.exchangeName,e.frameName,!1))}catch{}return{id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:t,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,totalEntries:e.totalEntries,quantity:0,date:new Date(e.createdAt).toISOString(),status:"pending"}})),...a]}),bt=[{field:"color",label:R.nbsp,minWidth:45,width:()=>45,format:({symbol:e})=>t(T,{children:async()=>{var a;try{const n=await o.symbolGlobalService.getSymbolMap();return t(Q,{sx:{color:(null==(a=n[e])?void 0:a.color)||"#ccc"}})}catch(n){return t(Q,{sx:{color:"#ccc"}})}}})},{field:"symbol",label:"Symbol",minWidth:115,width:e=>Math.max(e-100-100-100-80-45-100-90,45),format:({symbol:e})=>e},{field:"position",label:"Position",minWidth:90,width:()=>90,format:({position:e})=>{const o="long"===e;return t("span",{style:{color:o?"#1976D2":"#F57C00",padding:"4px 8px",borderRadius:"4px",fontWeight:"bold",fontSize:"11px"},children:o?"🔵 LONG":"🟠 SHORT"})}},{field:"buyPrice",label:"Buy price",minWidth:145,width:()=>145,format:({buyPrice:e})=>`${d(e)}$`},{field:"totalEntries",label:"DCA",minWidth:80,width:()=>80},{field:"profitLossPercentage",label:"%",minWidth:80,width:()=>80,format:({profitLossPercentage:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",e.toFixed(2),"%"]})}}],xt=[{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"position",title:"Position",readonly:!0,compute:e=>"long"===e.position?"🔵 LONG (profit on rise)":"🟠 SHORT (profit on fall)"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"date",title:"Date",readonly:!0,compute:e=>e.date?n(e.date).format("DD/MM/YYYY HH:mm"):""},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"profitLossPercentage",title:"Profit/Loss",readonly:!0,trailingIcon:({data:e})=>e.profitLossPercentage<0?t(q,{sx:{color:"red"}}):t(X,{sx:{color:"green"}}),compute:e=>{if(void 0!==e.profitLossPercentage){return`${e.profitLossPercentage>=0?"+":""}${e.profitLossPercentage.toFixed(2)}%`}return"N/A"}},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"buyPrice",title:"Entry",readonly:!0,compute:e=>e.buyPrice?`${d(e.buyPrice)}$`:"N/A"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"takeProfitPrice",title:"Take Profit",readonly:!0,compute:e=>e.takeProfitPrice?`${d(e.takeProfitPrice)}$`:"N/A"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"stopLossPrice",title:"Stop Loss",readonly:!0,compute:e=>e.stopLossPrice?`${d(e.stopLossPrice)}$`:"N/A"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalBuyPrice",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalBuyPrice&&e.originalBuyPrice!==e.buyPrice,compute:e=>e.originalBuyPrice?`${d(e.originalBuyPrice)}$`:"N/A"},{type:$.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"DCA Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>null!=e.totalEntries?String(e.totalEntries):"N/A"},{type:$.Component,sx:{mt:2},element:({payload:e})=>t(I,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Ct=[{label:"Details",icon:()=>t(D,{icon:J,color:"#4caf50"}),action:"open-action"}],kt=({sx:e,mode:a})=>{const n=(e=>S({handler:async(t,o)=>{const a=L(t,o);for await(const n of yt(e))if(a([n]).done)break;return a([]).rows}}))(a),[i,r]=P(null),{pickData:l,setOpen:s,render:c}=M({title:"Info",AfterTitle:({onClose:e})=>t(V,{direction:"row",gap:2,children:t(j,{size:"small",onClick:e,children:t(B,{})})}),payload:()=>({handleClose(){s(!1)}}),fields:xt,handler:()=>i.current,withActionButton:!1});return t(m,{children:[t(p,{sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",background:"whitesmote",overflow:"hidden",...e},children:t(N,{sx:{flex:1,background:"transparent !important"},rowColor:({status:e})=>"pending"===e?"#ffc40085":"transparent",hasMore:n.hasMore,loading:n.loading,onSkip:n.onSkip,data:n.data,columns:bt,rowActions:Ct,onRowClick:e=>{r(e),l(e.id)},onRowAction:(e,t)=>{"open-action"===e&&o.layoutService.pickSignal(t.id)}})}),c()]})},wt=[{type:$.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.thirtyOneDaysRevenue)||0,a=(null==e?void 0:e.thirtyOneDaysCount)||0,n=o<0?le.Red:o>0?le.Green:le.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"31 days",footerLabel:"Profit for 31 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:$.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.sevenDaysRevenue)||0,a=(null==e?void 0:e.sevenDaysCount)||0,n=o<0?le.Red:o>0?le.Green:le.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"7 days",footerLabel:"Profit for 7 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:$.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.yesterdayRevenue)||0,a=(null==e?void 0:e.yesterdayCount)||0,n=o<0?le.Red:o>0?le.Green:le.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Yesterday",footerLabel:"Yesterday's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:$.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.todayRevenue)||0,a=(null==e?void 0:e.todayCount)||0,n=o<0?le.Red:o>0?le.Green:le.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Today",footerLabel:"Today's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:$.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({tradePerfomance:e})=>{const o=[{color:"#DD4049",label:"Failed",maxValue:Math.max(e.rejectedCount+1,1),value:()=>e.rejectedCount},{color:"#2EA96F",label:"Successful",maxValue:Math.max(e.rejectedCount+e.resolvedCount+2,2),value:()=>e.resolvedCount},{color:"#F3A43A",label:"Total",hidden:!0,maxValue:Math.max(e.total+3,3),value:()=>e.total}];return t(at,{style:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o,valueUnit:Le(Math.abs(e.resolvedCount),{one:"Successful signal",many:"Successful signals"}),value:e.resolvedCount})}},{type:$.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({dailyTrades:e})=>t(ft,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:e})},{type:$.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({successRate:e})=>{const o=e.map(({symbol:e,displayName:o,rejectedCloseCount:a,rejectedStopLossCount:n,resolvedCloseCount:i,resolvedTakeProfitCount:r})=>({title:o||e,description:e,avatar:()=>t(G,{symbol:e}),done:r,archive:n,waiting:a,inprogress:i})).filter(({done:e,archive:t,waiting:o,inprogress:a})=>{let n=!1;return n=n||!!e,n=n||!!t,n=n||!!o,n=n||!!a,n});return t(ct,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o})}},{type:$.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:e})=>t(kt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},mode:e.mode})}],St={rejectedCount:0,resolvedCount:0,total:0},Lt=[{action:"download-action",label:"Download",icon:()=>t(D,{icon:H,color:"#4caf50"})},{divider:!0},{action:"live-action",label:"Switch to LIVE",isVisible:e=>"backtest"===e,icon:()=>t(D,{icon:ee,color:"#4caf50"})},{action:"backtest-action",label:"Switch to BACKTEST",isVisible:e=>"live"===e,icon:()=>t(D,{icon:Z,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>t(D,{icon:Y,color:"#4caf50"})}],Pt=[{type:U.Link,action:"back-action",label:t(K,{sx:{display:"block"}})},{type:U.Link,action:"back-action",label:"Dashboard"},{type:U.Link,action:"back-action",compute:e=>`KPI ${String(e).toUpperCase()}`}],Mt=new E,Nt=({mode:e})=>{const[a,{loading:n,execute:i}]=A(async()=>{const t=await o.symbolGlobalService.getSymbolList(),a=await o.symbolGlobalService.getSymbolMap(),n=new Map,i=[],r={...St};let l={symbol:"TOTAL",todayRevenue:0,yesterdayRevenue:0,sevenDaysRevenue:0,thirtyOneDaysRevenue:0,todayCount:0,yesterdayCount:0,sevenDaysCount:0,thirtyOneDaysCount:0};await Promise.all(t.map(async t=>{var o;const[s=[],c,d,u]=await Promise.all([ie(t,e),ne(t,e),ae(t,e),re(t,e)]);for(const e of s){const t=n.get(e.stamp)||{count:0,resolved:0,rejected:0};n.set(e.stamp,{count:t.count+e.count,resolved:t.resolved+e.resolved,rejected:t.rejected+e.rejected})}i.push({...c,symbol:t,displayName:(null==(o=a[t])?void 0:o.displayName)||t}),r.rejectedCount+=d.rejectedCount,r.resolvedCount+=d.resolvedCount,r.total+=d.total,l.todayRevenue+=u.todayRevenue,l.yesterdayRevenue+=u.yesterdayRevenue,l.sevenDaysRevenue+=u.sevenDaysRevenue,l.thirtyOneDaysRevenue+=u.thirtyOneDaysRevenue,l.todayCount+=u.todayCount,l.yesterdayCount+=u.yesterdayCount,l.sevenDaysCount+=u.sevenDaysCount,l.thirtyOneDaysCount+=u.thirtyOneDaysCount}));return{dailyTrades:Array.from(n).map(([e,{count:t,resolved:o,rejected:a}])=>({stamp:e,count:t,resolved:o,rejected:a})),successRate:i,tradePerfomance:r,revenueCount:l}},{onLoadStart:()=>o.layoutService.setModalLoader(!0),onLoadEnd:()=>o.layoutService.setModalLoader(!1),deps:[e]}),{execute:r}=O(async()=>{const t=await te(e),a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(a);o.layoutService.downloadFile(n,`signals_${e}_${Date.now()}.json`)},{onLoadStart:()=>o.layoutService.setAppbarLoader(!0),onLoadEnd:()=>o.layoutService.setAppbarLoader(!1)});z(()=>Mt.subscribe(i));return t(_,{children:[t(F,{items:Pt,actions:Lt,payload:e,onAction:async e=>{"download-action"===e&&await r(),"update-now"===e&&(te.clear(),await Mt.next()),"live-action"===e&&o.routerService.push("/dashboard/live"),"backtest-action"===e&&o.routerService.push("/dashboard/backtest"),"back-action"===e&&o.routerService.push("/")}}),a?n?null:t(W,{handler:a,payload:()=>({handleUpdate(){Mt.next()},mode:e}),fields:wt}):null]})};export{Nt as DashboardPage,Nt as default};
@@ -0,0 +1 @@
1
+ import{c as a,f as e,a7 as t,B as o,a3 as r,a8 as n,T as i,t as c,a9 as s,F as l,aa as d,P as h,ab as p,ac as u,Q as v,a as w,i as b,V as f,z as x,a5 as g,q as m,Z as y,ad as S,D as z,I as L}from"./index-zBOUVifH.js";import{C as k,R as H}from"./Refresh-CEQ_0ArO.js";import{K as C}from"./KeyboardArrowLeft-lQZO05jc.js";const j=a(e("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"),A=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(e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"}),"Info"),R=a(e("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),"Search"),B=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(A,{sx:t});case"info":return e(M,{sx:t});case"warn":return e(p,{sx:t});default:return e(j,{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:"hidden",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:B(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:c(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(s,{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(L,{icon:z,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(L,{icon:H,color:"#4caf50"})}],F=[{type:y.Link,action:"back-action",label:e(C,{sx:{display:"block"}})},{type:y.Link,action:"back-action",label:"Main"},{type:y.Link,action:"back-action",label:"Logs"},{type:y.Button,icon:R,action:"search-action",label:"Search"}],V=new w,I=()=>{const[a,o]=u(""),{data:r,hasMore:n,loading:i,onSkip:c}=v({handler:async(e,t)=>{const o=await b.logViewService.getList(),r=f(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>b.layoutService.setAppbarLoader(!0),onLoadEnd:()=>b.layoutService.setAppbarLoader(!1),reloadSubject:V}),s=x(r),{execute:l}=g(async()=>{const a=new Blob([JSON.stringify(s.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);b.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>b.layoutService.setAppbarLoader(!0),onLoadEnd:()=>b.layoutService.setAppbarLoader(!1)});return e(k,{children:[e(m,{items:F,actions:E,onAction:async a=>{"back-action"===a&&b.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await V.next()),"search-action"===a&&(async()=>{const a=await b.layoutService.prompt("Search keyword");if(a)return o(a),void V.next();o(""),V.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:c,bufferSize:S,hasMore:n,children:r.map(a=>e(D,{data:a,sx:{mb:1}},a.id))})]})};export{I as LogPage,I as default};