@backtest-kit/ui 13.5.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -170
- package/build/modules/frontend/build/assets/{Article-C7I5Jc2B.js → Article-CJq_3XCa.js} +1 -1
- package/build/modules/frontend/build/assets/{Background-xwzJo61H.js → Background-xfzkOWU4.js} +1 -1
- package/build/modules/frontend/build/assets/{IconPhoto-DrGLW-rX.js → IconPhoto-C03KsEBk.js} +1 -1
- package/build/modules/frontend/build/assets/{KeyboardArrowLeft-BpxUzr7-.js → KeyboardArrowLeft-bxIYZMcN.js} +1 -1
- package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-BTv5MH3G.js → PictureAsPdfOutlined-BF2HVAsQ.js} +1 -1
- package/build/modules/frontend/build/assets/{Refresh-DixrXBVq.js → Refresh-DdJstAqE.js} +1 -1
- package/build/modules/frontend/build/assets/emitters-Bc8GPUEm.js +1 -0
- package/build/modules/frontend/build/assets/{hasRouteMatch-C0K-M4jy.js → hasRouteMatch-Cp7g01zK.js} +1 -1
- package/build/modules/frontend/build/assets/{html2canvas-Xo2SFHzw.js → html2canvas-Dt1QJQhu.js} +1 -1
- package/build/modules/frontend/build/assets/{index-D6fbkGDu.js → index-BNUzSs1I.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CwqHMGtu.js → index-C1E7RvS-.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DFbdj6KX.js → index-C2Y1SjOE.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CtY-cILX.js → index-CPb9eGRj.js} +1 -1
- package/build/modules/frontend/build/assets/{index-wMYoZqi-.js → index-D4Et3yR7.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DeRxtBVy.js → index-D6o_GY5U.js} +1 -1
- package/build/modules/frontend/build/assets/{index-BO8_0_6f.js → index-D9Uifv6Q.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DP-GjNGC.js → index-DVm8eb9u.js} +1 -1
- package/build/modules/frontend/build/assets/{index-kQlTYlpK.js → index-Djrg7_-q.js} +8 -8
- package/build/modules/frontend/build/assets/{index-wq7wFKoe.js → index-Dv74783d.js} +1 -1
- package/build/modules/frontend/build/assets/{index-D7cEguAr.js → index-FvAL5guC.js} +1 -1
- package/build/modules/frontend/build/assets/{index-S9fsmR5b.js → index-YIWBv-S7.js} +1 -1
- package/build/modules/frontend/build/assets/{index-Giwjzoy7.js → index-qAqr3b-l.js} +1 -1
- package/build/modules/frontend/build/assets/{index.es-BiwqIRwO.js → index.es-DKkSWzSw.js} +1 -1
- package/build/modules/frontend/build/assets/{markdownit-By9-eJJI.js → markdownit-DMpqEulr.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-Djrg7_-q.js";import{h as ge}from"./hasRouteMatch-Cp7g01zK.js";import{I as he}from"./IconPhoto-C03KsEBk.js";import{C as be,R as fe}from"./Refresh-DdJstAqE.js";import{K as ve}from"./KeyboardArrowLeft-bxIYZMcN.js";import{B as xe}from"./Background-xfzkOWU4.js";import{r as Ce}from"./emitters-Bc8GPUEm.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{g as e,a as t,b as a,f as o,r,u as n,_ as i,d as s,I as l,C as c,e as d,j as p,k as h,s as v,P as m,l as u,n as g,T as f,o as y,B as w,M as $,t as x,p as b,q as S,D as z,F as C,v as P,i as L,w as M,Q as k,x as A,y as V,X as R,z as N,L as D,A as H,E as T,G as F,H as I,J as B,K as W,N as E,O,R as j,V as Y,W as J,Y as _,Z as G,$ as U,a0 as q,a1 as Z,a2 as K,a3 as Q,a4 as X,a5 as ee,a6 as te,a7 as ae}from"./index-kQlTYlpK.js";import{r as oe}from"./emitters-ByKSsASU.js";import{C as re,R as ne}from"./Refresh-DixrXBVq.js";function ie(t){return e("MuiAlert",t)}const se=t("MuiAlert",["root","action","icon","message","filled","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),le=a(o("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),ce=a(o("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),de=a(o("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),pe=a(o("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),he=["action","children","className","closeText","color","components","componentsProps","icon","iconMapping","onClose","role","severity","slotProps","slots","variant"],ve=v(m,{name:"MuiAlert",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[a.variant],t[`${a.variant}${p(a.color||a.severity)}`]]}})(({theme:e,ownerState:t})=>{const a="light"===e.palette.mode?u:g,o="light"===e.palette.mode?g:u,r=t.color||t.severity;return s({},e.typography.body2,{backgroundColor:"transparent",display:"flex",padding:"6px 16px"},r&&"standard"===t.variant&&{color:e.vars?e.vars.palette.Alert[`${r}Color`]:a(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:o(e.palette[r].light,.9),[`& .${se.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}},r&&"outlined"===t.variant&&{color:e.vars?e.vars.palette.Alert[`${r}Color`]:a(e.palette[r].light,.6),border:`1px solid ${(e.vars||e).palette[r].light}`,[`& .${se.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}},r&&"filled"===t.variant&&s({fontWeight:e.typography.fontWeightMedium},e.vars?{color:e.vars.palette.Alert[`${r}FilledColor`],backgroundColor:e.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:"dark"===e.palette.mode?e.palette[r].dark:e.palette[r].main,color:e.palette.getContrastText(e.palette[r].main)}))}),me=v("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(e,t)=>t.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),ue=v("div",{name:"MuiAlert",slot:"Message",overridesResolver:(e,t)=>t.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),ge=v("div",{name:"MuiAlert",slot:"Action",overridesResolver:(e,t)=>t.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),fe={success:o(le,{fontSize:"inherit"}),warning:o(ce,{fontSize:"inherit"}),error:o(de,{fontSize:"inherit"}),info:o(pe,{fontSize:"inherit"})},ye=r.forwardRef(function(e,t){var a,r,v,m,u,g;const f=n({props:e,name:"MuiAlert"}),{action:y,children:w,className:$,closeText:x="Close",color:b,components:S={},componentsProps:z={},icon:C,iconMapping:P=fe,onClose:L,role:M="alert",severity:k="success",slotProps:A={},slots:V={},variant:R="standard"}=f,N=i(f,he),D=s({},f,{color:b,severity:k,variant:R}),H=(e=>{const{variant:t,color:a,severity:o,classes:r}=e,n={root:["root",`${t}${p(a||o)}`,`${t}`],icon:["icon"],message:["message"],action:["action"]};return h(n,ie,r)})(D),T=null!=(a=null!=(r=V.closeButton)?r:S.CloseButton)?a:l,F=null!=(v=null!=(m=V.closeIcon)?m:S.CloseIcon)?v:c,I=null!=(u=A.closeButton)?u:z.closeButton,B=null!=(g=A.closeIcon)?g:z.closeIcon;return o(ve,s({role:M,elevation:0,ownerState:D,className:d(H.root,$),ref:t},N,{children:[!1!==C?o(me,{ownerState:D,className:H.icon,children:C||P[k]||fe[k]}):null,o(ue,{ownerState:D,className:H.message,children:w}),null!=y?o(ge,{ownerState:D,className:H.action,children:y}):null,null==y&&L?o(ge,{ownerState:D,className:H.action,children:o(T,s({size:"small","aria-label":x,title:x,color:"inherit",onClick:L},I,{children:o(F,s({fontSize:"small"},B))}))}):null]}))}),we=a([o("path",{d:"M13 17c-1.1 0-2-.9-2-2V9c0-1.1.9-2 2-2h6V5H5v14h14v-2h-6z",opacity:".3"}),o("path",{d:"M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.38-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z"}),o("circle",{cx:"16",cy:"12",r:"1.5"})],"AccountBalanceWalletTwoTone"),$e=a([o("path",{d:"M8 6h8v6H8zm11 8H5c-.55 0-1 .45-1 1v3h16v-3c0-.55-.45-1-1-1zm-1 3c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z",opacity:".3"}),o("path",{d:"M19 12h-1V4H6v8H5c-1.66 0-3 1.34-3 3v5h20v-5c0-1.66-1.34-3-3-3zM8 6h8v6H8V6zm12 12H4v-3c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v3z"}),o("circle",{cx:"18",cy:"16",r:"1"})],"AdfScannerTwoTone"),xe=a([o("path",{d:"M9 4H7v2H5v12h2v2h2v-2h2V6H9V4zm0 12H7V8h2v8z"}),o("path",{d:"M7 8h2v8H7zm8 2h2v3h-2z",opacity:".3"}),o("path",{d:"M19 8h-2V4h-2v4h-2v7h2v5h2v-5h2V8zm-2 5h-2v-3h2v3z"})],"CandlestickChartTwoTone"),be=a([o("path",{d:"M12 4c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm0 14.5c-.83 0-1.5-.67-1.5-1.5h3c0 .83-.67 1.5-1.5 1.5zm5-2.5H7v-2h1v-2.61C8 9.27 9.03 7.47 11 7v-.5c0-.57.43-1 1-1s1 .43 1 1V7c1.97.47 3 2.28 3 4.39V14h1v2z",opacity:".3"}),o("path",{d:"M12 18.5c.83 0 1.5-.67 1.5-1.5h-3c0 .83.67 1.5 1.5 1.5zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4-8.61c0-2.11-1.03-3.92-3-4.39v-.5c0-.57-.43-1-1-1s-1 .43-1 1V7c-1.97.47-3 2.27-3 4.39V14H7v2h10v-2h-1v-2.61zM14 14h-4v-3c0-1.1.9-2 2-2s2 .9 2 2v3z"})],"CircleNotificationsTwoTone"),Se=a(o("path",{d:"M21.5 14.98c-.02 0-.03 0-.05.01C21.2 13.3 19.76 12 18 12c-1.4 0-2.6.83-3.16 2.02C13.26 14.1 12 15.4 12 17c0 1.66 1.34 3 3 3l6.5-.02c1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5zM10 4.26v2.09C7.67 7.18 6 9.39 6 12c0 1.77.78 3.34 2 4.44V14h2v6H4v-2h2.73C5.06 16.54 4 14.4 4 12c0-3.73 2.55-6.85 6-7.74zM20 6h-2.73c1.43 1.26 2.41 3.01 2.66 5h-2.02c-.23-1.36-.93-2.55-1.91-3.44V10h-2V4h6v2z"}),"CloudSync"),ze=a(o("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Ce=a(o("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),Pe=a([o("path",{d:"M14 4H6v16h12V8h-4V4zm2 7v4c0 2.21-1.79 4-4 4s-4-1.79-4-4V9.5C8 8.12 9.12 7 10.5 7S13 8.12 13 9.5V15h-2V9.5c0-.28-.22-.5-.5-.5s-.5.22-.5.5V15c0 1.1.9 2 2 2s2-.9 2-2v-4h2z",opacity:".3"}),o("path",{d:"M14 15c0 1.1-.9 2-2 2s-2-.9-2-2V9.5c0-.28.22-.5.5-.5s.5.22.5.5V15h2V9.5C13 8.12 11.88 7 10.5 7S8 8.12 8 9.5V15c0 2.21 1.79 4 4 4s4-1.79 4-4v-4h-2v4z"}),o("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h8v4h4v12z"})],"FilePresentTwoTone"),Le=a([o("path",{d:"M19 5H5v14h14V5zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z",opacity:".3"}),o("path",{d:"M3 5v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2zm2 0h14v14H5V5zm2 5h2v7H7zm4-3h2v10h-2zm4 6h2v4h-2z"})],"InsertChartTwoTone"),Me=a([o("path",{d:"M10 5h4v14h-4V5zm-6 6h4v8H4v-8zm16 8h-4v-6h4v6z",opacity:".3"}),o("path",{d:"M16 11V3H8v6H2v12h20V11h-6zm-6-6h4v14h-4V5zm-6 6h4v8H4v-8zm16 8h-4v-6h4v6z"})],"LeaderboardTwoTone"),ke=a(o(r.Fragment,{children:[o("path",{d:"M12 20c4.41 0 8-3.59 8-8s-3.59-8-8-8-8 3.59-8 8 3.59 8 8 8zM10 7.5l6 4.5-6 4.5v-9z",opacity:".3"}),o("path",{d:"M12 22c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10zm0-18c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8zm-2 3.5v9l6-4.5z"})]}),"PlayCircleFilledWhiteTwoTone"),Ae=a([o("path",{d:"M4 18h16V8H4v10zm8-3h6v2h-6v-2zm-5.91-4.59L7.5 9l4 4-4 4-1.41-1.41L8.67 13l-2.58-2.59z",opacity:".3"}),o("path",{d:"M12 15h6v2h-6z"}),o("path",{d:"M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm0 14H4V8h16v10z"}),o("path",{d:"m7.5 17 4-4-4-4-1.41 1.41L8.67 13l-2.58 2.59z"})],"TerminalTwoTone"),Ve=b()(e=>({root:{marginTop:e.spacing(1),marginBottom:e.spacing(2),marginLeft:e.spacing(2),marginRight:e.spacing(3),background:"white",transition:"opacity 500ms","&:hover":{opacity:1},opacity:.35,cursor:"pointer"},open:{opacity:1},expandButton:{cursor:"pointer !important",marginLeft:e.spacing(1)},copyButton:{cursor:"pointer !important",marginRight:e.spacing(1)},downloadButton:{cursor:"pointer !important"}})),Re=(e,t="%")=>e?`${e.toFixed(2)}${t}`:"—",Ne=e=>e?`${e.toFixed(1)} min`:"—",De=e=>window.Translate?window.Translate.translateText(e):e,He=({data:e})=>{const{classes:t,cx:a}=Ve(),[n,i]=r.useState(!1),s=(e=>{const{context:t,portfolioTotalPnl:a,portfolioSharpeRatio:o,portfolioTotalTrades:r,portfolioStdDev:n,portfolioSortinoRatio:i,portfolioCalmarRatio:s,portfolioRecoveryFactor:l,portfolioExpectancy:c,portfolioAvgPeakPnl:d,portfolioAvgFallPnl:p,portfolioPeakProfitPnl:h,portfolioMaxDrawdownPnl:v,portfolioAvgDuration:m,portfolioMedianPnl:u,portfolioAvgConsecutiveWinPnl:g,portfolioAvgConsecutiveLossPnl:f,portfolioAvgWinDuration:y,portfolioAvgLossDuration:w,portfolioAnnualizedSharpeRatio:$,portfolioCertaintyRatio:x,portfolioExpectedYearlyReturns:b,portfolioTradesPerYear:S,symbols:z,backtest:C}=e,P=De(C?"Backtest":"Live"),L=t.frameName?` / ${t.frameName}`:"",M=[`## ${P}: ${t.strategyName} / ${t.exchangeName}${L}`,"",`**${De("Total PNL")}:** ${Re(a)} `,`**Sharpe Ratio:** ${Re(o,"")} `,`**${De("Annualized Sharpe")}:** ${Re($,"")} `,`**${De("Certainty Ratio")}:** ${Re(x,"")} `,`**${De("Expected Yearly Returns")}:** ${Re(b)} `,`**${De("Trades Per Year")}:** ${null!==S?S.toFixed(1):"—"} `,`**${De("Total trades")}:** ${r} `,`**${De("Standard Deviation Per Trade")}:** ${Re(n)} `,`**${De("Sortino Ratio")}:** ${Re(i,"")} `,`**${De("Calmar Ratio")}:** ${Re(s,"")} `,`**${De("Recovery Factor Per Equity Drawdown")}:** ${Re(l,"")} `,`**${De("Expectancy")}:** ${Re(c)} `,`**${De("Median PNL")}:** ${Re(u)} `,`**${De("Avg Peak PNL")}:** ${Re(d)} `,`**${De("Avg Drawdown PNL")}:** ${Re(p)} `,`**${De("Peak Profit PNL")}:** ${Re(h)} `,`**${De("Max Drawdown PNL")}:** ${Re(v)} `,`**${De("Avg Duration")}:** ${Ne(m)} `,`**${De("Avg Win Duration")}:** ${Ne(y)} `,`**${De("Avg Loss Duration")}:** ${Ne(w)} `,`**${De("Avg Consecutive Win PNL")}:** ${Re(g)} `,`**${De("Avg Consecutive Loss PNL")}:** ${Re(f)}`,""];for(const k of z)M.push(`### ${k.symbol}`,"",`**PNL:** ${Re(k.totalPnl)} `,`**${De("Avg PNL")}:** ${Re(k.avgPnl)} `,`**${De("Median PNL")}:** ${Re(k.medianPnl)} `,`**Win Rate:** ${Re(k.winRate)} `,`**Profit Factor:** ${Re(k.profitFactor,"")} `,`**Max Drawdown:** ${Re(k.maxDrawdown)} `,`**Expectancy:** ${Re(k.expectancy)} `,`**Sharpe Ratio:** ${Re(k.sharpeRatio,"")} `,`**Annualized Sharpe:** ${Re(k.annualizedSharpeRatio,"")} `,`**Certainty Ratio:** ${Re(k.certaintyRatio,"")} `,`**Expected Yearly Returns:** ${Re(k.expectedYearlyReturns)} `,`**Trades Per Year:** ${null!==k.tradesPerYear?k.tradesPerYear.toFixed(1):"—"} `,`**Sortino Ratio:** ${Re(k.sortinoRatio,"")} `,`**Calmar Ratio:** ${Re(k.calmarRatio,"")} `,`**Recovery Factor Per Equity Drawdown:** ${Re(k.recoveryFactor,"")} `,`**Standard Deviation:** ${Re(k.stdDev)} `,`**Avg Win:** ${Re(k.avgWin)} `,`**Avg Loss:** ${Re(k.avgLoss)} `,`**Max Win Streak:** ${k.maxWinStreak} `,`**Max Loss Streak:** ${k.maxLossStreak} `,`**Avg Peak PNL:** ${Re(k.avgPeakPnl)} `,`**Avg Drawdown PNL:** ${Re(k.avgFallPnl)} `,`**Peak Profit PNL:** ${Re(k.peakProfitPnl)} `,`**Max Drawdown PNL:** ${Re(k.maxDrawdownPnl)} `,`**Avg Duration:** ${Ne(k.avgDuration)} `,`**Avg Win Duration:** ${Ne(k.avgWinDuration)} `,`**Avg Loss Duration:** ${Ne(k.avgLossDuration)} `,`**Avg Consecutive Win PNL:** ${Re(k.avgConsecutiveWinPnl)} `,`**Avg Consecutive Loss PNL:** ${Re(k.avgConsecutiveLossPnl)} `,`**${De("Trades")}:** ${k.totalTrades}`,"");return M.join("\n")})(e),c=()=>{i(!n)},d=async e=>{e.stopPropagation(),await M(s)},p=async e=>{e.stopPropagation(),await P(s)&&L.alertService.notify("Copied!")};return o(ye,{className:a(t.root,{[t.open]:n}),action:o(C,{children:[o(l,{className:t.copyButton,onClick:p,size:"small",children:o(S,{})}),o(l,{className:t.downloadButton,onClick:d,size:"small",children:o(z,{})}),o(l,{className:t.expandButton,onClick:c,size:"small",children:o(n?ze:Ce,{})})]}),onClick:c,variant:"outlined",severity:"info",children:o(f,{minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",width:"100%",children:[o(f,{variant:"body2",sx:{opacity:n?.5:1,transition:"opacity 500ms"},minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",children:[e.backtest?"Backtest":"Live",": ",e.context.strategyName]}),o(y,{in:n,timeout:"auto",unmountOnExit:!0,children:[o(w,{paddingBottom:"16px"}),o($,{content:s}),o(w,{paddingBottom:"32px"})]}),!n&&o(f,{variant:"caption",sx:{opacity:.7,mt:1},children:[x(s).slice(0,150),"..."]})]})})},Te="backtest-kit__groupHeader",Fe="backtest-kit__groupRoot",Ie="backtest-kit__symbolImage",Be=b()({root:{[`& .${Fe}:hover .${Te}`]:{opacity:"1 !important"}}});function We(e){return te(e,"#000000")>te(e,"#FFFFFF")}const Ee=[{type:j.Component,element:()=>{const{reloadTrigger:e,doReload:t}=k(15e3),[a,{execute:r}]=A(async()=>{L.runtimeViewService.getRuntimeInfo.clear();const e=V(L.runtimeViewService.getRuntimeInfo,{defaultValue:null});return await e()},{onLoadStart:()=>L.layoutService.setAppbarLoader(!0),onLoadEnd:()=>L.layoutService.setAppbarLoader(!1),deps:[e]});R(()=>oe.subscribe(r));return o(H,{direction:"row",alignItems:"center",children:[o(N,{"aria-label":"breadcrumb",children:[o(D,{underline:"always",color:"inherit",href:"#",onClick:e=>e.preventDefault(),children:"Main"}),o(D,{underline:"always",color:"inherit",href:"#",onClick:e=>e.preventDefault(),children:"Navigation"})]}),o(w,{flex:1}),(()=>{if(!a)return null;const{symbol:e,when:r,currentPrice:n,backtest:i}=a;return o(W,{placement:"bottom",description:i?"Backtest mode":"Live mode",children:o(H,{direction:"row",alignItems:"center",spacing:1,sx:{display:{xs:"none",sm:"flex"},cursor:"pointer",userSelect:"none"},onClick:()=>{L.runtimeViewService.getRuntimeInfo.clear(),t()},children:[o(l,{size:"small",children:o(Se,{})}),o(f,{variant:"body2",sx:{opacity:.5},children:["Symbol:",T.nbsp,o("b",{children:e})]}),o(F,{orientation:"vertical",flexItem:!0}),o(f,{variant:"body2",sx:{opacity:.5},children:["Time:",T.nbsp,o("b",{children:I(r).format("HH:mm DD MMM YYYY")})]}),o(F,{orientation:"vertical",flexItem:!0}),o(f,{variant:"body2",sx:{opacity:.5},children:["Price:",T.nbsp,o("b",{children:[B(n,E(n)),"$"]})]})]})})})(),o(w,{pr:1})]})}}],Oe=[{action:"download-json",label:"Download Heatmap JSON",icon:()=>o(G,{icon:_,color:"#4caf50"})},{action:"download-markdown",label:"Download Heatmap Markdown",icon:()=>o(G,{icon:U,color:"#4caf50"})},{action:"download-pdf",label:"Download Heatmap PDF",icon:()=>o(G,{icon:q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(G,{icon:ne,color:"#4caf50"})}],je=(e,t)=>({type:K.Group,className:Fe,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:K.Component,className:Te,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(H,{direction:"row",children:[o(Q,{variant:"outlined",size:"medium",color:"info",label:`${T.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(w,{flex:1})]})},{type:K.Group,fields:t.map(({label:e,description:t,to:a,color:r,icon:n})=>((e,t,a,r,n)=>({type:K.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(W,{description:a,children:o(X,{component:ee,onClick:()=>{L.routerService.push(e)},sx:{width:"100%",background:r,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${Ie}`]:{transition:"filter 500ms"},"&:hover":{background:()=>We(r)?u(r,.33):g(r,.33),[`& .${Ie}`]:{transition:"filter 500ms",filter:We(r)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:Ie}),children:t})})}))(a,e,t,r,n))}]}),Ye=[{label:"Portfolio Overview",description:ae.newline("Closed trading signals grouped by symbol for Backtest and Live modes","Each card shows position type, entry price, TP/SL levels, PNL amount and percent","Displays DCA entry count and partial close count where applicable","Supports JSON export and manual refresh of the signal list"),to:"/overview",color:"#0033AD",icon:we},{label:"PNL Performance",description:ae.newline("KPI dashboard with aggregated trading performance metrics per symbol","Shows daily trade counts, success rates, resolved/rejected breakdowns","Revenue analytics across today, yesterday, 7-day and 31-day windows","Toggle between Backtest and Live modes; supports JSON export"),to:"/dashboard",color:"#E6007A",icon:Le},{label:"System Logs",description:ae.newline("Virtualized feed of runtime log entries with type badges: Debug, Info, Warn, Log","Each entry shows topic, timestamp and raw JSON arguments in monospace","Filter by keyword or regex via search prompt","Supports full log export as JSON file"),to:"/logs",color:"#58BF00",icon:Ae}],Je=[{label:"Notifications",description:ae.newline("Event feed for all trading signals: opens, closes, schedules, errors","Color-coded cards with symbol, position, PNL, entry/exit/TP/SL prices","Infinite-scroll pagination; click any card to open a detailed modal","Supports manual refresh to pull the latest activity"),to:"/notifications",color:"#F7931A",icon:be},{label:"Pending Status",description:ae.newline("Live view of active trading signals grouped by strategy","Grid of strategy buttons; click to inspect individual signal state","Detail view shows entry, exit, effective price, DCA and partial counts","Supports per-signal JSON export and manual refresh"),to:"/status",color:"#6F42C1",icon:ke},{label:"Dump Explorer",description:ae.newline("Tree-structured file browser for backtest output and artifact files","Icons indicate file type: image, JSON, plain text or generic","Click any file to open a full-screen preview modal","Supports keyword search and manual refresh of the file tree"),to:"/dump",color:"#0090FF",icon:Pe}],_e=[{label:"Markdown Reports",description:ae.newline("Strategy performance reports rendered from markdown for Backtest and Live runs","Grid of strategy buttons grouped by type and sorted by signal volume","Download reports as markdown, PDF or raw JSON","Supports manual refresh to regenerate report content"),to:"/report",color:"#009688",icon:$e},{label:"Price Charts",description:ae.newline("Interactive candlestick charts powered by TradingView Lightweight Charts","Navigate by symbol then interval (1m, 15m, 1h) to view price history","Overlays active signal lines: entry, take profit (green) and stop loss (red)","Supports chart image export and signal detail inspection"),to:"/price_chart",color:"#1565C0",icon:xe},{label:"Heatmap",description:ae.newline("Color-coded performance heatmap across all tracked symbols","Cells show win rate, profit factor, Sharpe ratio and other key metrics","Download heatmap as JSON, markdown report or PDF","Supports manual refresh to recalculate aggregated statistics"),to:"/heat",color:"#8D6E63",icon:Me}],Ge=[je("Application",Ye),je("Live",Je),je("Other",_e)],Ue=()=>o(Z,{sx:{width:"100%",height:"75px"}}),qe=()=>{const{classes:e}=Be();return o(re,{children:[o(O,{items:Ee,actions:Oe,onAction:async e=>{"update-now"===e&&await(async()=>{L.statusViewService.getStatusInfo.clear(),oe.next()})(),"download-markdown"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatReport(),t=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(t);L.layoutService.downloadFile(a,`heat_${Date.now()}.md`)})(),"download-pdf"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatReport();await M(e)})(),"download-json"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatData(),t=JSON.stringify(e,null,2),a=new Blob([t],{type:"text/plain"}),o=URL.createObjectURL(a);L.layoutService.downloadFile(o,`heat_${Date.now()}.json`)})()}}),o(Y,{Loader:Ue,reloadSubject:oe,children:async()=>{const e=await L.statusViewService.getStatusInfo();return e?o(He,{data:e}):null}}),o(J,{className:e.root,fields:Ge,payload:()=>({history:history})}),o(w,{paddingBottom:"24px"})]})};export{qe as MainPage,qe as default};
|
|
1
|
+
import{g as e,a as t,b as a,f as o,r,u as n,_ as i,d as s,I as l,C as c,e as d,j as p,k as h,s as v,P as m,l as u,n as g,T as f,o as y,B as w,M as $,t as x,p as b,q as S,D as z,F as C,v as P,i as L,w as M,Q as k,x as A,y as V,X as R,z as N,L as D,A as H,E as T,G as F,H as I,J as B,K as W,N as E,O,R as j,V as Y,W as J,Y as _,Z as G,$ as U,a0 as q,a1 as Z,a2 as K,a3 as Q,a4 as X,a5 as ee,a6 as te,a7 as ae}from"./index-Djrg7_-q.js";import{r as oe}from"./emitters-Bc8GPUEm.js";import{C as re,R as ne}from"./Refresh-DdJstAqE.js";function ie(t){return e("MuiAlert",t)}const se=t("MuiAlert",["root","action","icon","message","filled","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),le=a(o("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),ce=a(o("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),de=a(o("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),pe=a(o("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),he=["action","children","className","closeText","color","components","componentsProps","icon","iconMapping","onClose","role","severity","slotProps","slots","variant"],ve=v(m,{name:"MuiAlert",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[a.variant],t[`${a.variant}${p(a.color||a.severity)}`]]}})(({theme:e,ownerState:t})=>{const a="light"===e.palette.mode?u:g,o="light"===e.palette.mode?g:u,r=t.color||t.severity;return s({},e.typography.body2,{backgroundColor:"transparent",display:"flex",padding:"6px 16px"},r&&"standard"===t.variant&&{color:e.vars?e.vars.palette.Alert[`${r}Color`]:a(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:o(e.palette[r].light,.9),[`& .${se.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}},r&&"outlined"===t.variant&&{color:e.vars?e.vars.palette.Alert[`${r}Color`]:a(e.palette[r].light,.6),border:`1px solid ${(e.vars||e).palette[r].light}`,[`& .${se.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}},r&&"filled"===t.variant&&s({fontWeight:e.typography.fontWeightMedium},e.vars?{color:e.vars.palette.Alert[`${r}FilledColor`],backgroundColor:e.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:"dark"===e.palette.mode?e.palette[r].dark:e.palette[r].main,color:e.palette.getContrastText(e.palette[r].main)}))}),me=v("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(e,t)=>t.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),ue=v("div",{name:"MuiAlert",slot:"Message",overridesResolver:(e,t)=>t.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),ge=v("div",{name:"MuiAlert",slot:"Action",overridesResolver:(e,t)=>t.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),fe={success:o(le,{fontSize:"inherit"}),warning:o(ce,{fontSize:"inherit"}),error:o(de,{fontSize:"inherit"}),info:o(pe,{fontSize:"inherit"})},ye=r.forwardRef(function(e,t){var a,r,v,m,u,g;const f=n({props:e,name:"MuiAlert"}),{action:y,children:w,className:$,closeText:x="Close",color:b,components:S={},componentsProps:z={},icon:C,iconMapping:P=fe,onClose:L,role:M="alert",severity:k="success",slotProps:A={},slots:V={},variant:R="standard"}=f,N=i(f,he),D=s({},f,{color:b,severity:k,variant:R}),H=(e=>{const{variant:t,color:a,severity:o,classes:r}=e,n={root:["root",`${t}${p(a||o)}`,`${t}`],icon:["icon"],message:["message"],action:["action"]};return h(n,ie,r)})(D),T=null!=(a=null!=(r=V.closeButton)?r:S.CloseButton)?a:l,F=null!=(v=null!=(m=V.closeIcon)?m:S.CloseIcon)?v:c,I=null!=(u=A.closeButton)?u:z.closeButton,B=null!=(g=A.closeIcon)?g:z.closeIcon;return o(ve,s({role:M,elevation:0,ownerState:D,className:d(H.root,$),ref:t},N,{children:[!1!==C?o(me,{ownerState:D,className:H.icon,children:C||P[k]||fe[k]}):null,o(ue,{ownerState:D,className:H.message,children:w}),null!=y?o(ge,{ownerState:D,className:H.action,children:y}):null,null==y&&L?o(ge,{ownerState:D,className:H.action,children:o(T,s({size:"small","aria-label":x,title:x,color:"inherit",onClick:L},I,{children:o(F,s({fontSize:"small"},B))}))}):null]}))}),we=a([o("path",{d:"M13 17c-1.1 0-2-.9-2-2V9c0-1.1.9-2 2-2h6V5H5v14h14v-2h-6z",opacity:".3"}),o("path",{d:"M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.38-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z"}),o("circle",{cx:"16",cy:"12",r:"1.5"})],"AccountBalanceWalletTwoTone"),$e=a([o("path",{d:"M8 6h8v6H8zm11 8H5c-.55 0-1 .45-1 1v3h16v-3c0-.55-.45-1-1-1zm-1 3c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z",opacity:".3"}),o("path",{d:"M19 12h-1V4H6v8H5c-1.66 0-3 1.34-3 3v5h20v-5c0-1.66-1.34-3-3-3zM8 6h8v6H8V6zm12 12H4v-3c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v3z"}),o("circle",{cx:"18",cy:"16",r:"1"})],"AdfScannerTwoTone"),xe=a([o("path",{d:"M9 4H7v2H5v12h2v2h2v-2h2V6H9V4zm0 12H7V8h2v8z"}),o("path",{d:"M7 8h2v8H7zm8 2h2v3h-2z",opacity:".3"}),o("path",{d:"M19 8h-2V4h-2v4h-2v7h2v5h2v-5h2V8zm-2 5h-2v-3h2v3z"})],"CandlestickChartTwoTone"),be=a([o("path",{d:"M12 4c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm0 14.5c-.83 0-1.5-.67-1.5-1.5h3c0 .83-.67 1.5-1.5 1.5zm5-2.5H7v-2h1v-2.61C8 9.27 9.03 7.47 11 7v-.5c0-.57.43-1 1-1s1 .43 1 1V7c1.97.47 3 2.28 3 4.39V14h1v2z",opacity:".3"}),o("path",{d:"M12 18.5c.83 0 1.5-.67 1.5-1.5h-3c0 .83.67 1.5 1.5 1.5zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4-8.61c0-2.11-1.03-3.92-3-4.39v-.5c0-.57-.43-1-1-1s-1 .43-1 1V7c-1.97.47-3 2.27-3 4.39V14H7v2h10v-2h-1v-2.61zM14 14h-4v-3c0-1.1.9-2 2-2s2 .9 2 2v3z"})],"CircleNotificationsTwoTone"),Se=a(o("path",{d:"M21.5 14.98c-.02 0-.03 0-.05.01C21.2 13.3 19.76 12 18 12c-1.4 0-2.6.83-3.16 2.02C13.26 14.1 12 15.4 12 17c0 1.66 1.34 3 3 3l6.5-.02c1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5zM10 4.26v2.09C7.67 7.18 6 9.39 6 12c0 1.77.78 3.34 2 4.44V14h2v6H4v-2h2.73C5.06 16.54 4 14.4 4 12c0-3.73 2.55-6.85 6-7.74zM20 6h-2.73c1.43 1.26 2.41 3.01 2.66 5h-2.02c-.23-1.36-.93-2.55-1.91-3.44V10h-2V4h6v2z"}),"CloudSync"),ze=a(o("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Ce=a(o("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),Pe=a([o("path",{d:"M14 4H6v16h12V8h-4V4zm2 7v4c0 2.21-1.79 4-4 4s-4-1.79-4-4V9.5C8 8.12 9.12 7 10.5 7S13 8.12 13 9.5V15h-2V9.5c0-.28-.22-.5-.5-.5s-.5.22-.5.5V15c0 1.1.9 2 2 2s2-.9 2-2v-4h2z",opacity:".3"}),o("path",{d:"M14 15c0 1.1-.9 2-2 2s-2-.9-2-2V9.5c0-.28.22-.5.5-.5s.5.22.5.5V15h2V9.5C13 8.12 11.88 7 10.5 7S8 8.12 8 9.5V15c0 2.21 1.79 4 4 4s4-1.79 4-4v-4h-2v4z"}),o("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h8v4h4v12z"})],"FilePresentTwoTone"),Le=a([o("path",{d:"M19 5H5v14h14V5zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z",opacity:".3"}),o("path",{d:"M3 5v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2zm2 0h14v14H5V5zm2 5h2v7H7zm4-3h2v10h-2zm4 6h2v4h-2z"})],"InsertChartTwoTone"),Me=a([o("path",{d:"M10 5h4v14h-4V5zm-6 6h4v8H4v-8zm16 8h-4v-6h4v6z",opacity:".3"}),o("path",{d:"M16 11V3H8v6H2v12h20V11h-6zm-6-6h4v14h-4V5zm-6 6h4v8H4v-8zm16 8h-4v-6h4v6z"})],"LeaderboardTwoTone"),ke=a(o(r.Fragment,{children:[o("path",{d:"M12 20c4.41 0 8-3.59 8-8s-3.59-8-8-8-8 3.59-8 8 3.59 8 8 8zM10 7.5l6 4.5-6 4.5v-9z",opacity:".3"}),o("path",{d:"M12 22c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10zm0-18c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8zm-2 3.5v9l6-4.5z"})]}),"PlayCircleFilledWhiteTwoTone"),Ae=a([o("path",{d:"M4 18h16V8H4v10zm8-3h6v2h-6v-2zm-5.91-4.59L7.5 9l4 4-4 4-1.41-1.41L8.67 13l-2.58-2.59z",opacity:".3"}),o("path",{d:"M12 15h6v2h-6z"}),o("path",{d:"M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm0 14H4V8h16v10z"}),o("path",{d:"m7.5 17 4-4-4-4-1.41 1.41L8.67 13l-2.58 2.59z"})],"TerminalTwoTone"),Ve=b()(e=>({root:{marginTop:e.spacing(1),marginBottom:e.spacing(2),marginLeft:e.spacing(2),marginRight:e.spacing(3),background:"white",transition:"opacity 500ms","&:hover":{opacity:1},opacity:.35,cursor:"pointer"},open:{opacity:1},expandButton:{cursor:"pointer !important",marginLeft:e.spacing(1)},copyButton:{cursor:"pointer !important",marginRight:e.spacing(1)},downloadButton:{cursor:"pointer !important"}})),Re=(e,t="%")=>e?`${e.toFixed(2)}${t}`:"—",Ne=e=>e?`${e.toFixed(1)} min`:"—",De=e=>window.Translate?window.Translate.translateText(e):e,He=({data:e})=>{const{classes:t,cx:a}=Ve(),[n,i]=r.useState(!1),s=(e=>{const{context:t,portfolioTotalPnl:a,portfolioSharpeRatio:o,portfolioTotalTrades:r,portfolioStdDev:n,portfolioSortinoRatio:i,portfolioCalmarRatio:s,portfolioRecoveryFactor:l,portfolioExpectancy:c,portfolioAvgPeakPnl:d,portfolioAvgFallPnl:p,portfolioPeakProfitPnl:h,portfolioMaxDrawdownPnl:v,portfolioAvgDuration:m,portfolioMedianPnl:u,portfolioAvgConsecutiveWinPnl:g,portfolioAvgConsecutiveLossPnl:f,portfolioAvgWinDuration:y,portfolioAvgLossDuration:w,portfolioAnnualizedSharpeRatio:$,portfolioCertaintyRatio:x,portfolioExpectedYearlyReturns:b,portfolioTradesPerYear:S,symbols:z,backtest:C}=e,P=De(C?"Backtest":"Live"),L=t.frameName?` / ${t.frameName}`:"",M=[`## ${P}: ${t.strategyName} / ${t.exchangeName}${L}`,"",`**${De("Total PNL")}:** ${Re(a)} `,`**Sharpe Ratio:** ${Re(o,"")} `,`**${De("Annualized Sharpe")}:** ${Re($,"")} `,`**${De("Certainty Ratio")}:** ${Re(x,"")} `,`**${De("Expected Yearly Returns")}:** ${Re(b)} `,`**${De("Trades Per Year")}:** ${null!==S?S.toFixed(1):"—"} `,`**${De("Total trades")}:** ${r} `,`**${De("Standard Deviation Per Trade")}:** ${Re(n)} `,`**${De("Sortino Ratio")}:** ${Re(i,"")} `,`**${De("Calmar Ratio")}:** ${Re(s,"")} `,`**${De("Recovery Factor Per Equity Drawdown")}:** ${Re(l,"")} `,`**${De("Expectancy")}:** ${Re(c)} `,`**${De("Median PNL")}:** ${Re(u)} `,`**${De("Avg Peak PNL")}:** ${Re(d)} `,`**${De("Avg Drawdown PNL")}:** ${Re(p)} `,`**${De("Peak Profit PNL")}:** ${Re(h)} `,`**${De("Max Drawdown PNL")}:** ${Re(v)} `,`**${De("Avg Duration")}:** ${Ne(m)} `,`**${De("Avg Win Duration")}:** ${Ne(y)} `,`**${De("Avg Loss Duration")}:** ${Ne(w)} `,`**${De("Avg Consecutive Win PNL")}:** ${Re(g)} `,`**${De("Avg Consecutive Loss PNL")}:** ${Re(f)}`,""];for(const k of z)M.push(`### ${k.symbol}`,"",`**PNL:** ${Re(k.totalPnl)} `,`**${De("Avg PNL")}:** ${Re(k.avgPnl)} `,`**${De("Median PNL")}:** ${Re(k.medianPnl)} `,`**Win Rate:** ${Re(k.winRate)} `,`**Profit Factor:** ${Re(k.profitFactor,"")} `,`**Max Drawdown:** ${Re(k.maxDrawdown)} `,`**Expectancy:** ${Re(k.expectancy)} `,`**Sharpe Ratio:** ${Re(k.sharpeRatio,"")} `,`**Annualized Sharpe:** ${Re(k.annualizedSharpeRatio,"")} `,`**Certainty Ratio:** ${Re(k.certaintyRatio,"")} `,`**Expected Yearly Returns:** ${Re(k.expectedYearlyReturns)} `,`**Trades Per Year:** ${null!==k.tradesPerYear?k.tradesPerYear.toFixed(1):"—"} `,`**Sortino Ratio:** ${Re(k.sortinoRatio,"")} `,`**Calmar Ratio:** ${Re(k.calmarRatio,"")} `,`**Recovery Factor Per Equity Drawdown:** ${Re(k.recoveryFactor,"")} `,`**Standard Deviation:** ${Re(k.stdDev)} `,`**Avg Win:** ${Re(k.avgWin)} `,`**Avg Loss:** ${Re(k.avgLoss)} `,`**Max Win Streak:** ${k.maxWinStreak} `,`**Max Loss Streak:** ${k.maxLossStreak} `,`**Avg Peak PNL:** ${Re(k.avgPeakPnl)} `,`**Avg Drawdown PNL:** ${Re(k.avgFallPnl)} `,`**Peak Profit PNL:** ${Re(k.peakProfitPnl)} `,`**Max Drawdown PNL:** ${Re(k.maxDrawdownPnl)} `,`**Avg Duration:** ${Ne(k.avgDuration)} `,`**Avg Win Duration:** ${Ne(k.avgWinDuration)} `,`**Avg Loss Duration:** ${Ne(k.avgLossDuration)} `,`**Avg Consecutive Win PNL:** ${Re(k.avgConsecutiveWinPnl)} `,`**Avg Consecutive Loss PNL:** ${Re(k.avgConsecutiveLossPnl)} `,`**${De("Trades")}:** ${k.totalTrades}`,"");return M.join("\n")})(e),c=()=>{i(!n)},d=async e=>{e.stopPropagation(),await M(s)},p=async e=>{e.stopPropagation(),await P(s)&&L.alertService.notify("Copied!")};return o(ye,{className:a(t.root,{[t.open]:n}),action:o(C,{children:[o(l,{className:t.copyButton,onClick:p,size:"small",children:o(S,{})}),o(l,{className:t.downloadButton,onClick:d,size:"small",children:o(z,{})}),o(l,{className:t.expandButton,onClick:c,size:"small",children:o(n?ze:Ce,{})})]}),onClick:c,variant:"outlined",severity:"info",children:o(f,{minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",width:"100%",children:[o(f,{variant:"body2",sx:{opacity:n?.5:1,transition:"opacity 500ms"},minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",children:[e.backtest?"Backtest":"Live",": ",e.context.strategyName]}),o(y,{in:n,timeout:"auto",unmountOnExit:!0,children:[o(w,{paddingBottom:"16px"}),o($,{content:s}),o(w,{paddingBottom:"32px"})]}),!n&&o(f,{variant:"caption",sx:{opacity:.7,mt:1},children:[x(s).slice(0,150),"..."]})]})})},Te="backtest-kit__groupHeader",Fe="backtest-kit__groupRoot",Ie="backtest-kit__symbolImage",Be=b()({root:{[`& .${Fe}:hover .${Te}`]:{opacity:"1 !important"}}});function We(e){return te(e,"#000000")>te(e,"#FFFFFF")}const Ee=[{type:j.Component,element:()=>{const{reloadTrigger:e,doReload:t}=k(15e3),[a,{execute:r}]=A(async()=>{L.runtimeViewService.getRuntimeInfo.clear();const e=V(L.runtimeViewService.getRuntimeInfo,{defaultValue:null});return await e()},{onLoadStart:()=>L.layoutService.setAppbarLoader(!0),onLoadEnd:()=>L.layoutService.setAppbarLoader(!1),deps:[e]});R(()=>oe.subscribe(r));return o(H,{direction:"row",alignItems:"center",children:[o(N,{"aria-label":"breadcrumb",children:[o(D,{underline:"always",color:"inherit",href:"#",onClick:e=>e.preventDefault(),children:"Main"}),o(D,{underline:"always",color:"inherit",href:"#",onClick:e=>e.preventDefault(),children:"Navigation"})]}),o(w,{flex:1}),(()=>{if(!a)return null;const{symbol:e,when:r,currentPrice:n,backtest:i}=a;return o(W,{placement:"bottom",description:i?"Backtest mode":"Live mode",children:o(H,{direction:"row",alignItems:"center",spacing:1,sx:{display:{xs:"none",sm:"flex"},cursor:"pointer",userSelect:"none"},onClick:()=>{L.runtimeViewService.getRuntimeInfo.clear(),t()},children:[o(l,{size:"small",children:o(Se,{})}),o(f,{variant:"body2",sx:{opacity:.5},children:["Symbol:",T.nbsp,o("b",{children:e})]}),o(F,{orientation:"vertical",flexItem:!0}),o(f,{variant:"body2",sx:{opacity:.5},children:["Time:",T.nbsp,o("b",{children:I(r).format("HH:mm DD MMM YYYY")})]}),o(F,{orientation:"vertical",flexItem:!0}),o(f,{variant:"body2",sx:{opacity:.5},children:["Price:",T.nbsp,o("b",{children:[B(n,E(n)),"$"]})]})]})})})(),o(w,{pr:1})]})}}],Oe=[{action:"download-json",label:"Download Heatmap JSON",icon:()=>o(G,{icon:_,color:"#4caf50"})},{action:"download-markdown",label:"Download Heatmap Markdown",icon:()=>o(G,{icon:U,color:"#4caf50"})},{action:"download-pdf",label:"Download Heatmap PDF",icon:()=>o(G,{icon:q,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>o(G,{icon:ne,color:"#4caf50"})}],je=(e,t)=>({type:K.Group,className:Fe,sx:{p:2},desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fields:[{type:K.Component,className:Te,style:{transition:"opacity 500ms",opacity:.5},element:()=>o(H,{direction:"row",children:[o(Q,{variant:"outlined",size:"medium",color:"info",label:`${T.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"16px",background:"white",cursor:"not-allowed"}}),o(w,{flex:1})]})},{type:K.Group,fields:t.map(({label:e,description:t,to:a,color:r,icon:n})=>((e,t,a,r,n)=>({type:K.Component,desktopColumns:"6",tabletColumns:"12",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:()=>o(W,{description:a,children:o(X,{component:ee,onClick:()=>{L.routerService.push(e)},sx:{width:"100%",background:r,color:"white",fontWeight:"bold",fontSize:"18px",height:"75px",minHeight:"125px",textWrap:"wrap",padding:"16px",[`& .${Ie}`]:{transition:"filter 500ms"},"&:hover":{background:()=>We(r)?u(r,.33):g(r,.33),[`& .${Ie}`]:{transition:"filter 500ms",filter:We(r)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:o(n,{className:Ie}),children:t})})}))(a,e,t,r,n))}]}),Ye=[{label:"Portfolio Overview",description:ae.newline("Closed trading signals grouped by symbol for Backtest and Live modes","Each card shows position type, entry price, TP/SL levels, PNL amount and percent","Displays DCA entry count and partial close count where applicable","Supports JSON export and manual refresh of the signal list"),to:"/overview",color:"#0033AD",icon:we},{label:"PNL Performance",description:ae.newline("KPI dashboard with aggregated trading performance metrics per symbol","Shows daily trade counts, success rates, resolved/rejected breakdowns","Revenue analytics across today, yesterday, 7-day and 31-day windows","Toggle between Backtest and Live modes; supports JSON export"),to:"/dashboard",color:"#E6007A",icon:Le},{label:"System Logs",description:ae.newline("Virtualized feed of runtime log entries with type badges: Debug, Info, Warn, Log","Each entry shows topic, timestamp and raw JSON arguments in monospace","Filter by keyword or regex via search prompt","Supports full log export as JSON file"),to:"/logs",color:"#58BF00",icon:Ae}],Je=[{label:"Notifications",description:ae.newline("Event feed for all trading signals: opens, closes, schedules, errors","Color-coded cards with symbol, position, PNL, entry/exit/TP/SL prices","Infinite-scroll pagination; click any card to open a detailed modal","Supports manual refresh to pull the latest activity"),to:"/notifications",color:"#F7931A",icon:be},{label:"Pending Status",description:ae.newline("Live view of active trading signals grouped by strategy","Grid of strategy buttons; click to inspect individual signal state","Detail view shows entry, exit, effective price, DCA and partial counts","Supports per-signal JSON export and manual refresh"),to:"/status",color:"#6F42C1",icon:ke},{label:"Dump Explorer",description:ae.newline("Tree-structured file browser for backtest output and artifact files","Icons indicate file type: image, JSON, plain text or generic","Click any file to open a full-screen preview modal","Supports keyword search and manual refresh of the file tree"),to:"/dump",color:"#0090FF",icon:Pe}],_e=[{label:"Markdown Reports",description:ae.newline("Strategy performance reports rendered from markdown for Backtest and Live runs","Grid of strategy buttons grouped by type and sorted by signal volume","Download reports as markdown, PDF or raw JSON","Supports manual refresh to regenerate report content"),to:"/report",color:"#009688",icon:$e},{label:"Price Charts",description:ae.newline("Interactive candlestick charts powered by TradingView Lightweight Charts","Navigate by symbol then interval (1m, 15m, 1h) to view price history","Overlays active signal lines: entry, take profit (green) and stop loss (red)","Supports chart image export and signal detail inspection"),to:"/price_chart",color:"#1565C0",icon:xe},{label:"Heatmap",description:ae.newline("Color-coded performance heatmap across all tracked symbols","Cells show win rate, profit factor, Sharpe ratio and other key metrics","Download heatmap as JSON, markdown report or PDF","Supports manual refresh to recalculate aggregated statistics"),to:"/heat",color:"#8D6E63",icon:Me}],Ge=[je("Application",Ye),je("Live",Je),je("Other",_e)],Ue=()=>o(Z,{sx:{width:"100%",height:"75px"}}),qe=()=>{const{classes:e}=Be();return o(re,{children:[o(O,{items:Ee,actions:Oe,onAction:async e=>{"update-now"===e&&await(async()=>{L.statusViewService.getStatusInfo.clear(),oe.next()})(),"download-markdown"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatReport(),t=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(t);L.layoutService.downloadFile(a,`heat_${Date.now()}.md`)})(),"download-pdf"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatReport();await M(e)})(),"download-json"===e&&await(async()=>{const e=await L.heatViewService.getStrategyHeatData(),t=JSON.stringify(e,null,2),a=new Blob([t],{type:"text/plain"}),o=URL.createObjectURL(a);L.layoutService.downloadFile(o,`heat_${Date.now()}.json`)})()}}),o(Y,{Loader:Ue,reloadSubject:oe,children:async()=>{const e=await L.statusViewService.getStatusInfo();return e?o(He,{data:e}):null}}),o(J,{className:e.root,fields:Ge,payload:()=>({history:history})}),o(w,{paddingBottom:"24px"})]})};export{qe as MainPage,qe 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-Djrg7_-q.js";import{h as M}from"./hasRouteMatch-Cp7g01zK.js";import{B as V}from"./Background-xfzkOWU4.js";import{A as B}from"./Article-CJq_3XCa.js";import{C as D,R as F}from"./Refresh-DdJstAqE.js";import{K}from"./KeyboardArrowLeft-bxIYZMcN.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 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-Djrg7_-q.js";import{A as H}from"./Article-CJq_3XCa.js";import{C as R,R as z}from"./Refresh-DdJstAqE.js";import{K as C}from"./KeyboardArrowLeft-bxIYZMcN.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};
|