@backtest-kit/ui 13.6.0 → 14.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.
- package/README.md +189 -170
- package/build/modules/frontend/build/assets/{Article-C7I5Jc2B.js → Article-CpU7DBcT.js} +1 -1
- package/build/modules/frontend/build/assets/{Background-xwzJo61H.js → Background-DISIt7NA.js} +1 -1
- package/build/modules/frontend/build/assets/{IconPhoto-DrGLW-rX.js → IconPhoto-Czod_jkW.js} +1 -1
- package/build/modules/frontend/build/assets/{KeyboardArrowLeft-BpxUzr7-.js → KeyboardArrowLeft-BUZ_pXI5.js} +1 -1
- package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-BTv5MH3G.js → PictureAsPdfOutlined-BgifaQ0L.js} +1 -1
- package/build/modules/frontend/build/assets/{Refresh-DixrXBVq.js → Refresh-3cixHjvW.js} +1 -1
- package/build/modules/frontend/build/assets/emitters-DmNf0ttF.js +1 -0
- package/build/modules/frontend/build/assets/{hasRouteMatch-C0K-M4jy.js → hasRouteMatch-CqJJG3sx.js} +1 -1
- package/build/modules/frontend/build/assets/{html2canvas-Xo2SFHzw.js → html2canvas-Ds2vwzb-.js} +1 -1
- package/build/modules/frontend/build/assets/{index-wMYoZqi-.js → index-B1plXuf6.js} +1 -1
- package/build/modules/frontend/build/assets/{index-kQlTYlpK.js → index-BI3k7b1T.js} +5 -5
- package/build/modules/frontend/build/assets/{index-DP-GjNGC.js → index-BMq2INDq.js} +1 -1
- package/build/modules/frontend/build/assets/{index-D7cEguAr.js → index-BYiuApxW.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DFbdj6KX.js → index-BYnSX2YX.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CtY-cILX.js → index-C8oIDQdm.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CwqHMGtu.js → index-CA19hrNH.js} +1 -1
- package/build/modules/frontend/build/assets/{index-BO8_0_6f.js → index-Cqt7co-7.js} +1 -1
- package/build/modules/frontend/build/assets/{index-wq7wFKoe.js → index-DJ7B8Och.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DeRxtBVy.js → index-DwO4-4_F.js} +1 -1
- package/build/modules/frontend/build/assets/{index-Giwjzoy7.js → index-VxkdhxAi.js} +1 -1
- package/build/modules/frontend/build/assets/{index-S9fsmR5b.js → index-pxXO4P81.js} +1 -1
- package/build/modules/frontend/build/assets/{index-D6fbkGDu.js → index-ruSh1u75.js} +1 -1
- package/build/modules/frontend/build/assets/{index.es-BiwqIRwO.js → index.es-DPOJOdbj.js} +1 -1
- package/build/modules/frontend/build/assets/{markdownit-By9-eJJI.js → markdownit-C4X6Sysk.js} +1 -1
- package/build/modules/frontend/build/index.html +1 -1
- package/package.json +5 -5
- package/build/modules/frontend/build/assets/emitters-ByKSsASU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,a as t,r as o,u as a,_ as i,d as r,f as n,e as l,k as s,s as c,P as p,b as d,Q as m,x as y,i as u,O as g,R as h,p as b,a2 as f,Z as v,T as x,b2 as C,W as w,B as S,F as N,a3 as P,E as k,A,a5 as L,l as M,n as T,a4 as $,a6 as B,ai as R,b3 as F,b4 as V,w as z,X as I,a8 as E,b5 as O,D,b6 as j,b7 as H,ag as W,V as G,N as q,a1 as _,b8 as U,ad as Y,b9 as Q,ba as J,bb as K,J as X,bc as Z,aX as ee,ah as te,bd as oe,aQ as ae,aO as ie,a$ as re,be as ne,bf as le,bg as se,bh as ce,I as pe,av as de,al as me,bi as ye,aj as ue}from"./index-kQlTYlpK.js";import{h as ge}from"./hasRouteMatch-C0K-M4jy.js";import{I as he}from"./IconPhoto-DrGLW-rX.js";import{C as be,R as fe}from"./Refresh-DixrXBVq.js";import{K as ve}from"./KeyboardArrowLeft-BpxUzr7-.js";import{B as xe}from"./Background-xwzJo61H.js";import{r as Ce}from"./emitters-ByKSsASU.js";function we(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Se=["className","raised"],Ne=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),Pe=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Se),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},we,t)})(m);return n(Ne,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function ke(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Ae=["className","component"],Le=c("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),Me=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCardContent"}),{className:c,component:p="div"}=o,d=i(o,Ae),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},ke,t)})(m);return n(Le,r({as:p,className:l(y.root,c),ownerState:m,ref:t},d))}),Te=d(n("path",{d:"M18.21 9.21C15.93 10.78 13.45 13.3 13 17h2v2H9v-2h2c-.5-4.5-4.37-8-9-8V7c4.39 0 8.22 2.55 10 6.3 1.13-2.43 2.99-4.25 4.78-5.52L14 5h7v7l-2.79-2.79z"}),"AirlineStops"),$e=d(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle"),Be=d(n("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}),"CloseOutlined"),Re=d(n("path",{d:"M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25v4.7z"}),"ShieldOutlined"),Fe=d(n("path",{d:"m16 6 2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6h-6z"}),"TrendingUpOutlined"),Ve=d(n("path",{d:"M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-10 7H8v3H6v-3H3v-2h3V8h2v3h3v2zm4.5 2c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4-3c-.83 0-1.5-.67-1.5-1.5S18.67 9 19.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"VideogameAsset"),ze="backtest-kit__groupHeader",Ie="backtest-kit__groupRoot",Ee="backtest-kit__symbolImage",Oe=b()({root:{[`& .${Ie}:hover .${ze}`]:{opacity:"1 !important"}}});function De(e){return B(e,"#000000")>B(e,"#FFFFFF")}const je=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"}],He=[{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],We=(e,t)=>({type:f.Group,className:Ie,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:ze,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(A,{direction:"row",children:[n(P,{variant:"outlined",size:"small",color:"info",label:`${k.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(S,{flex:1})]})},{type:f.Group,fields:t.map(({symbol:e,label:t,to:o,color:a})=>((e,t,o,a)=>({type:f.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>n($,{component:L,onClick:()=>{u.routerService.push(`/status/${t}`)},sx:{width:"100%",background:a,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${Ee}`]:{transition:"filter 500ms"},"&:hover":{background:()=>De(a)?M(a,.33):T(a,.33),[`& .${Ee}`]:{transition:"filter 500ms",filter:De(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(he,{className:Ee,symbol:e}),children:n(S,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),Ge=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Button,action:"control-action",label:"Manual Control",icon:Ve},{type:h.Fab,action:"print-action",label:"Print",icon:O},{type:h.Fab,action:"update-now",label:"Refresh",icon:fe}],qe=[{action:"print-action",label:"Print",icon:()=>n(v,{icon:O,color:"#4caf50"})},{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],_e=new E,Ue=new E,Ye=new E,Qe=new E,Je=new E,Ke=_.createLoader(12),Xe=({payload:e})=>n(S,{sx:{mb:1,minHeight:48},children:n(H,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(A,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(W,{startIcon:n(Te,{}),onClick:async()=>await Ue.next(),color:"success",sx:{whiteSpace:"nowrap"},children:"Open Position"}),n(W,{startIcon:n(Fe,{}),onClick:async()=>await Ye.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:"Commit Averaging"}),n(W,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},children:"Commit Breakeven"}),n(S,{flex:1}),n(G,{Loader:Ke,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:Ce,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(x,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:["Avg price ",e.symbol,":",k.nbsp,n("b",{children:`${o.toFixed(q(o))}$`})]})}}),n(W,{startIcon:n(Be,{}),onClick:async()=>await Qe.next(),sx:{whiteSpace:"nowrap"},color:"error",children:"Close Position"})]})})}),Ze=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:"Direction",placeholder:"Select direction",itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for opening the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the position will be opened IMMEDIATELY`}]}}],et=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE`}]}}],tt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ot={success:!1,loading:!0,error:""},at=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:et}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({position:r.position,cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:Ze,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ot),{position:s,cost:c,note:p,symbol:d}=o.useMemo(()=>{const{position:t,cost:o,note:a,symbol:i}=e.data.form;return{position:t,cost:o,note:a,symbol:i}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitOpenPending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{position:s,cost:parseFloat(c||"0"),note:p||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(tt,{type:"error",title:"Position Opening Error",description:r.error,amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):r.loading?n(tt,{type:"loading",title:"Opening Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):n(tt,{type:"success",title:"Position Opened",description:"Position has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(c||"0"))}$`,symbol:d})})})},isActive:e=>!!le("/submit",e)}],it=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Opening"}],rt="/brief",nt=de(),lt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for averaging the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the averaging will be performed IMMEDIATELY`}]}}],st=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE`}]}}],ct=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},pt={success:!1,loading:!0,error:""},dt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:st}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:lt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(pt),{cost:s,note:c,symbol:p}=o.useMemo(()=>{const{cost:t,note:o,symbol:a}=e.data.form;return{cost:t,note:o,symbol:a}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitAverageBuy(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{cost:parseFloat(s||"0"),note:c||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(ct,{type:"error",title:"Averaging Error",description:r.error,amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):r.loading?n(ct,{type:"loading",title:"Averaging Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):n(ct,{type:"success",title:"Position Averaged",description:"Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(s||"0"))}$`,symbol:p})})})},isActive:e=>!!le("/submit",e)}],mt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Averaging"}],yt="/brief",ut=de(),gt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"note",title:"Note",placeholder:"Reason for closing the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the closing will be performed IMMEDIATELY`}]}}],ht=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE`}]}}],bt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ft={success:!1,loading:!0,error:""},vt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:ht}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:gt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ft),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitClosePending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{note:s||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(bt,{type:"error",title:"Position Closing Error",description:r.error,symbol:c}):r.loading?n(bt,{type:"loading",title:"Closing Position",description:"Please wait. Your operation is being processed...",symbol:c}):n(bt,{type:"success",title:"Position Closed",description:"Closing has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:c})})})},isActive:e=>!!le("/submit",e)}],xt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Closing"}],Ct="/brief",wt=de(),St=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:"The stop-loss will be moved to the breakeven point of the current position. No additional input is required."}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the move to breakeven will be performed IMMEDIATELY`}]}}],Nt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE`}]}}],Pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},kt={success:!1,loading:!0,error:""},At=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:Nt}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(w,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:Q,fields:St,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(kt),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitBreakeven(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(Pt,{type:"error",title:"Breakeven Error",description:r.error,symbol:s}):r.loading?n(Pt,{type:"loading",title:"Moving to Breakeven",description:"Please wait. Your operation is being processed...",symbol:s}):n(Pt,{type:"success",title:"Breakeven Set",description:"Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:s})})})},isActive:e=>!!le("/submit",e)}],Lt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Breakeven"}],Mt="/brief",Tt=de(),$t=e=>"pnl"===e?"P&L":e,Bt=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Link,action:"back-action",label:"Manual Control"},{type:h.Button,action:"update-now",label:"Refresh",icon:fe}],Rt=[{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>t?await u.controlViewService.getStrategyStatus(t.symbol,{strategyName:t.strategyName,exchangeName:t.exchangeName}):null,{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]}),r=me(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=se({history:nt,animation:"none",title:"Open Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:rt,sizeRequest:ce,routes:at,steps:it,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{nt.push(rt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=se({history:ut,animation:"none",title:"Average Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:yt,sizeRequest:ce,routes:dt,steps:mt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{ut.push(yt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=se({history:wt,animation:"none",title:"Close Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Ct,sizeRequest:ce,routes:vt,steps:xt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{wt.push(Ct),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=se({history:Tt,animation:"none",title:"Move to Breakeven",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:ce,routes:At,steps:Lt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}});I(Ce.subscribe(i)),I(Ue.subscribe(l)),I(Ye.subscribe(c)),I(Qe.subscribe(m)),I(Je.subscribe(b));const v=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`manual_control_${Date.now()}.json`)});return n(be,{children:[n(g,{items:Bt,actions:Rt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&v(),"update-now"===t&&await Ce.next()}}),o?a?null:n(ye,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:$t,AfterSearch:Xe,data:o}):null,n(S,{sx:{paddingBottom:"24px"}}),n(xe,{}),s(),d(),h(),f()]})},isActive:e=>ge(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>await u.statusViewService.getStatusOne(e.id),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),r=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`status_${Date.now()}.json`)}),l=F(async()=>{if(!o)return;const e=u.markdownHelperService.buildMarkdownFromFields(V,o);await z(e)});I(()=>_e.subscribe(i));return n(be,{children:[n(g,{items:Ge,actions:qe,payload:t,onAction:async t=>{"back-action"===t&&(async()=>{1!==(await u.statusViewService.getStatusList()).length?u.routerService.push("/status"):u.routerService.push("/")})(),"control-action"===t&&u.routerService.push(`/status/${e.id}/control`),"update-now"===t&&await _e.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o?n(N,{children:[n(w,{handler:o,fields:j}),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signal"})}),n(xe,{})]})},isActive:e=>ge(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=Oe(),{reloadTrigger:t,doReload:o}=m();y(async()=>{const e=await u.statusViewService.getStatusList();if(1===e.length){const[{id:t}]=e;u.routerService.push(`/status/${t}`)}},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});const[a,{loading:i}]=y(async()=>await(async()=>{const[e,t]=await Promise.all([u.symbolGlobalService.getSymbolMap(),u.statusViewService.getStatusList()]);if(!t||0===t.length)return[{type:f.Typography,typoVariant:"h6",placeholder:"Listening for a pending signal...",sx:{textAlign:"center",opacity:.5,mt:4}}];const o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;o[i]||(o[i]=[]),o[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",to:t.id})});const a=Object.entries(o).sort(([,e],[,t])=>t.length-e.length),i=[],r=[],n=[];return a.forEach(([e,t],o)=>{const a=We(e,t);o%2==0?i.push(a):r.push(a),n.push(a)}),[{type:f.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:i},{type:f.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:r},{type:f.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:n}]})(),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});return n(be,{children:[n(g,{items:je,actions:He,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a.length?n(N,{children:[n(w,{className:e.root,fields:a},t),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>ge(["/status"],e)}],Vt=({id:e})=>n(ue,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{Vt as StatusPage,Vt as default};
|
|
1
|
+
import{g as e,a as t,r as o,u as a,_ as i,d as r,f as n,e as l,k as s,s as c,P as p,b as d,Q as m,x as y,i as u,O as g,R as h,p as b,a2 as f,Z as v,T as x,b2 as C,W as w,B as S,F as N,a3 as P,E as k,A,a5 as L,l as M,n as T,a4 as $,a6 as B,ai as R,b3 as F,b4 as V,w as z,X as I,a8 as E,b5 as O,D,b6 as j,b7 as H,ag as W,V as G,N as q,a1 as _,b8 as U,ad as Y,b9 as Q,ba as J,bb as K,J as X,bc as Z,aX as ee,ah as te,bd as oe,aQ as ae,aO as ie,a$ as re,be as ne,bf as le,bg as se,bh as ce,I as pe,av as de,al as me,bi as ye,aj as ue}from"./index-BI3k7b1T.js";import{h as ge}from"./hasRouteMatch-CqJJG3sx.js";import{I as he}from"./IconPhoto-Czod_jkW.js";import{C as be,R as fe}from"./Refresh-3cixHjvW.js";import{K as ve}from"./KeyboardArrowLeft-BUZ_pXI5.js";import{B as xe}from"./Background-DISIt7NA.js";import{r as Ce}from"./emitters-DmNf0ttF.js";function we(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Se=["className","raised"],Ne=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),Pe=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Se),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},we,t)})(m);return n(Ne,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function ke(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Ae=["className","component"],Le=c("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),Me=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCardContent"}),{className:c,component:p="div"}=o,d=i(o,Ae),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},ke,t)})(m);return n(Le,r({as:p,className:l(y.root,c),ownerState:m,ref:t},d))}),Te=d(n("path",{d:"M18.21 9.21C15.93 10.78 13.45 13.3 13 17h2v2H9v-2h2c-.5-4.5-4.37-8-9-8V7c4.39 0 8.22 2.55 10 6.3 1.13-2.43 2.99-4.25 4.78-5.52L14 5h7v7l-2.79-2.79z"}),"AirlineStops"),$e=d(n("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle"),Be=d(n("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}),"CloseOutlined"),Re=d(n("path",{d:"M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25v4.7z"}),"ShieldOutlined"),Fe=d(n("path",{d:"m16 6 2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6h-6z"}),"TrendingUpOutlined"),Ve=d(n("path",{d:"M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-10 7H8v3H6v-3H3v-2h3V8h2v3h3v2zm4.5 2c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4-3c-.83 0-1.5-.67-1.5-1.5S18.67 9 19.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"VideogameAsset"),ze="backtest-kit__groupHeader",Ie="backtest-kit__groupRoot",Ee="backtest-kit__symbolImage",Oe=b()({root:{[`& .${Ie}:hover .${ze}`]:{opacity:"1 !important"}}});function De(e){return B(e,"#000000")>B(e,"#FFFFFF")}const je=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"}],He=[{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],We=(e,t)=>({type:f.Group,className:Ie,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:ze,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(A,{direction:"row",children:[n(P,{variant:"outlined",size:"small",color:"info",label:`${k.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(S,{flex:1})]})},{type:f.Group,fields:t.map(({symbol:e,label:t,to:o,color:a})=>((e,t,o,a)=>({type:f.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>n($,{component:L,onClick:()=>{u.routerService.push(`/status/${t}`)},sx:{width:"100%",background:a,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${Ee}`]:{transition:"filter 500ms"},"&:hover":{background:()=>De(a)?M(a,.33):T(a,.33),[`& .${Ee}`]:{transition:"filter 500ms",filter:De(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(he,{className:Ee,symbol:e}),children:n(S,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),Ge=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Button,action:"control-action",label:"Manual Control",icon:Ve},{type:h.Fab,action:"print-action",label:"Print",icon:O},{type:h.Fab,action:"update-now",label:"Refresh",icon:fe}],qe=[{action:"print-action",label:"Print",icon:()=>n(v,{icon:O,color:"#4caf50"})},{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],_e=new E,Ue=new E,Ye=new E,Qe=new E,Je=new E,Ke=_.createLoader(12),Xe=({payload:e})=>n(S,{sx:{mb:1,minHeight:48},children:n(H,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(A,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(W,{startIcon:n(Te,{}),onClick:async()=>await Ue.next(),color:"success",sx:{whiteSpace:"nowrap"},children:"Open Position"}),n(W,{startIcon:n(Fe,{}),onClick:async()=>await Ye.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:"Commit Averaging"}),n(W,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},children:"Commit Breakeven"}),n(S,{flex:1}),n(G,{Loader:Ke,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:Ce,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(x,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:["Avg price ",e.symbol,":",k.nbsp,n("b",{children:`${o.toFixed(q(o))}$`})]})}}),n(W,{startIcon:n(Be,{}),onClick:async()=>await Qe.next(),sx:{whiteSpace:"nowrap"},color:"error",children:"Close Position"})]})})}),Ze=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:"Direction",placeholder:"Select direction",itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for opening the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the position will be opened IMMEDIATELY`}]}}],et=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Open Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE`}]}}],tt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ot={success:!1,loading:!0,error:""},at=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:et}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({position:r.position,cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:Ze,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ot),{position:s,cost:c,note:p,symbol:d}=o.useMemo(()=>{const{position:t,cost:o,note:a,symbol:i}=e.data.form;return{position:t,cost:o,note:a,symbol:i}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitOpenPending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{position:s,cost:parseFloat(c||"0"),note:p||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(tt,{type:"error",title:"Position Opening Error",description:r.error,amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):r.loading?n(tt,{type:"loading",title:"Opening Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(c||"0"))}$`,symbol:d}):n(tt,{type:"success",title:"Position Opened",description:"Position has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(c||"0"))}$`,symbol:d})})})},isActive:e=>!!le("/submit",e)}],it=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Opening"}],rt="/brief",nt=de(),lt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Y,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:"Amount USDT",placeholder:"00000",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9]/,defaultValue:"100"},{type:f.Text,outlined:!0,name:"quantity",sx:{cursor:"not-allowed","& *":{cursor:"not-allowed"}},title:"Coin Quantity",placeholder:"0.00",compute:(e,t)=>{const o=parseFloat(e.cost||"0"),a=parseFloat(t.averagePrice||"0");return o&&a?(o/a).toFixed(6):"0"},inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/,readonly:!0},{type:f.Text,name:"note",title:"Note",placeholder:"Reason for averaging the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the averaging will be performed IMMEDIATELY`}]}}],st=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Average Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE`}]}}],ct=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},pt={success:!1,loading:!0,error:""},dt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:st}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({cost:r.cost,note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:lt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(pt),{cost:s,note:c,symbol:p}=o.useMemo(()=>{const{cost:t,note:o,symbol:a}=e.data.form;return{cost:t,note:o,symbol:a}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitAverageBuy(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{cost:parseFloat(s||"0"),note:c||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(ct,{type:"error",title:"Averaging Error",description:r.error,amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):r.loading?n(ct,{type:"loading",title:"Averaging Position",description:"Please wait. Your operation is being processed...",amount:`${X(parseFloat(s||"0"))}$`,symbol:p}):n(ct,{type:"success",title:"Position Averaged",description:"Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange",amount:`${X(parseFloat(s||"0"))}$`,symbol:p})})})},isActive:e=>!!le("/submit",e)}],mt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Averaging"}],yt="/brief",ut=de(),gt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"note",title:"Note",placeholder:"Reason for closing the position"}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the closing will be performed IMMEDIATELY`}]}}],ht=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Close Position"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE`}]}}],bt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},ft={success:!1,loading:!0,error:""},vt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:ht}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{r&&(i({note:r.note,symbol:a.data.brief.symbol}),await s(),t.replace("/submit"))}}),children:n(w,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:Q,fields:gt,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(ft),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitClosePending(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName},{note:s||""}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(bt,{type:"error",title:"Position Closing Error",description:r.error,symbol:c}):r.loading?n(bt,{type:"loading",title:"Closing Position",description:"Please wait. Your operation is being processed...",symbol:c}):n(bt,{type:"success",title:"Position Closed",description:"Closing has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:c})})})},isActive:e=>!!le("/submit",e)}],xt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Closing"}],Ct="/brief",wt=de(),St=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:"The stop-loss will be moved to the breakeven point of the current position. No additional input is required."}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} After pressing the Next button, the move to breakeven will be performed IMMEDIATELY`}]}}],Nt=[{type:f.Center,child:{type:f.Group,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fields:[{type:f.Typography,style:{opacity:.5},fieldBottomMargin:"3",typoVariant:"h6",placeholder:"Move to Breakeven"},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:"Symbol"},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${X(e.averagePrice)}$`,title:"Coin Price",placeholder:"000000.00",inputFormatterSymbol:"0",inputFormatterAllowed:/[0-9.]/}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${k.bullet} Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE`}]}}],Pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=Z(),s="loading"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(oe,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:te(l.palette.success.main,.1),icon:n($e,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:te(l.palette.error.main,.1),icon:n(ae,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:te(l.palette.warning.main,.1),icon:n(ie,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:te(l.palette.info.main,.1),icon:n(re,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:te(l.palette.grey[500],.1),icon:n(re,{}),chipColor:"default"};return n(Pe,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${te(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(S,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(S,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(x,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(P,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(ee,{})})]}),o&&n(x,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(S,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:te(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${te(s.color,.1)}`},children:[a&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Amount"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(S,{children:[n(x,{variant:"caption",color:"text.secondary",children:"Price"}),n(x,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},kt={success:!1,loading:!0,error:""},At=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=U([e],50),[s,{loading:c}]=y(async()=>{const e=t.getContext();return{averagePrice:await u.controlViewService.getAveragePrice(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),symbol:e.symbol}},{onLoadStart:()=>r(!0),onLoadEnd:()=>r(!1)});return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!!s,labelPrev:"Close",onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(w,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:Q,fields:Nt}):null})},isActive:e=>!!le("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=U([e],50);return n(K,{Navigation:n(J,{hasPrev:!0,hasNext:!0,labelPrev:"Back",onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(w,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:Q,fields:St,sx:{pt:1}})})},isActive:e=>!!le("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(kt),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);I(async()=>{i(!0);try{const e=t.getContext();await u.controlViewService.commitBreakeven(e.symbol,{strategyName:e.strategyName,exchangeName:e.exchangeName}),l({success:!0,loading:!1,error:""})}catch(e){l({success:!1,loading:!1,error:ne(e)})}finally{i(!1)}});return n(K,{Navigation:n(J,{hasNext:r.success||!!r.error,labelNext:"Close",onNext:async()=>{await a()}}),children:n(S,{p:1,children:r.error?n(Pt,{type:"error",title:"Breakeven Error",description:r.error,symbol:s}):r.loading?n(Pt,{type:"loading",title:"Moving to Breakeven",description:"Please wait. Your operation is being processed...",symbol:s}):n(Pt,{type:"success",title:"Breakeven Set",description:"Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange",symbol:s})})})},isActive:e=>!!le("/submit",e)}],Lt=[{id:"brief",label:"Briefing"},{id:"form",label:"Input"},{id:"submit",label:"Breakeven"}],Mt="/brief",Tt=de(),$t=e=>"pnl"===e?"P&L":e,Bt=[{type:h.Link,action:"back-action",label:n(ve,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:"Main"},{type:h.Link,action:"back-action",label:"Status"},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:"Live"},{type:h.Link,action:"back-action",label:"Manual Control"},{type:h.Button,action:"update-now",label:"Refresh",icon:fe}],Rt=[{action:"download-action",label:"Download",icon:()=>n(v,{icon:D,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>n(v,{icon:fe,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>t?await u.controlViewService.getStrategyStatus(t.symbol,{strategyName:t.strategyName,exchangeName:t.exchangeName}):null,{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]}),r=me(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=se({history:nt,animation:"none",title:"Open Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:rt,sizeRequest:ce,routes:at,steps:it,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{nt.push(rt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=se({history:ut,animation:"none",title:"Average Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:yt,sizeRequest:ce,routes:dt,steps:mt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{ut.push(yt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=se({history:wt,animation:"none",title:"Close Position",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Ct,sizeRequest:ce,routes:vt,steps:xt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{wt.push(Ct),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=se({history:Tt,animation:"none",title:"Move to Breakeven",AfterTitle:({onClose:e})=>n(A,{direction:"row",gap:1,children:n(pe,{size:"small",onClick:e,children:n(Y,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:ce,routes:At,steps:Lt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:Ce}});I(Ce.subscribe(i)),I(Ue.subscribe(l)),I(Ye.subscribe(c)),I(Qe.subscribe(m)),I(Je.subscribe(b));const v=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`manual_control_${Date.now()}.json`)});return n(be,{children:[n(g,{items:Bt,actions:Rt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&v(),"update-now"===t&&await Ce.next()}}),o?a?null:n(ye,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:$t,AfterSearch:Xe,data:o}):null,n(S,{sx:{paddingBottom:"24px"}}),n(xe,{}),s(),d(),h(),f()]})},isActive:e=>ge(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return R.get(t,e.id,null)},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),[o,{loading:a,execute:i}]=y(async()=>await u.statusViewService.getStatusOne(e.id),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[e.id]}),r=F(async()=>{if(!o)return;const e=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);u.layoutService.downloadFile(t,`status_${Date.now()}.json`)}),l=F(async()=>{if(!o)return;const e=u.markdownHelperService.buildMarkdownFromFields(V,o);await z(e)});I(()=>_e.subscribe(i));return n(be,{children:[n(g,{items:Ge,actions:qe,payload:t,onAction:async t=>{"back-action"===t&&(async()=>{1!==(await u.statusViewService.getStatusList()).length?u.routerService.push("/status"):u.routerService.push("/")})(),"control-action"===t&&u.routerService.push(`/status/${e.id}/control`),"update-now"===t&&await _e.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o?n(N,{children:[n(w,{handler:o,fields:j}),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signal"})}),n(xe,{})]})},isActive:e=>ge(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=Oe(),{reloadTrigger:t,doReload:o}=m();y(async()=>{const e=await u.statusViewService.getStatusList();if(1===e.length){const[{id:t}]=e;u.routerService.push(`/status/${t}`)}},{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});const[a,{loading:i}]=y(async()=>await(async()=>{const[e,t]=await Promise.all([u.symbolGlobalService.getSymbolMap(),u.statusViewService.getStatusList()]);if(!t||0===t.length)return[{type:f.Typography,typoVariant:"h6",placeholder:"Listening for a pending signal...",sx:{textAlign:"center",opacity:.5,mt:4}}];const o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;o[i]||(o[i]=[]),o[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",to:t.id})});const a=Object.entries(o).sort(([,e],[,t])=>t.length-e.length),i=[],r=[],n=[];return a.forEach(([e,t],o)=>{const a=We(e,t);o%2==0?i.push(a):r.push(a),n.push(a)}),[{type:f.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:i},{type:f.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:r},{type:f.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:n}]})(),{onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),deps:[t]});return n(be,{children:[n(g,{items:je,actions:He,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a.length?n(N,{children:[n(w,{className:e.root,fields:a},t),n(S,{paddingBottom:"24px"})]}):n(C,{children:n(x,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>ge(["/status"],e)}],Vt=({id:e})=>n(ue,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{Vt as StatusPage,Vt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,f as o,Q as t,x as i,i as a,O as n,R as l,p as s,a2 as r,Z as c,T as p,b2 as d,W as m,B as u,F as h,a3 as b,E as y,A as f,a5 as g,l as k,n as v,a4 as C,a6 as S,r as x,aD as L,bz as w,bA as P,bB as T,bC as V,bD as $,bE as H,H as z,J as M,N,al as O,X as A,bk as _,a$ as E,G as I,P as F,a1 as R,az as j,bF as G,a8 as D,aI as W,aJ as B,b3 as U,ag as Y,I as J,ad as K,D as Q,aj as X}from"./index-kQlTYlpK.js";import{h as Z}from"./hasRouteMatch-C0K-M4jy.js";import{I as q}from"./IconPhoto-DrGLW-rX.js";import{C as ee,R as oe}from"./Refresh-DixrXBVq.js";import{K as te}from"./KeyboardArrowLeft-BpxUzr7-.js";const ie=e([o("path",{d:"M5 19h14V5H5v14zm4-4h4v-2h-2v-2h2V9H9V7h4c1.1 0 2 .89 2 2v1.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2H9v-2z",opacity:".3"}),o("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-2zm0 16H5V5h14v14zm-4-4v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V9c0-1.11-.9-2-2-2H9v2h4v2h-2v2h2v2H9v2h4c1.1 0 2-.89 2-2z"})],"Looks3TwoTone"),ae=e([o("path",{d:"M19 5H5v14h14V5zm-5 12h-2V9h-2V7h4v10z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm5 4h2v8h2V7h-4z"})],"LooksOneTwoTone"),ne=e([o("path",{d:"M19 5H5v14h14V5zm-4 6c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm8 2H9v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2h-4v-2h2c1.1 0 2-.89 2-2V9c0-1.11-.9-2-2-2z"})],"LooksTwoTwoTone"),le="backtest-kit__groupHeader",se="backtest-kit__groupRoot",re="backtest-kit__symbolImage",ce=s()({root:{[`& .${se}:hover .${le}`]:{opacity:"1 !important"}}});function pe(e){return S(e,"#000000")>S(e,"#FFFFFF")}const de=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"}],me=[{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],ue=(e,t)=>({type:r.Group,className:se,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:r.Component,className:le,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"small",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({symbol:e,label:t,color:i})=>((e,t,i)=>({type:r.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(`/price_chart/${e.toLowerCase()}`)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${re}`]:{transition:"filter 500ms"},"&:hover":{background:()=>pe(i)?k(i,.33):v(i,.33),[`& .${re}`]:{transition:"filter 500ms",filter:pe(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(q,{className:re,symbol:e}),children:o(u,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:t})})}))(e,t,i))}]}),he="backtest-kit__groupHeader",be="backtest-kit__groupRoot",ye="backtest-kit__symbolImage",fe=s()({root:{[`& .${be}:hover .${he}`]:{opacity:"1 !important"}}});function ge(e){return S(e,"#000000")>S(e,"#FFFFFF")}const ke=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:e=>String(e).toUpperCase()}],ve=(e,t)=>({type:r.Group,className:be,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:r.Component,className:he,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"medium",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({label:e,to:t,color:i,icon:n})=>((e,t,i,n)=>({type:r.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(e)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${ye}`]:{transition:"filter 500ms"},"&:hover":{background:()=>ge(i)?k(i,.33):v(i,.33),[`& .${ye}`]:{transition:"filter 500ms",filter:ge(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:ye}),children:t})}))(t,e,i,n))}]}),Ce=s()({root:{position:"relative"},tooltip:{position:"absolute",margin:0,left:5,top:5,backgroundColor:"#343434",zIndex:999,color:"white",fontWeight:"bold",padding:"5px 10px",borderRadius:3,fontSize:"12px",pointerEvents:"none",touchAction:"none"}}),Se={layout:{textColor:"#d4d4d8",backgroundColor:"#ffffff"},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}},xe=({height:e,width:t,items:i,position:a,priceOpen:n,priceStopLoss:l,priceTakeProfit:s})=>{const{classes:r}=Ce(),c=x.useRef(void 0),[p,d]=x.useState(null);return x.useLayoutEffect(()=>{const{current:o}=c,r=L(o,{...Se,localization:{priceFormatter:e=>M(e,N(e))},width:t,height:e,crosshair:{mode:w.Normal,vertLine:{labelVisible:!1},horzLine:{visible:!1,labelVisible:!0}},timeScale:{timeVisible:!0,secondsVisible:!0,tickMarkFormatter:e=>{const o=i.find(o=>o.timestamp===Number(e))||i[0];if(!o||!o.timestamp)return"Invalid date";const t=z(o.timestamp);return t.isValid()?t.format("HH:mm:ss"):"Invalid date"}}}),p=r.addLineSeries({lastValueVisible:!1,color:P[400]}),m=i.map(e=>({time:Math.floor(e.timestamp),value:parseFloat(e.close)}));if(p.setData(m),a&&n){const e="long"===a?P[700]:V[700];p.createPriceLine({price:n,color:e,lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"long"===a?"LONG Entry":"SHORT Entry"})}return l&&p.createPriceLine({price:l,color:$[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"SL"}),s&&p.createPriceLine({price:s,color:H[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"TP"}),r.subscribeCrosshairMove(e=>{if(e.time){const o=i.find(o=>o.timestamp===Number(e.time));if(o){const e=z(o.timestamp).format("DD/MM/YYYY HH:mm:ss"),t=M(o.close,N(o.close));d(`${e}: ${t}`)}else d(null)}else d(null)}),r.timeScale().fitContent(),()=>{r.remove()}},[e,t,i]),o("div",{ref:c,className:r.root,children:p&&o("div",{className:r.tooltip,children:p})})},Le={"1m":"#2979ff","15m":"#f3a43a","1h":"#d500f9"},we={"1m":"1 minute","15m":"15 minutes","1h":"1 hour"};const Pe=({symbol:e,interval:t,reloadSubject:n,downloadSubject:l,onInfoClick:s,disableInfo:r,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h,sx:y})=>{const[f,{loading:g,execute:k}]=i(async()=>await a.exchangeViewService.getLastCandles(e,t),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e,t]}),v=O(f);A(()=>n.subscribe(k)),A(()=>l.subscribe(()=>{const{current:o}=v;!function(e,o="data.json"){const t=new Blob([e],{type:"application/json"}),i=window.URL.createObjectURL(t);a.layoutService.downloadFile(i,o)}(JSON.stringify(o,null,2),`${e}-${t}.json`)}));return o(F,{sx:{...y,display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"clip"},children:[o(u,{sx:{background:Le[t]||"#607d8b",minHeight:"48px",display:"flex",alignItems:"center",pl:2,pr:1},children:[o(p,{variant:"h6",sx:{color:"white",fontWeight:"bold",mr:1},children:we[t]||t}),!!c&&o(b,{variant:"filled",sx:{color:"white"},color:"short"===c?"warning":"success",label:String(c).toUpperCase()}),o(u,{sx:{flex:1}}),o(_,{disabled:r,onClick:s,children:o(E,{style:{color:"white",opacity:r?.5:1}})})]}),o(I,{}),!f||g?o(R,{sx:{height:"100%",width:"100%"}}):o(u,{sx:{position:"relative",flex:1},children:o(j,{style:{position:"absolute"},children:({height:e,width:t})=>o(xe,{items:f,height:e,width:t,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h})})})]})},Te=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:({symbol:e})=>String(e).toUpperCase()},{type:l.Link,action:"back-action",compute:({interval:e})=>String(e).toUpperCase()}],Ve=[{action:"download-now",label:"Download",icon:()=>o(c,{icon:Q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],$e=new D,He=new D,ze=[{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:r.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:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceOpen",title:"Entry",readonly:!0,compute:e=>e.priceOpen?`${M(e.priceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceOpen",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalPriceOpen&&e.originalPriceOpen!==e.priceOpen,compute:e=>e.originalPriceOpen?`${M(e.originalPriceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceTakeProfit",title:"Take Profit",readonly:!0,compute:e=>e.priceTakeProfit?`${M(e.priceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceTakeProfit",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalPriceTakeProfit&&e.originalPriceTakeProfit!==e.priceTakeProfit,compute:e=>e.originalPriceTakeProfit?`${M(e.originalPriceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceStopLoss",title:"Stop Loss",readonly:!0,compute:e=>e.priceStopLoss?`${M(e.priceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceStopLoss",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalPriceStopLoss&&e.originalPriceStopLoss!==e.priceStopLoss,compute:e=>e.originalPriceStopLoss?`${M(e.originalPriceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:r.Component,sx:{mt:2},element:({payload:e})=>o(C,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Me=[{id:"chart",element:({params:e})=>{const t=G(()=>({symbol:String(e.symbol).toUpperCase(),interval:e.interval})),[l,{loading:s,execute:r}]=i(async()=>{const o=String(e.symbol).toUpperCase();return await a.signalViewService.getPendingSignal(o)},{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e.symbol]});A(()=>$e.subscribe(r));const c=x.useMemo(()=>l?l.priceTakeProfit:0,[l]),p=x.useMemo(()=>l?l.priceStopLoss:0,[l]),d=x.useMemo(()=>l?l.priceOpen:0,[l]),m=x.useMemo(()=>l?l.position:null,[l]),[u,h]=W(null),{pickData:b,setOpen:y,render:g}=B({title:"Info",AfterTitle:({onClose:e})=>o(f,{direction:"row",gap:2,children:[o(Y,{onClick:()=>a.layoutService.pickSignal(u.current.id),variant:"outlined",children:"Show Details"}),o(J,{size:"small",onClick:e,children:o(K,{})})]}),payload:()=>({handleClose(){y(!1)}}),fields:ze,handler:()=>u.current,withActionButton:!1}),k=U(async()=>{l&&(h(l),b(l.id))});return o(ee,{children:[o(n,{items:Te,actions:Ve,payload:t,onAction:async o=>{"back-action"===o&&a.routerService.push(`/price_chart/${e.symbol}`),"update-now"===o&&await $e.next(),"download-now"===o&&await He.next()}}),s?null:o(Pe,{symbol:t.symbol,interval:t.interval,disableInfo:!l,reloadSubject:$e,downloadSubject:He,onInfoClick:k,position:m,priceOpen:d,priceStopLoss:p,priceTakeProfit:c,sx:{height:"calc(100dvh - 165px)"}}),g()]})},isActive:e=>Z(["/price_chart/:symbol/:interval"],e)},{id:"coin",element:({params:e})=>{const{classes:t}=fe(),i=e.symbol,l=x.useMemo(()=>[{label:"1 minute",to:`/price_chart/${i}/1m`,color:"#2979ff",icon:ae},{label:"15 minutes",to:`/price_chart/${i}/15m`,color:"#f3a43a",icon:ne},{label:"1 hour",to:`/price_chart/${i}/1h`,color:"#d500f9",icon:ie}],[i]),s=x.useMemo(()=>[ve("Chart",l)],[l]);return o(ee,{children:[o(n,{items:ke,payload:i,onAction:e=>{"back-action"===e&&a.routerService.push("/price_chart")}}),o(m,{className:t.root,fields:s}),o(u,{paddingBottom:"24px"})]})},isActive:e=>Z(["/price_chart/:symbol"],e)},{id:"main",element:()=>{const{classes:e}=ce(),{reloadTrigger:l,doReload:s}=t(),[c,{loading:b}]=i(async()=>await(async()=>{const[e,o]=await Promise.all([a.symbolGlobalService.getSymbolList(),a.symbolGlobalService.getSymbolMap()]),t={};e.forEach((e,i)=>{const a=o[e],n=i+1,l=(null==a?void 0:a.priority)||n;t[l]||(t[l]=[]),t[l].push({symbol:e,label:(null==a?void 0:a.displayName)||e,color:(null==a?void 0:a.color)||"#ccc"})});const i=Object.entries(t).map(([e,o])=>({priority:parseInt(e),routes:o})).sort(({priority:e,routes:{length:o}},{priority:t,routes:{length:i}})=>i-o||t-e),n=[],l=[],s=[];return i.forEach(({routes:e,priority:o},t)=>{const i=ue(`Priority ${o}`,e);t%2==0&&n.push(i),t%2==1&&l.push(i),s.push(i)}),s.length?[{type:r.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:n},{type:r.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:l},{type:r.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:s}]:[]})(),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[l]});return o(ee,{children:[o(n,{items:de,actions:me,onAction:e=>{"back-action"===e&&a.routerService.push("/"),"update-now"===e&&s()}}),b||!c?o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):c.length?o(h,{children:[o(m,{className:e.root,fields:c},l),o(u,{paddingBottom:"24px"})]}):o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"No symbols found"})})]})},isActive:e=>Z(["/price_chart"],e)}],Ne=({symbol:e,interval:t})=>o(X,{history:a.routerService,onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),routes:Me,params:{symbol:e,interval:t}});export{Ne as PriceChartPage,Ne as default};
|
|
1
|
+
import{b as e,f as o,Q as t,x as i,i as a,O as n,R as l,p as s,a2 as r,Z as c,T as p,b2 as d,W as m,B as u,F as h,a3 as b,E as y,A as f,a5 as g,l as k,n as v,a4 as C,a6 as S,r as x,aD as L,bz as w,bA as P,bB as T,bC as V,bD as $,bE as H,H as z,J as M,N,al as O,X as A,bk as _,a$ as E,G as I,P as F,a1 as R,az as j,bF as G,a8 as D,aI as W,aJ as B,b3 as U,ag as Y,I as J,ad as K,D as Q,aj as X}from"./index-BI3k7b1T.js";import{h as Z}from"./hasRouteMatch-CqJJG3sx.js";import{I as q}from"./IconPhoto-Czod_jkW.js";import{C as ee,R as oe}from"./Refresh-3cixHjvW.js";import{K as te}from"./KeyboardArrowLeft-BUZ_pXI5.js";const ie=e([o("path",{d:"M5 19h14V5H5v14zm4-4h4v-2h-2v-2h2V9H9V7h4c1.1 0 2 .89 2 2v1.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2H9v-2z",opacity:".3"}),o("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-2zm0 16H5V5h14v14zm-4-4v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V9c0-1.11-.9-2-2-2H9v2h4v2h-2v2h2v2H9v2h4c1.1 0 2-.89 2-2z"})],"Looks3TwoTone"),ae=e([o("path",{d:"M19 5H5v14h14V5zm-5 12h-2V9h-2V7h4v10z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm5 4h2v8h2V7h-4z"})],"LooksOneTwoTone"),ne=e([o("path",{d:"M19 5H5v14h14V5zm-4 6c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z",opacity:".3"}),o("path",{d:"M5 21h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2zM5 5h14v14H5V5zm8 2H9v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2h-4v-2h2c1.1 0 2-.89 2-2V9c0-1.11-.9-2-2-2z"})],"LooksTwoTwoTone"),le="backtest-kit__groupHeader",se="backtest-kit__groupRoot",re="backtest-kit__symbolImage",ce=s()({root:{[`& .${se}:hover .${le}`]:{opacity:"1 !important"}}});function pe(e){return S(e,"#000000")>S(e,"#FFFFFF")}const de=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"}],me=[{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],ue=(e,t)=>({type:r.Group,className:se,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:r.Component,className:le,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"small",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({symbol:e,label:t,color:i})=>((e,t,i)=>({type:r.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(`/price_chart/${e.toLowerCase()}`)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${re}`]:{transition:"filter 500ms"},"&:hover":{background:()=>pe(i)?k(i,.33):v(i,.33),[`& .${re}`]:{transition:"filter 500ms",filter:pe(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(q,{className:re,symbol:e}),children:o(u,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:t})})}))(e,t,i))}]}),he="backtest-kit__groupHeader",be="backtest-kit__groupRoot",ye="backtest-kit__symbolImage",fe=s()({root:{[`& .${be}:hover .${he}`]:{opacity:"1 !important"}}});function ge(e){return S(e,"#000000")>S(e,"#FFFFFF")}const ke=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:e=>String(e).toUpperCase()}],ve=(e,t)=>({type:r.Group,className:be,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:r.Component,className:he,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(f,{direction:"row",children:[o(b,{variant:"outlined",size:"medium",color:"info",label:`${y.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(u,{flex:1})]})},{type:r.Group,fields:t.map(({label:e,to:t,color:i,icon:n})=>((e,t,i,n)=>({type:r.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(C,{component:g,onClick:()=>{a.routerService.push(e)},sx:{width:"100%",background:i,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${ye}`]:{transition:"filter 500ms"},"&:hover":{background:()=>ge(i)?k(i,.33):v(i,.33),[`& .${ye}`]:{transition:"filter 500ms",filter:ge(i)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:ye}),children:t})}))(t,e,i,n))}]}),Ce=s()({root:{position:"relative"},tooltip:{position:"absolute",margin:0,left:5,top:5,backgroundColor:"#343434",zIndex:999,color:"white",fontWeight:"bold",padding:"5px 10px",borderRadius:3,fontSize:"12px",pointerEvents:"none",touchAction:"none"}}),Se={layout:{textColor:"#d4d4d8",backgroundColor:"#ffffff"},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}},xe=({height:e,width:t,items:i,position:a,priceOpen:n,priceStopLoss:l,priceTakeProfit:s})=>{const{classes:r}=Ce(),c=x.useRef(void 0),[p,d]=x.useState(null);return x.useLayoutEffect(()=>{const{current:o}=c,r=L(o,{...Se,localization:{priceFormatter:e=>M(e,N(e))},width:t,height:e,crosshair:{mode:w.Normal,vertLine:{labelVisible:!1},horzLine:{visible:!1,labelVisible:!0}},timeScale:{timeVisible:!0,secondsVisible:!0,tickMarkFormatter:e=>{const o=i.find(o=>o.timestamp===Number(e))||i[0];if(!o||!o.timestamp)return"Invalid date";const t=z(o.timestamp);return t.isValid()?t.format("HH:mm:ss"):"Invalid date"}}}),p=r.addLineSeries({lastValueVisible:!1,color:P[400]}),m=i.map(e=>({time:Math.floor(e.timestamp),value:parseFloat(e.close)}));if(p.setData(m),a&&n){const e="long"===a?P[700]:V[700];p.createPriceLine({price:n,color:e,lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"long"===a?"LONG Entry":"SHORT Entry"})}return l&&p.createPriceLine({price:l,color:$[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"SL"}),s&&p.createPriceLine({price:s,color:H[500],lineWidth:2,lineStyle:T.Solid,axisLabelVisible:!0,title:"TP"}),r.subscribeCrosshairMove(e=>{if(e.time){const o=i.find(o=>o.timestamp===Number(e.time));if(o){const e=z(o.timestamp).format("DD/MM/YYYY HH:mm:ss"),t=M(o.close,N(o.close));d(`${e}: ${t}`)}else d(null)}else d(null)}),r.timeScale().fitContent(),()=>{r.remove()}},[e,t,i]),o("div",{ref:c,className:r.root,children:p&&o("div",{className:r.tooltip,children:p})})},Le={"1m":"#2979ff","15m":"#f3a43a","1h":"#d500f9"},we={"1m":"1 minute","15m":"15 minutes","1h":"1 hour"};const Pe=({symbol:e,interval:t,reloadSubject:n,downloadSubject:l,onInfoClick:s,disableInfo:r,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h,sx:y})=>{const[f,{loading:g,execute:k}]=i(async()=>await a.exchangeViewService.getLastCandles(e,t),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e,t]}),v=O(f);A(()=>n.subscribe(k)),A(()=>l.subscribe(()=>{const{current:o}=v;!function(e,o="data.json"){const t=new Blob([e],{type:"application/json"}),i=window.URL.createObjectURL(t);a.layoutService.downloadFile(i,o)}(JSON.stringify(o,null,2),`${e}-${t}.json`)}));return o(F,{sx:{...y,display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"clip"},children:[o(u,{sx:{background:Le[t]||"#607d8b",minHeight:"48px",display:"flex",alignItems:"center",pl:2,pr:1},children:[o(p,{variant:"h6",sx:{color:"white",fontWeight:"bold",mr:1},children:we[t]||t}),!!c&&o(b,{variant:"filled",sx:{color:"white"},color:"short"===c?"warning":"success",label:String(c).toUpperCase()}),o(u,{sx:{flex:1}}),o(_,{disabled:r,onClick:s,children:o(E,{style:{color:"white",opacity:r?.5:1}})})]}),o(I,{}),!f||g?o(R,{sx:{height:"100%",width:"100%"}}):o(u,{sx:{position:"relative",flex:1},children:o(j,{style:{position:"absolute"},children:({height:e,width:t})=>o(xe,{items:f,height:e,width:t,position:c,priceOpen:d,priceStopLoss:m,priceTakeProfit:h})})})]})},Te=[{type:l.Link,action:"back-action",label:o(te,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Price Chart"},{type:l.Link,action:"back-action",compute:({symbol:e})=>String(e).toUpperCase()},{type:l.Link,action:"back-action",compute:({interval:e})=>String(e).toUpperCase()}],Ve=[{action:"download-now",label:"Download",icon:()=>o(c,{icon:Q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(c,{icon:oe,color:"#4caf50"})}],$e=new D,He=new D,ze=[{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:r.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:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceOpen",title:"Entry",readonly:!0,compute:e=>e.priceOpen?`${M(e.priceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceOpen",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalPriceOpen&&e.originalPriceOpen!==e.priceOpen,compute:e=>e.originalPriceOpen?`${M(e.originalPriceOpen)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceTakeProfit",title:"Take Profit",readonly:!0,compute:e=>e.priceTakeProfit?`${M(e.priceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceTakeProfit",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalPriceTakeProfit&&e.originalPriceTakeProfit!==e.priceTakeProfit,compute:e=>e.originalPriceTakeProfit?`${M(e.originalPriceTakeProfit)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"priceStopLoss",title:"Stop Loss",readonly:!0,compute:e=>e.priceStopLoss?`${M(e.priceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalPriceStopLoss",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalPriceStopLoss&&e.originalPriceStopLoss!==e.priceStopLoss,compute:e=>e.originalPriceStopLoss?`${M(e.originalPriceStopLoss)}$`:"N/A"},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:r.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:r.Component,sx:{mt:2},element:({payload:e})=>o(C,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Me=[{id:"chart",element:({params:e})=>{const t=G(()=>({symbol:String(e.symbol).toUpperCase(),interval:e.interval})),[l,{loading:s,execute:r}]=i(async()=>{const o=String(e.symbol).toUpperCase();return await a.signalViewService.getPendingSignal(o)},{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[e.symbol]});A(()=>$e.subscribe(r));const c=x.useMemo(()=>l?l.priceTakeProfit:0,[l]),p=x.useMemo(()=>l?l.priceStopLoss:0,[l]),d=x.useMemo(()=>l?l.priceOpen:0,[l]),m=x.useMemo(()=>l?l.position:null,[l]),[u,h]=W(null),{pickData:b,setOpen:y,render:g}=B({title:"Info",AfterTitle:({onClose:e})=>o(f,{direction:"row",gap:2,children:[o(Y,{onClick:()=>a.layoutService.pickSignal(u.current.id),variant:"outlined",children:"Show Details"}),o(J,{size:"small",onClick:e,children:o(K,{})})]}),payload:()=>({handleClose(){y(!1)}}),fields:ze,handler:()=>u.current,withActionButton:!1}),k=U(async()=>{l&&(h(l),b(l.id))});return o(ee,{children:[o(n,{items:Te,actions:Ve,payload:t,onAction:async o=>{"back-action"===o&&a.routerService.push(`/price_chart/${e.symbol}`),"update-now"===o&&await $e.next(),"download-now"===o&&await He.next()}}),s?null:o(Pe,{symbol:t.symbol,interval:t.interval,disableInfo:!l,reloadSubject:$e,downloadSubject:He,onInfoClick:k,position:m,priceOpen:d,priceStopLoss:p,priceTakeProfit:c,sx:{height:"calc(100dvh - 165px)"}}),g()]})},isActive:e=>Z(["/price_chart/:symbol/:interval"],e)},{id:"coin",element:({params:e})=>{const{classes:t}=fe(),i=e.symbol,l=x.useMemo(()=>[{label:"1 minute",to:`/price_chart/${i}/1m`,color:"#2979ff",icon:ae},{label:"15 minutes",to:`/price_chart/${i}/15m`,color:"#f3a43a",icon:ne},{label:"1 hour",to:`/price_chart/${i}/1h`,color:"#d500f9",icon:ie}],[i]),s=x.useMemo(()=>[ve("Chart",l)],[l]);return o(ee,{children:[o(n,{items:ke,payload:i,onAction:e=>{"back-action"===e&&a.routerService.push("/price_chart")}}),o(m,{className:t.root,fields:s}),o(u,{paddingBottom:"24px"})]})},isActive:e=>Z(["/price_chart/:symbol"],e)},{id:"main",element:()=>{const{classes:e}=ce(),{reloadTrigger:l,doReload:s}=t(),[c,{loading:b}]=i(async()=>await(async()=>{const[e,o]=await Promise.all([a.symbolGlobalService.getSymbolList(),a.symbolGlobalService.getSymbolMap()]),t={};e.forEach((e,i)=>{const a=o[e],n=i+1,l=(null==a?void 0:a.priority)||n;t[l]||(t[l]=[]),t[l].push({symbol:e,label:(null==a?void 0:a.displayName)||e,color:(null==a?void 0:a.color)||"#ccc"})});const i=Object.entries(t).map(([e,o])=>({priority:parseInt(e),routes:o})).sort(({priority:e,routes:{length:o}},{priority:t,routes:{length:i}})=>i-o||t-e),n=[],l=[],s=[];return i.forEach(({routes:e,priority:o},t)=>{const i=ue(`Priority ${o}`,e);t%2==0&&n.push(i),t%2==1&&l.push(i),s.push(i)}),s.length?[{type:r.Group,columns:"6",className:"tabletLeftColumn",phoneHidden:!0,desktopHidden:!0,fields:n},{type:r.Group,columns:"6",className:"tabletRightColumn",phoneHidden:!0,desktopHidden:!0,fields:l},{type:r.Group,columns:"12",className:"wideColumn",tabletHidden:!0,fields:s}]:[]})(),{onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),deps:[l]});return o(ee,{children:[o(n,{items:de,actions:me,onAction:e=>{"back-action"===e&&a.routerService.push("/"),"update-now"===e&&s()}}),b||!c?o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):c.length?o(h,{children:[o(m,{className:e.root,fields:c},l),o(u,{paddingBottom:"24px"})]}):o(d,{children:o(p,{variant:"h6",sx:{opacity:.5},children:"No symbols found"})})]})},isActive:e=>Z(["/price_chart"],e)}],Ne=({symbol:e,interval:t})=>o(X,{history:a.routerService,onLoadStart:()=>a.layoutService.setAppbarLoader(!0),onLoadEnd:()=>a.layoutService.setAppbarLoader(!1),routes:Me,params:{symbol:e,interval:t}});export{Ne as PriceChartPage,Ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,f as e,aZ as t,B as o,A as r,a9 as n,T as i,H as s,a3 as c,F as l,G as d,P as h,aO as p,a$ as u,b0 as b,aG as w,a8 as f,i as x,aH as g,al as y,aL as v,O as m,R as S,b1 as L,a_ as k,D as j,Z as A}from"./index-
|
|
1
|
+
import{b as a,f as e,aZ as t,B as o,A as r,a9 as n,T as i,H as s,a3 as c,F as l,G as d,P as h,aO as p,a$ as u,b0 as b,aG as w,a8 as f,i as x,aH as g,al as y,aL as v,O as m,R as S,b1 as L,a_ as k,D as j,Z as A}from"./index-BI3k7b1T.js";import{A as H}from"./Article-CpU7DBcT.js";import{C as R,R as z}from"./Refresh-3cixHjvW.js";import{K as C}from"./KeyboardArrowLeft-BUZ_pXI5.js";const B=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"),D=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(B,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(H,{sx:t})}},E=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:D(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}})]})})}),F=[{action:"download-action",label:"Download",icon:()=>e(A,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(A,{icon:z,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(C,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:L,action:"search-action",label:"Search"}],O=new f,Y=()=>{const[a,o]=b(""),{data:r,hasMore:n,loading:i,onSkip:s}=w({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:O}),c=y(r),{execute:l}=v(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:F,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await O.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void O.next();o(""),O.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:k,hasMore:n,children:r.map(a=>e(E,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,f as a,r as t,bp as i,bq as o,x as r,i as s,br as n,bs as c,bt as l,I as d,ad as p,b1 as h,bu as u,p as b,ah as m,bv as f,a1 as y,T as g,b2 as x,an as v,a5 as w,bw as L,ao as S,bx as k,aZ as A,Y as j,X as C,a8 as N,O as z,R,b7 as E,B as H,Z as T,aj as I}from"./index-
|
|
1
|
+
import{b as e,f as a,r as t,bp as i,bq as o,x as r,i as s,br as n,bs as c,bt as l,I as d,ad as p,b1 as h,bu as u,p as b,ah as m,bv as f,a1 as y,T as g,b2 as x,an as v,a5 as w,bw as L,ao as S,bx as k,aZ as A,Y as j,X as C,a8 as N,O as z,R,b7 as E,B as H,Z as T,aj as I}from"./index-BI3k7b1T.js";import{h as M}from"./hasRouteMatch-CqJJG3sx.js";import{B as V}from"./Background-DISIt7NA.js";import{A as B}from"./Article-CpU7DBcT.js";import{C as D,R as F}from"./Refresh-3cixHjvW.js";import{K}from"./KeyboardArrowLeft-BUZ_pXI5.js";const O=e(a("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"Image"),P=e(a("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"}),"InsertDriveFile"),W="65px",X=e=>e.mimeType.startsWith("image/")?a(O,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(j,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(B,{sx:{color:"#1976d2",fontSize:20}}):a(P,{sx:{color:"#546e7a",fontSize:20}}),Z=b()(e=>({root:{position:"relative",height:"100%",width:"100%",background:"#eee",overflow:"clip"},header:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"8px",paddingRight:"4px",height:W},input:{height:W,paddingRight:e.spacing(2),paddingLeft:e.spacing(1),width:"100%"},container:{position:"absolute",top:W,left:0,right:0,bottom:0,height:`calc(100% - ${W})`,width:"100%",background:"white",overflow:"clip",display:"flex",alignItems:"stretch",justifyContent:"stretch"},content:{display:"flex",flex:1},loader:{height:"100%",width:"100%"},accent:{background:m("#00c3ff",.05)}})),q=({outlinePaper:e,className:b,style:m,sx:j,nodes:C,initialSearch:N=""})=>{const{classes:z,cx:R}=Z(),[E,H]=t.useState(N),T=i(E),[I,{flush:M}]=o(E,2500),[V,{loading:B}]=r(async()=>await(async(e,a)=>{const t=e.trim().toLowerCase(),i=[];let o=0;for(const r of s.explorerHelperService.deepFlat(a))if("file"!==r.type||t&&!r.path.toLowerCase().includes(t)||i.push(r),++o%1e4==0&&await f(0),i.length>25e3)break;return i})(I,C),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),deps:[I,C]}),{execute:D}=n(async e=>{await s.layoutService.pickDumpContent(e)},{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});return a(u,{outlinePaper:e,className:R(z.root,b),style:m,sx:j,children:[a("div",{className:z.header,children:a(c,{disabled:B,className:z.input,endAdornment:a(l,{position:"end",children:a(d,{disabled:B||!E,onClick:()=>{T.once(async()=>{await f(500),M()}),H("")},edge:"end",children:a(E?p:h,{})})}),placeholder:"Search",value:E,onBlur:()=>M(),onChange:({target:e})=>H(e.value),onKeyDown:({key:e,currentTarget:a})=>"Enter"===e&&a.blur()})}),a("div",{className:z.container,children:a("div",{className:z.content,children:V?V.length?a(A,{withScrollbar:!0,children:V.map((e,t)=>a(v,{className:R({[z.accent]:t%2==1}),component:w,onClick:()=>(async e=>{await D(e)})(e.id),children:[a(L,{children:X(e)}),a(S,{primary:e.label,secondary:e.path}),a(k,{content:e.path,label:"Copy path"})]},e.id))}):a(x,{sx:{height:"100%",width:"100%"},children:a(g,{variant:"h6",sx:{opacity:.5},children:"Not found"})}):a(y,{className:z.loader})})})]})},Y=[{type:R.Link,action:"back-action",label:a(K,{sx:{display:"block"}})},{type:R.Link,action:"back-action",label:"Main"},{type:R.Link,action:"back-action",label:"Dump Explorer"}],$=[{action:"update-now",label:"Refresh",icon:()=>a(T,{icon:F,color:"#4caf50"})}],G=new N,J=({params:e})=>{const[t,{loading:i,execute:o}]=r(async()=>await s.explorerViewService.getFolderTree(),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});C(()=>G.subscribe(o));return a(D,{children:[a(z,{items:Y,actions:$,onAction:e=>{"back-action"===e&&s.routerService.push("/"),"update-now"===e&&(s.explorerViewService.clear(),G.next())}}),a(E,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(H,{pr:2,pl:2,children:i||!t?a(x,{children:a(g,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(q,{nodes:t,initialSearch:e.search})})}),a(V,{})]})},Q=[{id:"search",element:J,isActive:e=>M(["/dump/:search"],e)},{id:"main",element:J,isActive:e=>M(["/dump"],e)}],U=({search:e=""})=>a(I,{history:s.routerService,onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),routes:Q,params:{search:e}});export{U as DumpPage,U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,f as t,i as o,aw as a,H as n,ax as l,r as i,ay as r,p as s,T as c,J as d,c as p,P as u,F as m,az as h,aA as g,aB as f,B as y,ao as v,aC as b,aD as x,aa as C,aE as k,aF as w,aG as P,aH as S,aI as L,aJ as M,a2 as N,ag as R,I as $,ad as T,A as D,aK as j,E as B,a4 as I,Z as V,V as A,x as E,aL as O,X as z,a8 as F,O as U,R as W,D as H,aM as G,aN as _,W as Y}from"./index-kQlTYlpK.js";import{I as K}from"./IconPhoto-DrGLW-rX.js";import{C as J,R as X}from"./Refresh-DixrXBVq.js";import{K as Z}from"./KeyboardArrowLeft-BpxUzr7-.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"),Q=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"),ee=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"),te=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"),oe=l(async e=>"live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),{key:([e])=>`${e}`,timeout:45e3}),ae=async(e,t)=>(await oe(t)).filter(t=>"closed"===t.status&&t.symbol===e),ne=async(e,t)=>{const o=await ae(e,t);return{total:o.length,resolvedCount:o.filter(e=>e.pnl.pnlPercentage>0).length,rejectedCount:o.filter(e=>e.pnl.pnlPercentage<=0).length}},le=async(e,t)=>{const o=await ae(e,t),a=e=>Math.abs(e.pnl.priceClose-e.priceTakeProfit)/e.priceTakeProfit<.005,n=e=>Math.abs(e.pnl.priceClose-e.priceStopLoss)/e.priceStopLoss<.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 ae(e,t),l=new Map;for(const i of o){const e=a(n(i.updatedAt)),t=l.get(e)??{resolved:0,rejected:0};i.pnl.pnlPercentage>0?l.set(e,{...t,resolved:t.resolved+1}):l.set(e,{...t,rejected:t.rejected+1})}return Array.from(l.entries()).map(([e,{resolved:t,rejected:o}])=>({stamp:e,count:t+o,resolved:t,rejected:o}))},re=async(e,t)=>{const o=await ae(e,t),a="backtest"===t&&o.length?o.reduce((e,t)=>Math.max(e,t.updatedAt),0):Date.now(),l=n(a).startOf("day").valueOf(),i=l-864e5,r=l-6048e5,s=l-26784e5,c=e=>e.reduce((e,t)=>e+t.pnl.pnlCost,0),d=o.filter(e=>e.updatedAt>=l),p=o.filter(e=>e.updatedAt>=i&&e.updatedAt<l),u=o.filter(e=>e.updatedAt>=r),m=o.filter(e=>e.updatedAt>=s);return{symbol:e,todayRevenue:c(d),yesterdayRevenue:c(p),sevenDaysRevenue:c(u),thirtyOneDaysRevenue:c(m),todayCount:d.length,yesterdayCount:p.length,sevenDaysCount:u.length,thirtyOneDaysCount:m.length}};var se=(e=>(e.Red="#DD4049",e.Orange="#F3A43A",e.Green="#2EA96F",e.Blue="#2979ff",e.Violet="#d500f9",e))(se||{});const ce=i.createContext(null),de=({value:e,children:o})=>t(ce.Provider,{value:e,children:o}),pe=()=>i.useContext(ce);var ue=(e=>(e.Semi="semi",e.Solid="solid",e.Unset="unset",e))(ue||{});const me=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"stretch",whiteSpace:"nowrap",gap:"8px",overflow:"clip",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}}})),he=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=me(),{footerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...s===ue.Solid&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},ge=(e,t=2)=>{let o=1;for(let a=0;a<t;a++)o*=10;return Math.round(e*o)/o},fe=s()({root:{position:"relative",width:"100%",height:"0px"},container:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center"}}),ye=({caption:e})=>{const{classes:o}=fe();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}}})),be=p(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"]}),xe=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=ve(),{backgroundMode:l=ue.Solid,roundDigits:s=2,value:p,caption:u,valueUnit:m="Unit"}=pe(),h=i.useMemo(()=>({...o,...l===ue.Solid&&{backgroundColor:a}}),[a,l,o]);return t(be,{v0:r(e,n.root),v1:h,v2:r(n.content,{[n.solidBackground]:l===ue.Solid,[n.unsetBackground]:l===ue.Unset,[n.semiBackground]:l===ue.Semi}),v3:t(c,{fontWeight:"bold",children:d(ge(p,s))}),v4:t(c,{children:m}),v5:!!u&&t(ye,{caption:u})})},Ce=s()(e=>({root:{display:"flex",alignItems:"center",whiteSpace:"nowrap",fontWeight:700,fontSize:"18px",paddingLeft:"8px",gap:"8px",overflow:"clip",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}}})),ke=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=Ce(),{headerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...(s===ue.Solid||s===ue.Semi)&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},we=s()({root:{overflow:"clip",height:"100%",width:"100%",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},click:{cursor:"pointer"},header:{minHeight:"36px"},content:{flex:1},footer:{minHeight:"32px"}}),Pe=({className:e,style:o})=>{const{classes:a}=we(),{backgroundColor:n,onClick:l,footerLabel:i}=pe();return t(u,{className:r(e,a.root,{[a.click]:!!l}),onClick:l,style:o,children:[t(ke,{backgroundColor:n}),t(xe,{backgroundColor:n,className:a.content}),!!i&&t(he,{backgroundColor:n,className:a.footer})]})},Se=i.memo(({className:e,style:o,...a})=>t(de,{value:a,children:t(Pe,{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})()}`,Me=i.createContext(null),Ne=({value:e,children:o})=>t(Me.Provider,{value:e,children:o}),Re=()=>i.useContext(Me),$e=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",paddingLeft:"20px",paddingRight:"20px",overflow:"clip"},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"}}),Te=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Footer_1",portals:["v3"]}),De=({className:e,style:o})=>{const{classes:a}=$e(),{items:n}=Re();return t(Te,{v0:r(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))})},je=s()(()=>({circle:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%","& > div":{borderRadius:"50%"}}})),Be=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{style:e.v2})}),{name:"Circle_1"}),Ie=({className:e,style:o,lineWidth:a,side:n,color:l,rotate:i})=>{const{classes:s}=je();return t(Be,{v0:r(e,s.circle),v1:{...o},v2:{borderTop:`${a}px solid ${l}`,borderLeft:`${a}px solid ${l}`,borderRight:`${a}px solid transparent`,borderBottom:`${a}px solid transparent`,transform:`rotate(${i}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}})),Ae=({side:e})=>{const{classes:o}=Ve();return t("div",{className:o.dot,style:{height:e,width:e}})},Ee=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}=Ee();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}`}})),Fe=({side:e})=>{const{classes:o}=ze();return t("div",{className:o.dot,style:{height:e,width:e}})},Ue=s()(e=>({pointer:{position:"absolute",left:"21%",width:"29%",bottom:"0%",zIndex:1,transformOrigin:"right center",fill:e.palette.text.primary}})),We=p(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,...l})=>{const{classes:i}=Ue();return t(We,{v0:r(e,i.pointer),v1:{...o,transform:`rotate(${a}deg) scale(${n}) translateX(5px)`},v2:l})},Ge=e=>e*Math.PI/180,_e=(e,t)=>({left:t*Math.cos(Ge(e))+t,top:t*Math.sin(Ge(e))+t}),Ye=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}})),Ke=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Labels_1",portals:["v3"]}),Je=({items:e,side:o})=>{const{classes:a}=Ye(),n=i.useMemo(()=>Math.floor(o/2),[o]);return t(Ke,{v0:a.root,v1:{height:o,width:o},v2:a.container,v3:e.slice(0,e.length-1).map(({angle:e,value:o},l)=>t("span",{className:a.label,style:{..._e(e+180,n),...e<90&&{marginLeft:10},...e>90&&{marginLeft:-10},...e>15&&e<165&&{marginTop:5}},children:o},l))})},Xe=({width:e,side:o,chunks:a,maxValue:n,minValue:l,value:r})=>{const s=i.useMemo(()=>.5*o,[o]),c=i.useMemo(()=>.63*o,[o]),d=i.useMemo(()=>.58*o,[o]),p=i.useCallback(e=>180/(n-l)*(e.minValue-l)+45,[n,l]),u=i.useMemo(()=>Math.min(r/n*180,180),[n,r]),h=i.useMemo(()=>e>o?c/e*1.5:1,[c,e,o]),g=i.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=i.useMemo(()=>[{angle:0,value:0},...g,{angle:180,value:n}],[g,n]);return t(m,{children:[t(He,{angle:u,scale:h}),[...a].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,a)=>t(Ie,{rotate:p(e),color:e.color,side:o,lineWidth:s},`${e.color}-${a}`)),g.map(({angle:e},o)=>t(Oe,{angle:e-90},`${e}-${o}`)),t(Fe,{side:o}),t(Ae,{side:c}),t(Je,{items:f,side:d})]})},Ze=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",overflow:"clip"},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)"}}}),qe=({className:e,height:o,width:a})=>{const{classes:n}=Ze(),{value:l,items:s}=Re(),c=Math.min(2*o,a),d=i.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]),p=i.useMemo(()=>{const e=d.find(({minValue:e,maxValue:t})=>l>=e&&l<=t);if(e)return e.color;return d.reduce((e,t)=>t.minValue>=e.minValue?t:e).color},[d,l]),u=i.useMemo(()=>d.reduce((e,{minValue:t})=>Math.min(e,t),Number.POSITIVE_INFINITY),[d]),m=i.useMemo(()=>d.reduce((e,{maxValue:t})=>Math.max(e,t),Number.NEGATIVE_INFINITY),[d]);return t("div",{className:r(e,n.root),children:t("div",{className:n.container,children:t(Xe,{chunks:d,value:l,minValue:u,maxValue:m,side:c,width:a,color:p})})})},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}}})),et=p(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"]}),tt=({className:e,style:o})=>{const{classes:a}=Qe(),{value:n,roundDigits:l=3,valueUnit:i="Unit"}=Re();return t(et,{v0:r(e,a.root),v1:o,v2:a.container,v3:a.content,v4:t(c,{children:ge(n,l)}),v5:t(c,{children:i})})},ot=s()(e=>({root:{position:"relative",overflow:"clip",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"}})),at=({className:e,style:o})=>{const{classes:a}=ot(),n=e=>{let t=e;return t-=32,t-=12,t-=60,t},l=e=>{let t=e;return t-=12,t};return t(u,{className:r(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(qe,{className:a.chart,height:n(e),width:l(o)}),t(tt,{className:a.note}),t(De,{className:a.footer})]})})})},nt=i.memo(({className:e,style:o,...a})=>t(Ne,{value:a,children:t(at,{className:e,style:o})})),lt=s()({root:{position:"relative",height:10,flex:1},bar:{position:"absolute !important",top:"42%",left:0,right:10}}),it=e=>{const{classes:o}=lt(),a=["done","inprogress","waiting","archive"],n=t=>{var o;return null==(o=e.data[t])?void 0:o.value},l=a.map(t=>{const o=n(t);var a,l;return`${a=t,(null==(l=e.data[a])?void 0:l.title)||t} - ${o}`}).join(" | "),i=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},l)=>{let i=0;if(0!==l)for(let r=l-1;r>=0;r--)i+=n(a[r]);return{value:t>0?t+i:t,key:o,color:e}}).sort(({value:e},{value:t})=>t-e),r=Math.max(...i.map(({value:e})=>e));return t(f,{title:l,arrow:!0,children:t("div",{className:o.root,children:i.map(({color:e,value:a,key:n},l)=>{const i=((e,t=100)=>Math.min(100,Math.round(Math.max(Number(e),0)/t*100)))(a,r);return t(g,{sx:{height:"10px !important",zIndex:`${l+1} !important`,backgroundColor:"transparent !important","& .MuiLinearProgress-bar":{borderTopRightRadius:5,borderBottomRightRadius:5,backgroundColor:`${e} !important`}},variant:"determinate",className:o.bar,value:i},`${l}-${n}`)})})})},rt=s()({root:{display:"flex"},work:{display:"flex",alignItems:"center"},row:{flex:1,paddingLeft:5,paddingRight:5,paddingBottom:15}}),st=({title:e,description:o,avatar:a,done:n,inprogress:l,waiting:i,archive:r})=>{const{classes:s}=rt();return t(y,{className:s.root,children:t(y,{className:s.row,children:[t(y,{className:s.work,children:[t(a,{}),t(v,{primary:e,secondary:o,sx:{flex:"none",marginLeft:"0.5em"}})]}),t(y,{flex:"1",children:t(it,{data:{done:{color:"#7FB537",title:"Take profit",value:n},inprogress:{color:"#4FC0E8",title:"Resolved",value:l},waiting:{color:"#FE9B31",title:"Rejected",value:i},archive:{color:"#FA5F5A",title:"Stop loss",value:r}}})})]})})},ct=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"}}),dt=({items:e,sx:o})=>{const{classes:a}=ct();return t(u,{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(st,{...e},o))})}),t(y,{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(y,{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(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#4FC0E8",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Resolved"})]}),t(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FE9B31",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Rejected"})]}),t(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FA5F5A",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Stop loss"})]})]})]})},pt=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}},mt={color:"#90cbfa",lineWidth:2,crosshairMarkerVisible:!1,lastValueVisible:!1,priceLineVisible:!1},ht=({height:e,width:o,items:a})=>{const{classes:n}=pt(),l=i.useRef(void 0),r=i.useRef(void 0);return i.useLayoutEffect(()=>{const{current:t}=l,{current:n}=r,i=x(t,{...ut,height:e,width:o});i.addLineSeries({...mt}).setData(a);const s=({time:e})=>{if(e)try{const{day:t,month:o,year:l}=e,i=a.find(({time:e})=>e.day===t&&e.month===o&&e.year===l);if(i){const e=Math.round(Math.round(100*i.value)/100);n.innerHTML=`${C("Total")}: ${e}, ${C("Resolved")}: ${i.resolved}, ${C("Rejected")}: ${i.rejected}`}else n.innerHTML=""}catch(t){console.log(t),n.innerHTML=""}else n.innerHTML=""};return i.timeScale().fitContent(),i.subscribeCrosshairMove(s),()=>{i.unsubscribeCrosshairMove(s),i.remove()}},[e,o,a]),t("div",{ref:l,className:n.root,children:t("p",{ref:r,className:n.tooltip})})},gt=({items:e})=>t(h,{children:({height:o,width:a})=>t(ht,{height:o,width:a,items:e})}),ft=s()({root:{},container:{position:"relative",margin:0,padding:0,overflow:"clip"},editor:{position:"absolute",top:0,left:0,right:0,bottom:0}}),yt=({items:e,sx:o})=>{const{classes:a}=ft(),n=i.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(u,{className:a.container,sx:o,children:t("div",{className:a.editor,children:t(gt,{items:n})})})},vt=e=>P({handler:async(t,a)=>{const n=S(t,a);for await(const l of(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,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"finished"}));return"backtest"===e?a:[...t.filter(e=>"opened"===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,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"pending"})),...a]}))(e))if(n([l]).done)break;return n([]).rows}}),bt=[{field:"color",label:B.nbsp,minWidth:45,width:()=>45,format:({symbol:e})=>t(A,{children:async()=>{var a;try{const n=await o.symbolGlobalService.getSymbolMap();return t(te,{sx:{color:(null==(a=n[e])?void 0:a.color)||"#ccc"}})}catch(n){return t(te,{sx:{color:"#ccc"}})}}})},{field:"symbol",label:"Symbol",minWidth:115,width:e=>Math.max(e-45-90-145-80-90-80,45),format:({symbol:e})=>t(y,{sx:{width:"75px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children: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:"Entry",minWidth:145,width:()=>145,format:({buyPrice:e})=>`${d(e)}$`},{field:"pnlEntries",label:"Invested",minWidth:80,width:()=>80,format:({pnlEntries:e})=>`${d(e)}$`},{field:"profitLossPercentage",label:"PNL %",minWidth:90,width:()=>90,format:({profitLossPercentage:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",e.toFixed(2),"%"]})}},{field:"pnlCost",label:"PNL $",minWidth:80,width:()=>80,format:({pnlCost:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",d(e),"$"]})}}],xt=[{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:N.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:N.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:N.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:N.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:N.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:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalTakeProfitPrice",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalTakeProfitPrice&&e.originalTakeProfitPrice!==e.takeProfitPrice,compute:e=>e.originalTakeProfitPrice?`${d(e.originalTakeProfitPrice)}$`:"N/A"},{type:N.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:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalStopLossPrice",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalStopLossPrice&&e.originalStopLossPrice!==e.stopLossPrice,compute:e=>e.originalStopLossPrice?`${d(e.originalStopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlEntries",title:"Invested",readonly:!0,compute:e=>`${d(e.pnlEntries)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"profitLossPercentage",title:"PNL %",readonly:!0,trailingIcon:({data:e})=>e.profitLossPercentage<0?t(q,{sx:{color:"red"}}):t(Q,{sx:{color:"green"}}),compute:e=>`${e.profitLossPercentage>=0?"+":""}${e.profitLossPercentage.toFixed(2)}%`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlCost",title:"PNL $",readonly:!0,compute:e=>`${e.pnlCost>=0?"+":""}${d(e.pnlCost)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:N.Component,sx:{mt:2},element:({payload:e})=>t(I,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Ct=[{label:"Details",icon:()=>t(V,{icon:ee,color:"#4caf50"}),action:"open-action"}],kt=({sx:e,mode:a})=>{const n=vt(a),[l,i]=L(null),{pickData:r,setOpen:s,render:c}=M({title:"Info",AfterTitle:({onClose:e})=>t(D,{direction:"row",gap:2,children:[t(R,{onClick:()=>o.layoutService.pickSignal(l.current.id),variant:"outlined",children:"Show Details"}),t($,{size:"small",onClick:e,children:t(T,{})})]}),payload:()=>({handleClose(){s(!1)}}),fields:xt,handler:()=>l.current,withActionButton:!1});return t(m,{children:[t(u,{sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",background:"whitesmote",overflow:"clip",...e},children:t(j,{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=>{i(e),r(e.id)},onRowAction:(e,t)=>{"open-action"===e&&o.layoutService.pickSignal(t.id)}})}),c()]})},wt=[{type:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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(nt,{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:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({dailyTrades:e})=>t(yt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:e})},{type:N.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:l,resolvedTakeProfitCount:i})=>({title:o||e,description:e,avatar:()=>t(K,{symbol:e}),done:i,archive:n,waiting:a,inprogress:l})).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(dt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o})}},{type:N.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})}],Pt={rejectedCount:0,resolvedCount:0,total:0},St=[{action:"download-action",label:"Download",icon:()=>t(V,{icon:H,color:"#4caf50"})},{divider:!0},{action:"live-action",label:"Switch to LIVE",isVisible:e=>"backtest"===e,icon:()=>t(V,{icon:G,color:"#4caf50"})},{action:"backtest-action",label:"Switch to BACKTEST",isVisible:e=>"live"===e,icon:()=>t(V,{icon:_,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>t(V,{icon:X,color:"#4caf50"})}],Lt=[{type:W.Link,action:"back-action",label:t(Z,{sx:{display:"block"}})},{type:W.Link,action:"back-action",label:"Main"},{type:W.Link,action:"back-action",label:"Dashboard"},{type:W.Link,action:"back-action",compute:e=>`KPI ${String(e).toUpperCase()}`}],Mt=new F,Nt=({mode:e="backtest"})=>{const[a,{loading:n,execute:l}]=E(async()=>{const t=await(async e=>{const t=await o.symbolGlobalService.getSymbolList(),a=await oe(e),n=new Set(a.map(e=>e.symbol));return t.forEach(e=>n.delete(e)),t.concat(Array.from(n))})(e),a=await o.symbolGlobalService.getSymbolMap(),n=new Map,l=[],i={...Pt};let r={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,p]=await Promise.all([ie(t,e),le(t,e),ne(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})}l.push({...c,symbol:t,displayName:(null==(o=a[t])?void 0:o.displayName)||t}),i.rejectedCount+=d.rejectedCount,i.resolvedCount+=d.resolvedCount,i.total+=d.total,r.todayRevenue+=p.todayRevenue,r.yesterdayRevenue+=p.yesterdayRevenue,r.sevenDaysRevenue+=p.sevenDaysRevenue,r.thirtyOneDaysRevenue+=p.thirtyOneDaysRevenue,r.todayCount+=p.todayCount,r.yesterdayCount+=p.yesterdayCount,r.sevenDaysCount+=p.sevenDaysCount,r.thirtyOneDaysCount+=p.thirtyOneDaysCount}));return{dailyTrades:Array.from(n).map(([e,{count:t,resolved:o,rejected:a}])=>({stamp:e,count:t,resolved:o,rejected:a})),successRate:l,tradePerfomance:i,revenueCount:r}},{onLoadStart:()=>o.layoutService.setModalLoader(!0),onLoadEnd:()=>o.layoutService.setModalLoader(!1),deps:[e]}),{execute:i}=O(async()=>{const t=await oe(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(l));return t(J,{children:[t(U,{items:Lt,actions:St,payload:e,onAction:async e=>{"download-action"===e&&await i(),"update-now"===e&&(oe.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(Y,{handler:a,payload:()=>({handleUpdate(){Mt.next()},mode:e}),fields:wt}):null]})};export{Nt as DashboardPage,Nt as default};
|
|
1
|
+
import{b as e,f as t,i as o,aw as a,H as n,ax as l,r as i,ay as r,p as s,T as c,J as d,c as p,P as u,F as m,az as h,aA as g,aB as f,B as y,ao as v,aC as b,aD as x,aa as C,aE as k,aF as w,aG as P,aH as S,aI as L,aJ as M,a2 as N,ag as R,I as $,ad as T,A as D,aK as j,E as B,a4 as I,Z as V,V as A,x as E,aL as O,X as z,a8 as F,O as U,R as W,D as H,aM as G,aN as _,W as Y}from"./index-BI3k7b1T.js";import{I as K}from"./IconPhoto-Czod_jkW.js";import{C as J,R as X}from"./Refresh-3cixHjvW.js";import{K as Z}from"./KeyboardArrowLeft-BUZ_pXI5.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"),Q=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"),ee=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"),te=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"),oe=l(async e=>"live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),{key:([e])=>`${e}`,timeout:45e3}),ae=async(e,t)=>(await oe(t)).filter(t=>"closed"===t.status&&t.symbol===e),ne=async(e,t)=>{const o=await ae(e,t);return{total:o.length,resolvedCount:o.filter(e=>e.pnl.pnlPercentage>0).length,rejectedCount:o.filter(e=>e.pnl.pnlPercentage<=0).length}},le=async(e,t)=>{const o=await ae(e,t),a=e=>Math.abs(e.pnl.priceClose-e.priceTakeProfit)/e.priceTakeProfit<.005,n=e=>Math.abs(e.pnl.priceClose-e.priceStopLoss)/e.priceStopLoss<.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 ae(e,t),l=new Map;for(const i of o){const e=a(n(i.updatedAt)),t=l.get(e)??{resolved:0,rejected:0};i.pnl.pnlPercentage>0?l.set(e,{...t,resolved:t.resolved+1}):l.set(e,{...t,rejected:t.rejected+1})}return Array.from(l.entries()).map(([e,{resolved:t,rejected:o}])=>({stamp:e,count:t+o,resolved:t,rejected:o}))},re=async(e,t)=>{const o=await ae(e,t),a="backtest"===t&&o.length?o.reduce((e,t)=>Math.max(e,t.updatedAt),0):Date.now(),l=n(a).startOf("day").valueOf(),i=l-864e5,r=l-6048e5,s=l-26784e5,c=e=>e.reduce((e,t)=>e+t.pnl.pnlCost,0),d=o.filter(e=>e.updatedAt>=l),p=o.filter(e=>e.updatedAt>=i&&e.updatedAt<l),u=o.filter(e=>e.updatedAt>=r),m=o.filter(e=>e.updatedAt>=s);return{symbol:e,todayRevenue:c(d),yesterdayRevenue:c(p),sevenDaysRevenue:c(u),thirtyOneDaysRevenue:c(m),todayCount:d.length,yesterdayCount:p.length,sevenDaysCount:u.length,thirtyOneDaysCount:m.length}};var se=(e=>(e.Red="#DD4049",e.Orange="#F3A43A",e.Green="#2EA96F",e.Blue="#2979ff",e.Violet="#d500f9",e))(se||{});const ce=i.createContext(null),de=({value:e,children:o})=>t(ce.Provider,{value:e,children:o}),pe=()=>i.useContext(ce);var ue=(e=>(e.Semi="semi",e.Solid="solid",e.Unset="unset",e))(ue||{});const me=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"stretch",whiteSpace:"nowrap",gap:"8px",overflow:"clip",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}}})),he=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=me(),{footerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...s===ue.Solid&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},ge=(e,t=2)=>{let o=1;for(let a=0;a<t;a++)o*=10;return Math.round(e*o)/o},fe=s()({root:{position:"relative",width:"100%",height:"0px"},container:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center"}}),ye=({caption:e})=>{const{classes:o}=fe();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}}})),be=p(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"]}),xe=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=ve(),{backgroundMode:l=ue.Solid,roundDigits:s=2,value:p,caption:u,valueUnit:m="Unit"}=pe(),h=i.useMemo(()=>({...o,...l===ue.Solid&&{backgroundColor:a}}),[a,l,o]);return t(be,{v0:r(e,n.root),v1:h,v2:r(n.content,{[n.solidBackground]:l===ue.Solid,[n.unsetBackground]:l===ue.Unset,[n.semiBackground]:l===ue.Semi}),v3:t(c,{fontWeight:"bold",children:d(ge(p,s))}),v4:t(c,{children:m}),v5:!!u&&t(ye,{caption:u})})},Ce=s()(e=>({root:{display:"flex",alignItems:"center",whiteSpace:"nowrap",fontWeight:700,fontSize:"18px",paddingLeft:"8px",gap:"8px",overflow:"clip",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}}})),ke=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=Ce(),{headerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...(s===ue.Solid||s===ue.Semi)&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},we=s()({root:{overflow:"clip",height:"100%",width:"100%",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},click:{cursor:"pointer"},header:{minHeight:"36px"},content:{flex:1},footer:{minHeight:"32px"}}),Pe=({className:e,style:o})=>{const{classes:a}=we(),{backgroundColor:n,onClick:l,footerLabel:i}=pe();return t(u,{className:r(e,a.root,{[a.click]:!!l}),onClick:l,style:o,children:[t(ke,{backgroundColor:n}),t(xe,{backgroundColor:n,className:a.content}),!!i&&t(he,{backgroundColor:n,className:a.footer})]})},Se=i.memo(({className:e,style:o,...a})=>t(de,{value:a,children:t(Pe,{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})()}`,Me=i.createContext(null),Ne=({value:e,children:o})=>t(Me.Provider,{value:e,children:o}),Re=()=>i.useContext(Me),$e=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",paddingLeft:"20px",paddingRight:"20px",overflow:"clip"},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"}}),Te=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Footer_1",portals:["v3"]}),De=({className:e,style:o})=>{const{classes:a}=$e(),{items:n}=Re();return t(Te,{v0:r(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))})},je=s()(()=>({circle:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%","& > div":{borderRadius:"50%"}}})),Be=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{style:e.v2})}),{name:"Circle_1"}),Ie=({className:e,style:o,lineWidth:a,side:n,color:l,rotate:i})=>{const{classes:s}=je();return t(Be,{v0:r(e,s.circle),v1:{...o},v2:{borderTop:`${a}px solid ${l}`,borderLeft:`${a}px solid ${l}`,borderRight:`${a}px solid transparent`,borderBottom:`${a}px solid transparent`,transform:`rotate(${i}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}})),Ae=({side:e})=>{const{classes:o}=Ve();return t("div",{className:o.dot,style:{height:e,width:e}})},Ee=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}=Ee();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}`}})),Fe=({side:e})=>{const{classes:o}=ze();return t("div",{className:o.dot,style:{height:e,width:e}})},Ue=s()(e=>({pointer:{position:"absolute",left:"21%",width:"29%",bottom:"0%",zIndex:1,transformOrigin:"right center",fill:e.palette.text.primary}})),We=p(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,...l})=>{const{classes:i}=Ue();return t(We,{v0:r(e,i.pointer),v1:{...o,transform:`rotate(${a}deg) scale(${n}) translateX(5px)`},v2:l})},Ge=e=>e*Math.PI/180,_e=(e,t)=>({left:t*Math.cos(Ge(e))+t,top:t*Math.sin(Ge(e))+t}),Ye=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}})),Ke=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Labels_1",portals:["v3"]}),Je=({items:e,side:o})=>{const{classes:a}=Ye(),n=i.useMemo(()=>Math.floor(o/2),[o]);return t(Ke,{v0:a.root,v1:{height:o,width:o},v2:a.container,v3:e.slice(0,e.length-1).map(({angle:e,value:o},l)=>t("span",{className:a.label,style:{..._e(e+180,n),...e<90&&{marginLeft:10},...e>90&&{marginLeft:-10},...e>15&&e<165&&{marginTop:5}},children:o},l))})},Xe=({width:e,side:o,chunks:a,maxValue:n,minValue:l,value:r})=>{const s=i.useMemo(()=>.5*o,[o]),c=i.useMemo(()=>.63*o,[o]),d=i.useMemo(()=>.58*o,[o]),p=i.useCallback(e=>180/(n-l)*(e.minValue-l)+45,[n,l]),u=i.useMemo(()=>Math.min(r/n*180,180),[n,r]),h=i.useMemo(()=>e>o?c/e*1.5:1,[c,e,o]),g=i.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=i.useMemo(()=>[{angle:0,value:0},...g,{angle:180,value:n}],[g,n]);return t(m,{children:[t(He,{angle:u,scale:h}),[...a].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,a)=>t(Ie,{rotate:p(e),color:e.color,side:o,lineWidth:s},`${e.color}-${a}`)),g.map(({angle:e},o)=>t(Oe,{angle:e-90},`${e}-${o}`)),t(Fe,{side:o}),t(Ae,{side:c}),t(Je,{items:f,side:d})]})},Ze=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",overflow:"clip"},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)"}}}),qe=({className:e,height:o,width:a})=>{const{classes:n}=Ze(),{value:l,items:s}=Re(),c=Math.min(2*o,a),d=i.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]),p=i.useMemo(()=>{const e=d.find(({minValue:e,maxValue:t})=>l>=e&&l<=t);if(e)return e.color;return d.reduce((e,t)=>t.minValue>=e.minValue?t:e).color},[d,l]),u=i.useMemo(()=>d.reduce((e,{minValue:t})=>Math.min(e,t),Number.POSITIVE_INFINITY),[d]),m=i.useMemo(()=>d.reduce((e,{maxValue:t})=>Math.max(e,t),Number.NEGATIVE_INFINITY),[d]);return t("div",{className:r(e,n.root),children:t("div",{className:n.container,children:t(Xe,{chunks:d,value:l,minValue:u,maxValue:m,side:c,width:a,color:p})})})},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}}})),et=p(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"]}),tt=({className:e,style:o})=>{const{classes:a}=Qe(),{value:n,roundDigits:l=3,valueUnit:i="Unit"}=Re();return t(et,{v0:r(e,a.root),v1:o,v2:a.container,v3:a.content,v4:t(c,{children:ge(n,l)}),v5:t(c,{children:i})})},ot=s()(e=>({root:{position:"relative",overflow:"clip",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"}})),at=({className:e,style:o})=>{const{classes:a}=ot(),n=e=>{let t=e;return t-=32,t-=12,t-=60,t},l=e=>{let t=e;return t-=12,t};return t(u,{className:r(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(qe,{className:a.chart,height:n(e),width:l(o)}),t(tt,{className:a.note}),t(De,{className:a.footer})]})})})},nt=i.memo(({className:e,style:o,...a})=>t(Ne,{value:a,children:t(at,{className:e,style:o})})),lt=s()({root:{position:"relative",height:10,flex:1},bar:{position:"absolute !important",top:"42%",left:0,right:10}}),it=e=>{const{classes:o}=lt(),a=["done","inprogress","waiting","archive"],n=t=>{var o;return null==(o=e.data[t])?void 0:o.value},l=a.map(t=>{const o=n(t);var a,l;return`${a=t,(null==(l=e.data[a])?void 0:l.title)||t} - ${o}`}).join(" | "),i=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},l)=>{let i=0;if(0!==l)for(let r=l-1;r>=0;r--)i+=n(a[r]);return{value:t>0?t+i:t,key:o,color:e}}).sort(({value:e},{value:t})=>t-e),r=Math.max(...i.map(({value:e})=>e));return t(f,{title:l,arrow:!0,children:t("div",{className:o.root,children:i.map(({color:e,value:a,key:n},l)=>{const i=((e,t=100)=>Math.min(100,Math.round(Math.max(Number(e),0)/t*100)))(a,r);return t(g,{sx:{height:"10px !important",zIndex:`${l+1} !important`,backgroundColor:"transparent !important","& .MuiLinearProgress-bar":{borderTopRightRadius:5,borderBottomRightRadius:5,backgroundColor:`${e} !important`}},variant:"determinate",className:o.bar,value:i},`${l}-${n}`)})})})},rt=s()({root:{display:"flex"},work:{display:"flex",alignItems:"center"},row:{flex:1,paddingLeft:5,paddingRight:5,paddingBottom:15}}),st=({title:e,description:o,avatar:a,done:n,inprogress:l,waiting:i,archive:r})=>{const{classes:s}=rt();return t(y,{className:s.root,children:t(y,{className:s.row,children:[t(y,{className:s.work,children:[t(a,{}),t(v,{primary:e,secondary:o,sx:{flex:"none",marginLeft:"0.5em"}})]}),t(y,{flex:"1",children:t(it,{data:{done:{color:"#7FB537",title:"Take profit",value:n},inprogress:{color:"#4FC0E8",title:"Resolved",value:l},waiting:{color:"#FE9B31",title:"Rejected",value:i},archive:{color:"#FA5F5A",title:"Stop loss",value:r}}})})]})})},ct=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"}}),dt=({items:e,sx:o})=>{const{classes:a}=ct();return t(u,{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(st,{...e},o))})}),t(y,{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(y,{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(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#4FC0E8",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Resolved"})]}),t(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FE9B31",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Rejected"})]}),t(y,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FA5F5A",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Stop loss"})]})]})]})},pt=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}},mt={color:"#90cbfa",lineWidth:2,crosshairMarkerVisible:!1,lastValueVisible:!1,priceLineVisible:!1},ht=({height:e,width:o,items:a})=>{const{classes:n}=pt(),l=i.useRef(void 0),r=i.useRef(void 0);return i.useLayoutEffect(()=>{const{current:t}=l,{current:n}=r,i=x(t,{...ut,height:e,width:o});i.addLineSeries({...mt}).setData(a);const s=({time:e})=>{if(e)try{const{day:t,month:o,year:l}=e,i=a.find(({time:e})=>e.day===t&&e.month===o&&e.year===l);if(i){const e=Math.round(Math.round(100*i.value)/100);n.innerHTML=`${C("Total")}: ${e}, ${C("Resolved")}: ${i.resolved}, ${C("Rejected")}: ${i.rejected}`}else n.innerHTML=""}catch(t){console.log(t),n.innerHTML=""}else n.innerHTML=""};return i.timeScale().fitContent(),i.subscribeCrosshairMove(s),()=>{i.unsubscribeCrosshairMove(s),i.remove()}},[e,o,a]),t("div",{ref:l,className:n.root,children:t("p",{ref:r,className:n.tooltip})})},gt=({items:e})=>t(h,{children:({height:o,width:a})=>t(ht,{height:o,width:a,items:e})}),ft=s()({root:{},container:{position:"relative",margin:0,padding:0,overflow:"clip"},editor:{position:"absolute",top:0,left:0,right:0,bottom:0}}),yt=({items:e,sx:o})=>{const{classes:a}=ft(),n=i.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(u,{className:a.container,sx:o,children:t("div",{className:a.editor,children:t(gt,{items:n})})})},vt=e=>P({handler:async(t,a)=>{const n=S(t,a);for await(const l of(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,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"finished"}));return"backtest"===e?a:[...t.filter(e=>"opened"===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,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"pending"})),...a]}))(e))if(n([l]).done)break;return n([]).rows}}),bt=[{field:"color",label:B.nbsp,minWidth:45,width:()=>45,format:({symbol:e})=>t(A,{children:async()=>{var a;try{const n=await o.symbolGlobalService.getSymbolMap();return t(te,{sx:{color:(null==(a=n[e])?void 0:a.color)||"#ccc"}})}catch(n){return t(te,{sx:{color:"#ccc"}})}}})},{field:"symbol",label:"Symbol",minWidth:115,width:e=>Math.max(e-45-90-145-80-90-80,45),format:({symbol:e})=>t(y,{sx:{width:"75px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children: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:"Entry",minWidth:145,width:()=>145,format:({buyPrice:e})=>`${d(e)}$`},{field:"pnlEntries",label:"Invested",minWidth:80,width:()=>80,format:({pnlEntries:e})=>`${d(e)}$`},{field:"profitLossPercentage",label:"PNL %",minWidth:90,width:()=>90,format:({profitLossPercentage:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",e.toFixed(2),"%"]})}},{field:"pnlCost",label:"PNL $",minWidth:80,width:()=>80,format:({pnlCost:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",d(e),"$"]})}}],xt=[{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:N.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:N.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:N.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:N.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:N.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:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalTakeProfitPrice",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalTakeProfitPrice&&e.originalTakeProfitPrice!==e.takeProfitPrice,compute:e=>e.originalTakeProfitPrice?`${d(e.originalTakeProfitPrice)}$`:"N/A"},{type:N.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:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalStopLossPrice",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalStopLossPrice&&e.originalStopLossPrice!==e.stopLossPrice,compute:e=>e.originalStopLossPrice?`${d(e.originalStopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlEntries",title:"Invested",readonly:!0,compute:e=>`${d(e.pnlEntries)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"profitLossPercentage",title:"PNL %",readonly:!0,trailingIcon:({data:e})=>e.profitLossPercentage<0?t(q,{sx:{color:"red"}}):t(Q,{sx:{color:"green"}}),compute:e=>`${e.profitLossPercentage>=0?"+":""}${e.profitLossPercentage.toFixed(2)}%`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlCost",title:"PNL $",readonly:!0,compute:e=>`${e.pnlCost>=0?"+":""}${d(e.pnlCost)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:N.Component,sx:{mt:2},element:({payload:e})=>t(I,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Ct=[{label:"Details",icon:()=>t(V,{icon:ee,color:"#4caf50"}),action:"open-action"}],kt=({sx:e,mode:a})=>{const n=vt(a),[l,i]=L(null),{pickData:r,setOpen:s,render:c}=M({title:"Info",AfterTitle:({onClose:e})=>t(D,{direction:"row",gap:2,children:[t(R,{onClick:()=>o.layoutService.pickSignal(l.current.id),variant:"outlined",children:"Show Details"}),t($,{size:"small",onClick:e,children:t(T,{})})]}),payload:()=>({handleClose(){s(!1)}}),fields:xt,handler:()=>l.current,withActionButton:!1});return t(m,{children:[t(u,{sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",background:"whitesmote",overflow:"clip",...e},children:t(j,{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=>{i(e),r(e.id)},onRowAction:(e,t)=>{"open-action"===e&&o.layoutService.pickSignal(t.id)}})}),c()]})},wt=[{type:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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?se.Red:o>0?se.Green:se.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:N.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(nt,{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:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({dailyTrades:e})=>t(yt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:e})},{type:N.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:l,resolvedTakeProfitCount:i})=>({title:o||e,description:e,avatar:()=>t(K,{symbol:e}),done:i,archive:n,waiting:a,inprogress:l})).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(dt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o})}},{type:N.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})}],Pt={rejectedCount:0,resolvedCount:0,total:0},St=[{action:"download-action",label:"Download",icon:()=>t(V,{icon:H,color:"#4caf50"})},{divider:!0},{action:"live-action",label:"Switch to LIVE",isVisible:e=>"backtest"===e,icon:()=>t(V,{icon:G,color:"#4caf50"})},{action:"backtest-action",label:"Switch to BACKTEST",isVisible:e=>"live"===e,icon:()=>t(V,{icon:_,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>t(V,{icon:X,color:"#4caf50"})}],Lt=[{type:W.Link,action:"back-action",label:t(Z,{sx:{display:"block"}})},{type:W.Link,action:"back-action",label:"Main"},{type:W.Link,action:"back-action",label:"Dashboard"},{type:W.Link,action:"back-action",compute:e=>`KPI ${String(e).toUpperCase()}`}],Mt=new F,Nt=({mode:e="backtest"})=>{const[a,{loading:n,execute:l}]=E(async()=>{const t=await(async e=>{const t=await o.symbolGlobalService.getSymbolList(),a=await oe(e),n=new Set(a.map(e=>e.symbol));return t.forEach(e=>n.delete(e)),t.concat(Array.from(n))})(e),a=await o.symbolGlobalService.getSymbolMap(),n=new Map,l=[],i={...Pt};let r={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,p]=await Promise.all([ie(t,e),le(t,e),ne(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})}l.push({...c,symbol:t,displayName:(null==(o=a[t])?void 0:o.displayName)||t}),i.rejectedCount+=d.rejectedCount,i.resolvedCount+=d.resolvedCount,i.total+=d.total,r.todayRevenue+=p.todayRevenue,r.yesterdayRevenue+=p.yesterdayRevenue,r.sevenDaysRevenue+=p.sevenDaysRevenue,r.thirtyOneDaysRevenue+=p.thirtyOneDaysRevenue,r.todayCount+=p.todayCount,r.yesterdayCount+=p.yesterdayCount,r.sevenDaysCount+=p.sevenDaysCount,r.thirtyOneDaysCount+=p.thirtyOneDaysCount}));return{dailyTrades:Array.from(n).map(([e,{count:t,resolved:o,rejected:a}])=>({stamp:e,count:t,resolved:o,rejected:a})),successRate:l,tradePerfomance:i,revenueCount:r}},{onLoadStart:()=>o.layoutService.setModalLoader(!0),onLoadEnd:()=>o.layoutService.setModalLoader(!1),deps:[e]}),{execute:i}=O(async()=>{const t=await oe(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(l));return t(J,{children:[t(U,{items:Lt,actions:St,payload:e,onAction:async e=>{"download-action"===e&&await i(),"update-now"===e&&(oe.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(Y,{handler:a,payload:()=>({handleUpdate(){Mt.next()},mode:e}),fields:wt}):null]})};export{Nt as DashboardPage,Nt as default};
|