@backtest-kit/ui 15.4.0 → 15.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/modules/frontend/build/assets/{Article-DL41GA0a.js → Article-syu9ECjj.js} +1 -1
- package/build/modules/frontend/build/assets/{Background-DhTBM0kG.js → Background-CsI3L_P-.js} +1 -1
- package/build/modules/frontend/build/assets/{IconPhoto-CGT-L09K.js → IconPhoto-BorPc4HC.js} +1 -1
- package/build/modules/frontend/build/assets/{KeyboardArrowLeft-CF6hGzGl.js → KeyboardArrowLeft-mYxZRvhi.js} +1 -1
- package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-C2rlUSVJ.js → PictureAsPdfOutlined-iaRMxzYr.js} +1 -1
- package/build/modules/frontend/build/assets/{Refresh-BEzkJ_ge.js → Refresh-Bx2t72xl.js} +1 -1
- package/build/modules/frontend/build/assets/emitters-CUHC1ADb.js +1 -0
- package/build/modules/frontend/build/assets/{hasRouteMatch-Bc6IBTG4.js → hasRouteMatch-_bnrnDj6.js} +1 -1
- package/build/modules/frontend/build/assets/{html2canvas-BrRQKwKk.js → html2canvas-DOHsZOxH.js} +1 -1
- package/build/modules/frontend/build/assets/{index-D5RN2bOA.js → index-B0jNGAXL.js} +1 -1
- package/build/modules/frontend/build/assets/{index-Loobwod7.js → index-B2Lvw6GG.js} +1 -1
- package/build/modules/frontend/build/assets/{index-BZjEYFfO.js → index-CEnwiRAD.js} +1 -1
- package/build/modules/frontend/build/assets/{index-NOH2rGyk.js → index-CjLi-euX.js} +1 -1
- package/build/modules/frontend/build/assets/{index-ClGONTx7.js → index-CtAXHHZ4.js} +1 -1
- package/build/modules/frontend/build/assets/{index-BUhmLJSw.js → index-D6F73QcI.js} +1 -1
- package/build/modules/frontend/build/assets/{index-ChUhZnIE.js → index-D_mt72Gs.js} +1 -1
- package/build/modules/frontend/build/assets/{index-BQ4Egk78.js → index-DkBmN4gr.js} +1 -1
- package/build/modules/frontend/build/assets/{index-C-FMDM09.js → index-OetLRntu.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CJlJOSPg.js → index-WZ_nxkBQ.js} +5 -5
- package/build/modules/frontend/build/assets/index-krQILU58.js +1 -0
- package/build/modules/frontend/build/assets/{index-ffa7_jT3.js → index-rlNIYwyN.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DvkcUAiy.js → index-vbQRf1vS.js} +1 -1
- package/build/modules/frontend/build/assets/{index.es-Drs6xcLZ.js → index.es-6ih0wv_Z.js} +1 -1
- package/build/modules/frontend/build/assets/markdownit-BdJWliYA.js +1 -0
- package/build/modules/frontend/build/index.html +1 -1
- package/package.json +3 -3
- package/build/modules/frontend/build/assets/emitters-Cp5Wn6Es.js +0 -1
- package/build/modules/frontend/build/assets/index-Cfpamomx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,f as e,a_ as t,B as o,J as r,aa as n,T as i,O as s,a4 as c,w as l,N as d,l as h,aO as p,b0 as u,b1 as w,aG as b,a9 as f,i as x,aH as g,al as y,aL as v,V as m,W as S,b2 as L,a$ as k,D as j,$ as A,t as z}from"./index-
|
|
1
|
+
import{d as a,f as e,a_ as t,B as o,J as r,aa as n,T as i,O as s,a4 as c,w as l,N as d,l as h,aO as p,b0 as u,b1 as w,aG as b,a9 as f,i as x,aH as g,al as y,aL as v,V as m,W as S,b2 as L,a$ as k,D as j,$ as A,t as z}from"./index-WZ_nxkBQ.js";import{A as H}from"./Article-syu9ECjj.js";import{C as R,R as C}from"./Refresh-Bx2t72xl.js";import{K as B}from"./KeyboardArrowLeft-mYxZRvhi.js";const D=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),E=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(D,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(H,{sx:t})}},M=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:E(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),F=[{action:"download-action",label:z("Download"),icon:()=>e(A,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:z("Refresh manually"),icon:()=>e(A,{icon:C,color:"#4caf50"})}],O=[{type:S.Link,action:"back-action",label:e(B,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:z("Main")},{type:S.Link,action:"back-action",label:z("Logs")},{type:S.Button,icon:L,action:"search-action",label:z("Search")}],W=new f,Y=()=>{const[a,o]=w(""),{data:r,hasMore:n,loading:i,onSkip:s}=b({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:W}),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:O,actions:F,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await W.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt(z("Search keyword"));if(a)return o(a),void W.next();o(""),W.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(M,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,b as t,r as o,u as a,_ as i,e as r,f as n,h as l,k as s,s as c,l as p,d,z as m,A as y,i as u,V as g,W as h,q as b,a3 as f,t as v,$ as x,T as C,b3 as w,Y as S,B as N,w as P,a4 as k,K as A,J as L,a6 as $,m as M,n as T,a5 as B,a7 as R,ai as V,b4 as F,b5 as z,y as I,G as E,a9 as O,b6 as D,D as j,b7 as H,b8 as W,ag as G,X as q,U,a2 as Y,b9 as _,ad as Q,ba as J,bb as K,bc as X,Q as Z,bd as ee,aZ as te,ah as oe,be as ae,aQ as ie,aO as re,b0 as ne,bf as le,bg as se,bh as ce,bi as pe,I as de,av as me,al as ye,bj as ue,aj as ge}from"./index-CJlJOSPg.js";import{h as he}from"./hasRouteMatch-Bc6IBTG4.js";import{I as be}from"./IconPhoto-CGT-L09K.js";import{C as fe,R as ve}from"./Refresh-BEzkJ_ge.js";import{K as xe}from"./KeyboardArrowLeft-CF6hGzGl.js";import{B as Ce}from"./Background-DhTBM0kG.js";import{r as we}from"./emitters-Cp5Wn6Es.js";function Se(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Ne=["className","raised"],Pe=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),ke=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Ne),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},Se,t)})(m);return n(Pe,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function Ae(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Le=["className","component"],$e=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,Le),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},Ae,t)})(m);return n($e,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"),Be=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"),Re=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"),Ve=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"),ze=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"),Ie="backtest-kit__groupHeader",Ee="backtest-kit__groupRoot",Oe="backtest-kit__symbolImage",De=b()({root:{[`& .${Ee}:hover .${Ie}`]:{opacity:"1 !important"}}});function je(e){return R(e,"#000000")>R(e,"#FFFFFF")}const He=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")}],We=[{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ge=(e,t)=>({type:f.Group,className:Ee,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:Ie,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(L,{direction:"row",children:[n(k,{variant:"outlined",size:"small",color:"info",label:`${A.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(N,{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(B,{component:$,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",[`& .${Oe}`]:{transition:"filter 500ms"},"&:hover":{background:()=>je(a)?M(a,.33):T(a,.33),[`& .${Oe}`]:{transition:"filter 500ms",filter:je(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(be,{className:Oe,symbol:e}),children:n(N,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),qe=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:v("Live")},{type:h.Button,action:"control-action",label:v("Manual Control"),icon:ze},{type:h.Fab,action:"print-action",label:v("Print"),icon:D},{type:h.Fab,action:"update-now",label:v("Refresh"),icon:ve}],Ue=[{action:"print-action",label:v("Print"),icon:()=>n(x,{icon:D,color:"#4caf50"})},{action:"download-action",label:v("Download"),icon:()=>n(x,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ye=new O,_e=new O,Qe=new O,Je=new O,Ke=new O,Xe=Y.createLoader(12),Ze=({payload:e})=>n(N,{sx:{mb:1,minHeight:48},children:n(W,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(L,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(G,{startIcon:n(Te,{}),onClick:async()=>await _e.next(),color:"success",sx:{whiteSpace:"nowrap"},children:v("Open Position")}),n(G,{startIcon:n(Fe,{}),onClick:async()=>await Qe.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:v("Commit Averaging")}),n(G,{startIcon:n(Ve,{}),onClick:async()=>await Ke.next(),sx:{whiteSpace:"nowrap"},children:v("Commit Breakeven")}),n(N,{flex:1}),n(q,{Loader:Xe,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:we,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(C,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:[v("Avg price")," ",e.symbol,":",A.nbsp,n("b",{children:`${o.toFixed(U(o))}${v("$")}`})]})}}),n(G,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},color:"error",children:v("Close Position")})]})})}),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:v("Open Position")},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:v("Direction"),placeholder:v("Select direction"),itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Q,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:v("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:v("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:v("Note"),placeholder:v("Reason for opening the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the position will be opened IMMEDIATELY")}`}]}}],tt=[{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:v("Open Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE")}`}]}}],ot=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},at={success:!1,loading:!0,error:""},it=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:tt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:et,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(at),{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]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(ot,{type:"error",title:v("Position Opening Error"),description:r.error,amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d}):r.loading?n(ot,{type:"loading",title:v("Opening Position"),description:v("Please wait. Your operation is being processed..."),amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d}):n(ot,{type:"success",title:v("Position Opened"),description:v("Position has been scheduled successfully. Waiting for the order to be executed on the exchange"),amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d})})})},isActive:e=>!!se("/submit",e)}],rt=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Opening")}],nt="/brief",lt=me(),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:v("Average Position")},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Q,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:v("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:v("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:v("Note"),placeholder:v("Reason for averaging the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the averaging will be performed IMMEDIATELY")}`}]}}],ct=[{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:v("Average Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE")}`}]}}],pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},dt={success:!1,loading:!0,error:""},mt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:ct}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:st,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(dt),{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]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(pt,{type:"error",title:v("Averaging Error"),description:r.error,amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p}):r.loading?n(pt,{type:"loading",title:v("Averaging Position"),description:v("Please wait. Your operation is being processed..."),amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p}):n(pt,{type:"success",title:v("Position Averaged"),description:v("Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange"),amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p})})})},isActive:e=>!!se("/submit",e)}],yt=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Averaging")}],ut="/brief",gt=me(),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:v("Close Position")},{type:f.Outline,fields:[{type:f.Text,name:"note",title:v("Note"),placeholder:v("Reason for closing the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the closing will be performed IMMEDIATELY")}`}]}}],bt=[{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:v("Close Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE")}`}]}}],ft=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},vt={success:!1,loading:!0,error:""},xt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:bt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:ht,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(vt),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(ft,{type:"error",title:v("Position Closing Error"),description:r.error,symbol:c}):r.loading?n(ft,{type:"loading",title:v("Closing Position"),description:v("Please wait. Your operation is being processed..."),symbol:c}):n(ft,{type:"success",title:v("Position Closed"),description:v("Closing has been scheduled successfully. Waiting for the order to be executed on the exchange"),symbol:c})})})},isActive:e=>!!se("/submit",e)}],Ct=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Closing")}],wt="/brief",St=me(),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:v("Move to Breakeven")},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:v("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:`${A.bullet} ${v("After pressing the Next button, the move to breakeven will be performed IMMEDIATELY")}`}]}}],Pt=[{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:v("Move to Breakeven")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE")}`}]}}],kt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},At={success:!1,loading:!0,error:""},Lt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:Pt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("Back"),onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(S,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:J,fields:Nt,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(At),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(kt,{type:"error",title:v("Breakeven Error"),description:r.error,symbol:s}):r.loading?n(kt,{type:"loading",title:v("Moving to Breakeven"),description:v("Please wait. Your operation is being processed..."),symbol:s}):n(kt,{type:"success",title:v("Breakeven Set"),description:v("Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange"),symbol:s})})})},isActive:e=>!!se("/submit",e)}],$t=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Breakeven")}],Mt="/brief",Tt=me(),Bt=e=>"pnl"===e?v("P&L"):e,Rt=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:v("Live")},{type:h.Link,action:"back-action",label:v("Manual Control")},{type:h.Button,action:"update-now",label:v("Refresh"),icon:ve}],Vt=[{action:"download-action",label:v("Download"),icon:()=>n(x,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return V.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=ye(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:lt,animation:"none",title:v("Open Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:nt,sizeRequest:pe,routes:it,steps:rt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{lt.push(nt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:gt,animation:"none",title:v("Average Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:ut,sizeRequest:pe,routes:mt,steps:yt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{gt.push(ut),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:St,animation:"none",title:v("Close Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:wt,sizeRequest:pe,routes:xt,steps:Ct,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{St.push(wt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:Tt,animation:"none",title:v("Move to Breakeven"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:pe,routes:Lt,steps:$t,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}});E(()=>we.subscribe(i)),E(()=>_e.subscribe(l)),E(()=>Qe.subscribe(c)),E(()=>Je.subscribe(m)),E(()=>Ke.subscribe(b));const x=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(fe,{children:[n(g,{items:Rt,actions:Vt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&x(),"update-now"===t&&await we.next()}}),o?a?null:n(ue,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:Bt,AfterSearch:Ze,data:o}):null,n(N,{sx:{paddingBottom:"24px"}}),n(Ce,{}),s(),d(),h(),f()]})},isActive:e=>he(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return V.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(z,o);await I(e)});E(()=>Ye.subscribe(i));return n(fe,{children:[n(g,{items:qe,actions:Ue,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 Ye.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("Loading...")})}):o?n(P,{children:[n(S,{handler:o,fields:H}),n(N,{paddingBottom:"24px"})]}):n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("No pending signal")})}),n(Ce,{})]})},isActive:e=>he(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=De(),{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:v("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=Ge(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(fe,{children:[n(g,{items:He,actions:We,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("Loading...")})}):a.length?n(P,{children:[n(S,{className:e.root,fields:a},t),n(N,{paddingBottom:"24px"})]}):n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("No pending signals")})})]})},isActive:e=>he(["/status"],e)}],zt=({id:e})=>n(ge,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{zt as StatusPage,zt as default};
|
|
1
|
+
import{g as e,b as t,r as o,u as a,_ as i,e as r,f as n,h as l,k as s,s as c,l as p,d,z as m,A as y,i as u,V as g,W as h,q as b,a3 as f,t as v,$ as x,T as C,b3 as w,Y as S,B as N,w as P,a4 as k,K as A,J as L,a6 as $,m as M,n as T,a5 as B,a7 as R,ai as V,b4 as F,b5 as z,y as I,G as E,a9 as O,b6 as D,D as j,b7 as H,b8 as W,ag as G,X as q,U,a2 as Y,b9 as _,ad as Q,ba as J,bb as K,bc as X,Q as Z,bd as ee,aZ as te,ah as oe,be as ae,aQ as ie,aO as re,b0 as ne,bf as le,bg as se,bh as ce,bi as pe,I as de,av as me,al as ye,bj as ue,aj as ge}from"./index-WZ_nxkBQ.js";import{h as he}from"./hasRouteMatch-_bnrnDj6.js";import{I as be}from"./IconPhoto-BorPc4HC.js";import{C as fe,R as ve}from"./Refresh-Bx2t72xl.js";import{K as xe}from"./KeyboardArrowLeft-mYxZRvhi.js";import{B as Ce}from"./Background-CsI3L_P-.js";import{r as we}from"./emitters-CUHC1ADb.js";function Se(t){return e("MuiCard",t)}t("MuiCard",["root"]);const Ne=["className","raised"],Pe=c(p,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),ke=o.forwardRef(function(e,t){const o=a({props:e,name:"MuiCard"}),{className:c,raised:p=!1}=o,d=i(o,Ne),m=r({},o,{raised:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},Se,t)})(m);return n(Pe,r({className:l(y.root,c),elevation:p?8:void 0,ref:t,ownerState:m},d))});function Ae(t){return e("MuiCardContent",t)}t("MuiCardContent",["root"]);const Le=["className","component"],$e=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,Le),m=r({},o,{component:p}),y=(e=>{const{classes:t}=e;return s({root:["root"]},Ae,t)})(m);return n($e,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"),Be=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"),Re=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"),Ve=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"),ze=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"),Ie="backtest-kit__groupHeader",Ee="backtest-kit__groupRoot",Oe="backtest-kit__symbolImage",De=b()({root:{[`& .${Ee}:hover .${Ie}`]:{opacity:"1 !important"}}});function je(e){return R(e,"#000000")>R(e,"#FFFFFF")}const He=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")}],We=[{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ge=(e,t)=>({type:f.Group,className:Ee,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:f.Component,className:Ie,style:{transition:"opacity 500ms",opacity:.5},element:()=>n(L,{direction:"row",children:[n(k,{variant:"outlined",size:"small",color:"info",label:`${A.bullet} ${e}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),n(N,{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(B,{component:$,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",[`& .${Oe}`]:{transition:"filter 500ms"},"&:hover":{background:()=>je(a)?M(a,.33):T(a,.33),[`& .${Oe}`]:{transition:"filter 500ms",filter:je(a)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:n(be,{className:Oe,symbol:e}),children:n(N,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(e,o,t,a))}]}),qe=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:v("Live")},{type:h.Button,action:"control-action",label:v("Manual Control"),icon:ze},{type:h.Fab,action:"print-action",label:v("Print"),icon:D},{type:h.Fab,action:"update-now",label:v("Refresh"),icon:ve}],Ue=[{action:"print-action",label:v("Print"),icon:()=>n(x,{icon:D,color:"#4caf50"})},{action:"download-action",label:v("Download"),icon:()=>n(x,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ye=new O,_e=new O,Qe=new O,Je=new O,Ke=new O,Xe=Y.createLoader(12),Ze=({payload:e})=>n(N,{sx:{mb:1,minHeight:48},children:n(W,{sx:{height:"100%",minHeight:48},hideOverflowY:!0,children:n(L,{direction:"row",gap:1,sx:{pointerEvents:"all"},children:[n(G,{startIcon:n(Te,{}),onClick:async()=>await _e.next(),color:"success",sx:{whiteSpace:"nowrap"},children:v("Open Position")}),n(G,{startIcon:n(Fe,{}),onClick:async()=>await Qe.next(),color:"warning",sx:{whiteSpace:"nowrap"},children:v("Commit Averaging")}),n(G,{startIcon:n(Ve,{}),onClick:async()=>await Ke.next(),sx:{whiteSpace:"nowrap"},children:v("Commit Breakeven")}),n(N,{flex:1}),n(q,{Loader:Xe,deps:[e.symbol,e.exchangeName,e.strategyName],reloadSubject:we,children:async()=>{const t=await u.controlViewService.getAveragePrice(e.symbol,{exchangeName:e.exchangeName,strategyName:e.strategyName}),o=Number(t);return n(C,{height:"100%",display:"flex",alignItems:"center",whiteSpace:"nowrap",mr:1,children:[v("Avg price")," ",e.symbol,":",A.nbsp,n("b",{children:`${o.toFixed(U(o))}${v("$")}`})]})}}),n(G,{startIcon:n(Re,{}),onClick:async()=>await Je.next(),sx:{whiteSpace:"nowrap"},color:"error",children:v("Close Position")})]})})}),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:v("Open Position")},{type:f.Outline,fields:[{type:f.Combo,name:"position",title:v("Direction"),placeholder:v("Select direction"),itemList:["long","short"],validation:{required:!0},defaultValue:"long"},{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Q,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:v("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:v("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:v("Note"),placeholder:v("Reason for opening the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the position will be opened IMMEDIATELY")}`}]}}],tt=[{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:v("Open Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to open a position on. Rely on the symbol AND THE PRICE")}`}]}}],ot=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},at={success:!1,loading:!0,error:""},it=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:tt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:et,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(at),{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]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(ot,{type:"error",title:v("Position Opening Error"),description:r.error,amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d}):r.loading?n(ot,{type:"loading",title:v("Opening Position"),description:v("Please wait. Your operation is being processed..."),amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d}):n(ot,{type:"success",title:v("Position Opened"),description:v("Position has been scheduled successfully. Waiting for the order to be executed on the exchange"),amount:`${Z(parseFloat(c||"0"))}${v("$")}`,symbol:d})})})},isActive:e=>!!se("/submit",e)}],rt=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Opening")}],nt="/brief",lt=me(),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:v("Average Position")},{type:f.Outline,fields:[{type:f.Text,name:"cost",inputPattern:"[0-9]*",inputMode:"numeric",inputType:"tel",trailingIcon:Q,trailingIconClick:(e,{},{},t)=>{t("")},validation:{required:!0},title:v("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:v("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:v("Note"),placeholder:v("Reason for averaging the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the averaging will be performed IMMEDIATELY")}`}]}}],ct=[{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:v("Average Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to average the position on. Rely on the symbol AND THE PRICE")}`}]}}],pt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},dt={success:!1,loading:!0,error:""},mt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:ct}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:st,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(dt),{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]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(pt,{type:"error",title:v("Averaging Error"),description:r.error,amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p}):r.loading?n(pt,{type:"loading",title:v("Averaging Position"),description:v("Please wait. Your operation is being processed..."),amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p}):n(pt,{type:"success",title:v("Position Averaged"),description:v("Averaging has been scheduled successfully. Waiting for the order to be executed on the exchange"),amount:`${Z(parseFloat(s||"0"))}${v("$")}`,symbol:p})})})},isActive:e=>!!se("/submit",e)}],yt=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Averaging")}],ut="/brief",gt=me(),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:v("Close Position")},{type:f.Outline,fields:[{type:f.Text,name:"note",title:v("Note"),placeholder:v("Reason for closing the position")}]},{type:f.Typography,fieldBottomMargin:"3",typoVariant:"caption",sx:{pt:2,opacity:.5,fontSize:12},placeholder:`${A.bullet} ${v("After pressing the Next button, the closing will be performed IMMEDIATELY")}`}]}}],bt=[{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:v("Close Position")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin you want to close the position on. Rely on the symbol AND THE PRICE")}`}]}}],ft=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},vt={success:!1,loading:!0,error:""},xt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:bt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:a,onChange:i})=>{const[r,l]=o.useState(e),s=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("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(S,{payload:()=>({averagePrice:a.data.brief.averagePrice}),onChange:e=>l(e),slots:J,fields:ht,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(vt),{note:s,symbol:c}=o.useMemo(()=>{const{note:t,symbol:o}=e.data.form;return{note:t,symbol:o}},[e]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(ft,{type:"error",title:v("Position Closing Error"),description:r.error,symbol:c}):r.loading?n(ft,{type:"loading",title:v("Closing Position"),description:v("Please wait. Your operation is being processed..."),symbol:c}):n(ft,{type:"success",title:v("Position Closed"),description:v("Closing has been scheduled successfully. Waiting for the order to be executed on the exchange"),symbol:c})})})},isActive:e=>!!se("/submit",e)}],Ct=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Closing")}],wt="/brief",St=me(),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:v("Move to Breakeven")},{type:f.Outline,fields:[{type:f.Typography,typoVariant:"body1",placeholder:v("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:`${A.bullet} ${v("After pressing the Next button, the move to breakeven will be performed IMMEDIATELY")}`}]}}],Pt=[{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:v("Move to Breakeven")},{type:f.Outline,fields:[{type:f.Text,name:"symbol",compute:({},e)=>e.symbol,title:v("Symbol")},{type:f.Text,name:"price",inputPattern:"[0-9.]*",inputMode:"decimal",inputType:"tel",compute:({},e)=>`${Z(e.averagePrice)}${v("$")}`,title:v("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:`${A.bullet} ${v("Carefully verify that this is the coin whose stop you want to move to breakeven. Rely on the symbol AND THE PRICE")}`}]}}],kt=({type:e,title:t,description:o,amount:a,price:i,symbol:r})=>{const l=ee(),s="loading"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(ae,{size:24,color:"warning"}),chipColor:"warning"}:"success"===e?{color:l.palette.success.main,bgColor:oe(l.palette.success.main,.1),icon:n(Be,{}),chipColor:"success"}:"error"===e?{color:l.palette.error.main,bgColor:oe(l.palette.error.main,.1),icon:n(ie,{}),chipColor:"error"}:"warning"===e?{color:l.palette.warning.main,bgColor:oe(l.palette.warning.main,.1),icon:n(re,{}),chipColor:"warning"}:"info"===e?{color:l.palette.info.main,bgColor:oe(l.palette.info.main,.1),icon:n(ne,{}),chipColor:"info"}:{color:l.palette.grey[500],bgColor:oe(l.palette.grey[500],.1),icon:n(ne,{}),chipColor:"default"};return n(ke,{elevation:0,sx:{backgroundColor:s.bgColor,border:`1px solid ${oe(s.color,.3)}`,borderRadius:2,transition:"all 0.3s ease"},children:n(Me,{sx:{p:3},children:[n(N,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[n(N,{sx:{color:s.color,display:"flex",alignItems:"center"},children:s.icon}),n(C,{variant:"h6",sx:{color:s.color,fontWeight:600,flex:1},children:t}),r&&n(k,{label:r,size:"small",color:s.chipColor,variant:"outlined",icon:n(te,{})})]}),o&&n(C,{variant:"body2",color:"text.secondary",sx:{mb:2,lineHeight:1.5},children:o}),(a||i)&&n(N,{sx:{display:"flex",gap:3,mt:2,p:2,backgroundColor:oe(l.palette.background.paper,.6),borderRadius:1,border:`1px solid ${oe(s.color,.1)}`},children:[a&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Amount")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:a})]}),i&&n(N,{children:[n(C,{variant:"caption",color:"text.secondary",children:v("Price")}),n(C,{variant:"subtitle1",sx:{fontWeight:600,color:s.color},children:i})]})]})]})})},At={success:!1,loading:!0,error:""},Lt=[{id:"brief",element:({data:e,payload:t,history:o,onChange:a,onClose:i,setLoading:r})=>{const l=_([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(X,{Navigation:n(K,{hasPrev:!0,hasNext:!!s,labelPrev:v("Close"),onPrev:async()=>{await i()},onNext:async()=>{a({averagePrice:s.averagePrice,symbol:s.symbol}),await l(),o.replace("/form")}}),children:s?c?null:n(S,{payload:()=>({averagePrice:s.averagePrice,symbol:s.symbol}),slots:J,fields:Pt}):null})},isActive:e=>!!se("/brief",e)},{id:"form",element:({data:e,history:t,formState:o,onChange:a})=>{const i=_([e],50);return n(X,{Navigation:n(K,{hasPrev:!0,hasNext:!0,labelPrev:v("Back"),onPrev:async()=>{t.replace("/brief")},onNext:async()=>{a({symbol:o.data.brief.symbol}),await i(),t.replace("/submit")}}),children:n(S,{payload:()=>({averagePrice:o.data.brief.averagePrice}),slots:J,fields:Nt,sx:{pt:1}})})},isActive:e=>!!se("/form",e)},{id:"submit",element:({formState:e,payload:t,beginSave:a,setLoading:i})=>{const[r,l]=o.useState(At),{symbol:s}=o.useMemo(()=>{const{symbol:t}=e.data.form;return{symbol:t}},[e]);E(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:le(e)})}finally{i(!1)}});return n(X,{Navigation:n(K,{hasNext:r.success||!!r.error,labelNext:v("Close"),onNext:async()=>{await a()}}),children:n(N,{p:1,children:r.error?n(kt,{type:"error",title:v("Breakeven Error"),description:r.error,symbol:s}):r.loading?n(kt,{type:"loading",title:v("Moving to Breakeven"),description:v("Please wait. Your operation is being processed..."),symbol:s}):n(kt,{type:"success",title:v("Breakeven Set"),description:v("Breakeven has been scheduled successfully. Waiting for the order to be executed on the exchange"),symbol:s})})})},isActive:e=>!!se("/submit",e)}],$t=[{id:"brief",label:v("Briefing")},{id:"form",label:v("Input")},{id:"submit",label:v("Breakeven")}],Mt="/brief",Tt=me(),Bt=e=>"pnl"===e?v("P&L"):e,Rt=[{type:h.Link,action:"back-action",label:n(xe,{sx:{display:"block"}})},{type:h.Link,action:"back-action",label:v("Main")},{type:h.Link,action:"back-action",label:v("Status")},{type:h.Link,action:"back-action",compute:e=>e?`${String(e.symbol).toUpperCase()} (${e.strategyName})`:v("Live")},{type:h.Link,action:"back-action",label:v("Manual Control")},{type:h.Button,action:"update-now",label:v("Refresh"),icon:ve}],Vt=[{action:"download-action",label:v("Download"),icon:()=>n(x,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:v("Refresh"),icon:()=>n(x,{icon:ve,color:"#4caf50"})}],Ft=[{id:"control",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return V.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=ye(t),{pickData:l,render:s}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:lt,animation:"none",title:v("Open Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:nt,sizeRequest:pe,routes:it,steps:rt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{lt.push(nt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:c,render:d}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:gt,animation:"none",title:v("Average Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:ut,sizeRequest:pe,routes:mt,steps:yt,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{gt.push(ut),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:m,render:h}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:St,animation:"none",title:v("Close Position"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:wt,sizeRequest:pe,routes:xt,steps:Ct,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{St.push(wt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}}),{pickData:b,render:f}=(({payload:e})=>{const{pickData:t,render:o}=ce({history:Tt,animation:"none",title:v("Move to Breakeven"),AfterTitle:({onClose:e})=>n(L,{direction:"row",gap:1,children:n(de,{size:"small",onClick:e,children:n(Q,{})})}),mapPayload:()=>e,pathname:Mt,sizeRequest:pe,routes:Lt,steps:$t,onSubmit:async t=>(t&&await e.reloadSubject.next(),!0)});return{pickData:()=>{Tt.push(Mt),t()},render:o}})({payload:{getContext:()=>r.current,reloadSubject:we}});E(()=>we.subscribe(i)),E(()=>_e.subscribe(l)),E(()=>Qe.subscribe(c)),E(()=>Je.subscribe(m)),E(()=>Ke.subscribe(b));const x=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(fe,{children:[n(g,{items:Rt,actions:Vt,payload:t,onAction:async t=>{"back-action"===t&&u.routerService.push(`/status/${e.id}`),"download-action"===t&&x(),"update-now"===t&&await we.next()}}),o?a?null:n(ue,{component:p,withExpandAll:!0,sx:{p:1,minHeight:"calc(100dvh - 175px)"},payload:t,formatSearch:Bt,AfterSearch:Ze,data:o}):null,n(N,{sx:{paddingBottom:"24px"}}),n(Ce,{}),s(),d(),h(),f()]})},isActive:e=>he(["/status/:id/control"],e)},{id:"status",element:({params:e})=>{const[t]=y(async()=>{const t=await u.statusViewService.getStatusMap();return V.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(z,o);await I(e)});E(()=>Ye.subscribe(i));return n(fe,{children:[n(g,{items:qe,actions:Ue,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 Ye.next(),"download-action"===t&&await r(),"print-action"===t&&await l()}}),a?n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("Loading...")})}):o?n(P,{children:[n(S,{handler:o,fields:H}),n(N,{paddingBottom:"24px"})]}):n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("No pending signal")})}),n(Ce,{})]})},isActive:e=>he(["/status/:id"],e)},{id:"main",element:()=>{const{classes:e}=De(),{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:v("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=Ge(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(fe,{children:[n(g,{items:He,actions:We,onAction:e=>{"back-action"===e&&u.routerService.push("/"),"update-now"===e&&o()}}),i||!a?n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("Loading...")})}):a.length?n(P,{children:[n(S,{className:e.root,fields:a},t),n(N,{paddingBottom:"24px"})]}):n(w,{children:n(C,{variant:"h6",sx:{opacity:.5},children:v("No pending signals")})})]})},isActive:e=>he(["/status"],e)}],zt=({id:e})=>n(ge,{history:u.routerService,onLoadStart:()=>u.layoutService.setAppbarLoader(!0),onLoadEnd:()=>u.layoutService.setAppbarLoader(!1),routes:Ft,params:{id:e}});export{zt as StatusPage,zt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,b8 as t,M as a,t as i,B as r,v as o,bk as n,i as l,bl as s,x as d,b4 as c,bm as w,Z as p,$ as h,a0 as m,a1 as k,b1 as g,bn as b,aI as v,bo as y,av as u,bi as f,b6 as S,ad as x,J as _,bp as N,ax as D,y as V,z as O,A as R,V as L,W as B,q as A,a3 as P,T as C,b3 as $,Y as J,w as M,a4 as j,K as G,a6 as X,m as F,n as H,a5 as I,a7 as E,aj as z}from"./index-CJlJOSPg.js";import{h as T}from"./hasRouteMatch-Bc6IBTG4.js";import{I as U}from"./IconPhoto-CGT-L09K.js";import{C as K,R as W}from"./Refresh-BEzkJ_ge.js";import{K as q}from"./KeyboardArrowLeft-CF6hGzGl.js";const Y=[{id:"backtest",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Z=[{id:"backtest",label:i("Backtest"),isVisible:({type:e})=>"backtest"===e},{id:"live",label:i("Live"),isVisible:({type:e})=>"live"===e},{id:"strategy",label:i("Strategy")},{id:"breakeven",label:i("Breakeven")},{id:"risk",label:i("Risk")},{id:"partial",label:i("Partial")},{id:"highest_profit",label:i("Highest Profit")},{id:"max_drawdown",label:i("Max Drawdown")},{id:"schedule",label:i("Schedule")},{id:"performance",label:i("Performance")},{id:"sync",label:i("Sync")},{id:"heat",label:i("Heat")}],Q=({disabled:t,className:a,style:r,sx:c,onClick:w,color:p})=>e(s,{className:a,style:r,sx:c,disabled:t,color:p,size:36,onClick:async e=>{const[t,{resolve:a}]=n();e.preventDefault(),e.stopPropagation(),await w(e,e=>a(e));const r=await t;await(async e=>{let t=!1;t=t||"string"==typeof e,t=t||"number"==typeof e,t=t||"boolean"==typeof e,t=t||void 0===e,t=t||null===e,t&&await d(String(e))})(r),l.alertService.notify(i("Copied!"))},children:e(o,{})}),ee=[{action:"json",label:i("Download JSON"),icon:()=>e(h,{icon:p,color:"#4caf50"})},{action:"markdown",label:i("Download Markdown"),icon:()=>e(h,{icon:m,color:"#4caf50"})},{action:"pdf",label:i("Download PDF"),icon:()=>e(h,{icon:k,color:"#4caf50"})}],te=({disabled:t,className:a,style:i,sx:r,onDownloadJson:o,onDownloadMarkdown:n,onDownloadPdf:l})=>{const s=c(async e=>{"json"===e?await o():"markdown"===e?await n():"pdf"===e&&await l()});return e(w,{transparent:!0,className:a,style:i,sx:r,disabled:t,options:ee,onAction:s})},ae=u(),ie=D(async(e,t)=>{const a=("backtest"===t?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:n}=a,[s,d,c,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?l.markdownViewService.getBacktestReport(i,r,o,n):Promise.resolve(""),"live"===t?l.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),l.markdownViewService.getBreakevenReport(i,r,o,n,"backtest"===t),l.markdownViewService.getRiskReport(i,r,o,n,"backtest"===t),l.markdownViewService.getPartialReport(i,r,o,n,"backtest"===t),l.markdownViewService.getHighestProfitReport(i,r,o,n,"backtest"===t),l.markdownViewService.getMaxDrawdownReport(i,r,o,n,"backtest"===t),l.markdownViewService.getScheduleReport(i,r,o,n,"backtest"===t),l.markdownViewService.getPerformanceReport(i,r,o,n,"backtest"===t),l.markdownViewService.getSyncReport(i,r,o,n,"backtest"===t),l.markdownViewService.getHeatReport(r,o,n,"backtest"===t),l.markdownViewService.getStrategyReport(i,r,o,n,"backtest"===t)]);return{type:t,backtest:s,live:d,breakeven:c,risk:w,partial:p,highest_profit:h,max_drawdown:m,schedule:k,performance:g,sync:b,heat:v,strategy:y}},{timeout:45e3,key:([e,t])=>`${e}_${t}`}),re=()=>{const[t,a]=g(""),[o,n]=g("backtest"),d=b(),{push:c,pop:w}=d,[p,h]=v(ae.location.pathname),m=async()=>{const e=(await ie(t.current,o.current))[p.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},k=async()=>{const e=await ie(t.current,o.current),a=p.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);l.layoutService.downloadFile(t,`${a}_${o.current}_${Date.now()}.md`)}},u=async()=>{const e=("backtest"===o.current?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:r,frameName:n}=e,s=p.current.replace("/markdown_report/",""),d="backtest"===o.current;let c;if("backtest"===s?c=await l.markdownViewService.getBacktestData(a,i,r,n):"live"===s?c=await l.markdownViewService.getLiveData(a,i,r):"breakeven"===s?c=await l.markdownViewService.getBreakevenData(a,i,r,n,d):"risk"===s?c=await l.markdownViewService.getRiskData(a,i,r,n,d):"partial"===s?c=await l.markdownViewService.getPartialData(a,i,r,n,d):"highest_profit"===s?c=await l.markdownViewService.getHighestProfitData(a,i,r,n,d):"max_drawdown"===s?c=await l.markdownViewService.getMaxDrawdownData(a,i,r,n,d):"schedule"===s?c=await l.markdownViewService.getScheduleData(a,i,r,n,d):"performance"===s?c=await l.markdownViewService.getPerformanceData(a,i,r,n,d):"sync"===s?c=await l.markdownViewService.getSyncData(a,i,r,n,d):"heat"===s?c=await l.markdownViewService.getHeatData(i,r,n,d):"strategy"===s&&(c=await l.markdownViewService.getStrategyData(a,i,r,n,d)),void 0!==c){const e=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);l.layoutService.downloadFile(t,`${s}_${o.current}_${Date.now()}.json`)}},{pickData:D,render:O}=y({tabs:Z,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),h(a)},animation:"none",title:i("Markdown Report"),sizeRequest:f,history:ae,routes:Y,BeforeTitle:({onClose:t})=>{const{total:a}=b();return e(r,{sx:{mr:1,display:1===a?"none":"flex"},children:e(s,{onClick:t,children:e(N,{})})})},AfterTitle:({onClose:a})=>e(_,{direction:"row",gap:1,children:[e(s,{sx:{mr:"10px"},onClick:()=>m(),children:e(S,{})}),e(Q,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:n,exchangeName:s,frameName:d}=r,c="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await l.markdownViewService.getBacktestData(o,n,s,d),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await l.markdownViewService.getLiveData(o,n,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await l.markdownViewService.getBreakevenData(o,n,s,d,c),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await l.markdownViewService.getRiskData(o,n,s,d,c),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await l.markdownViewService.getPartialData(o,n,s,d,c),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await l.markdownViewService.getHighestProfitData(o,n,s,d,c),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await l.markdownViewService.getMaxDrawdownData(o,n,s,d,c),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await l.markdownViewService.getScheduleData(o,n,s,d,c),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await l.markdownViewService.getPerformanceData(o,n,s,d,c),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await l.markdownViewService.getSyncData(o,n,s,d,c),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await l.markdownViewService.getHeatData(n,s,d,c),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await l.markdownViewService.getStrategyData(o,n,s,d,c),null,2))})(p.current,t.current,o.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(te,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:u,onDownloadMarkdown:k,onDownloadPdf:m}),e(s,{onClick:a,children:e(x,{})})]}),fetchState:async()=>await ie(t.current,o.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:d,sync:c,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:d,sync:c,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),onClose:()=>{w()}});return(e,t)=>{c({id:"markdown_report_modal",render:O,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";ae.push(e),h(e)},onMount:()=>{a(e),n(t),D()}})}},oe="backtest-kit__groupHeader",ne="backtest-kit__groupRoot",le="backtest-kit__symbolImage",se=A()({root:{[`& .${ne}:hover .${oe}`]:{opacity:"1 !important"}}});function de(e){return E(e,"#000000")>E(e,"#FFFFFF")}const ce=[{type:B.Link,action:"back-action",label:e(q,{sx:{display:"block"}})},{type:B.Link,action:"back-action",label:i("Main")},{type:B.Link,action:"back-action",label:i("Markdown Report")}],we=[{action:"update-now",label:i("Refresh"),icon:()=>e(h,{icon:W,color:"#4caf50"})}],pe=(t,a)=>({type:P.Group,className:ne,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:P.Component,className:oe,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(_,{direction:"row",children:[e(j,{variant:"outlined",size:"small",color:"info",label:`${G.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(r,{flex:1})]})},{type:P.Group,fields:a.map(({symbol:t,label:a,id:i,type:o,color:n})=>((t,a,i,o,n)=>({type:P.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:l})=>e(I,{component:X,onClick:()=>{l.handleOpen(t,a)},sx:{width:"100%",background:n,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${le}`]:{transition:"filter 500ms"},"&:hover":{background:()=>de(n)?F(n,.33):H(n,.33),[`& .${le}`]:{transition:"filter 500ms",filter:de(n)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(U,{className:le,symbol:i}),children:e(r,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(i,o,t,a,n))}]}),he=[{id:"main",element:()=>{const{classes:t}=se(),{reloadTrigger:a,doReload:o}=O(),[n,{loading:s}]=R(async()=>await(async()=>{const[e,t,a]=await Promise.all([l.symbolGlobalService.getSymbolMap(),l.backtestGlobalService.list(),l.liveGlobalService.list()]),r={},o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;r[i]||(r[i]=[]),r[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",type:"backtest",id:t.id})}),a.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",id:t.id,type:"live"})});const n=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>pe(e,t)),s=Object.entries(o).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>pe(e,t));return s.length||n.length?[{type:P.Fragment,isVisible:()=>!!n.length,fields:[{type:P.Line,title:i("Backtest")},{type:P.Group,columns:"12",fields:n}]},{type:P.Fragment,isVisible:()=>!!s.length,fields:[{type:P.Line,title:i("Live")},{type:P.Group,columns:"12",fields:s}]}]:[]})(),{onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),deps:[a]}),d=re(),c=(e,t)=>{d(e,t)};return e(K,{children:[e(L,{items:ce,actions:we,onAction:e=>{"back-action"===e&&l.routerService.push("/"),"update-now"===e&&o()}}),s||!n?e($,{children:e(C,{variant:"h6",sx:{opacity:.5},children:i("Loading...")})}):n.length?e(M,{children:[e(J,{className:t.root,fields:n,payload:()=>({handleOpen:c})},a),e(r,{paddingBottom:"24px"})]}):e($,{children:e(C,{variant:"h6",sx:{opacity:.5},children:i("No pending signals")})})]})},isActive:e=>T(["/report"],e)}],me=({id:t})=>e(z,{history:l.routerService,onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),routes:he,params:{id:t}});export{me as StatusPage,me as default};
|
|
1
|
+
import{f as e,b8 as t,M as a,t as i,B as r,v as o,bk as n,i as l,bl as s,x as d,b4 as c,bm as w,Z as p,$ as h,a0 as m,a1 as k,b1 as g,bn as b,aI as v,bo as y,av as u,bi as f,b6 as S,ad as x,J as _,bp as N,ax as D,y as V,z as O,A as R,V as L,W as B,q as A,a3 as P,T as C,b3 as $,Y as J,w as M,a4 as j,K as G,a6 as X,m as F,n as H,a5 as I,a7 as E,aj as z}from"./index-WZ_nxkBQ.js";import{h as T}from"./hasRouteMatch-_bnrnDj6.js";import{I as U}from"./IconPhoto-BorPc4HC.js";import{C as K,R as W}from"./Refresh-Bx2t72xl.js";import{K as q}from"./KeyboardArrowLeft-mYxZRvhi.js";const Y=[{id:"backtest",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:o})=>e(r,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:o||i("# No data")}),e(r,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Z=[{id:"backtest",label:i("Backtest"),isVisible:({type:e})=>"backtest"===e},{id:"live",label:i("Live"),isVisible:({type:e})=>"live"===e},{id:"strategy",label:i("Strategy")},{id:"breakeven",label:i("Breakeven")},{id:"risk",label:i("Risk")},{id:"partial",label:i("Partial")},{id:"highest_profit",label:i("Highest Profit")},{id:"max_drawdown",label:i("Max Drawdown")},{id:"schedule",label:i("Schedule")},{id:"performance",label:i("Performance")},{id:"sync",label:i("Sync")},{id:"heat",label:i("Heat")}],Q=({disabled:t,className:a,style:r,sx:c,onClick:w,color:p})=>e(s,{className:a,style:r,sx:c,disabled:t,color:p,size:36,onClick:async e=>{const[t,{resolve:a}]=n();e.preventDefault(),e.stopPropagation(),await w(e,e=>a(e));const r=await t;await(async e=>{let t=!1;t=t||"string"==typeof e,t=t||"number"==typeof e,t=t||"boolean"==typeof e,t=t||void 0===e,t=t||null===e,t&&await d(String(e))})(r),l.alertService.notify(i("Copied!"))},children:e(o,{})}),ee=[{action:"json",label:i("Download JSON"),icon:()=>e(h,{icon:p,color:"#4caf50"})},{action:"markdown",label:i("Download Markdown"),icon:()=>e(h,{icon:m,color:"#4caf50"})},{action:"pdf",label:i("Download PDF"),icon:()=>e(h,{icon:k,color:"#4caf50"})}],te=({disabled:t,className:a,style:i,sx:r,onDownloadJson:o,onDownloadMarkdown:n,onDownloadPdf:l})=>{const s=c(async e=>{"json"===e?await o():"markdown"===e?await n():"pdf"===e&&await l()});return e(w,{transparent:!0,className:a,style:i,sx:r,disabled:t,options:ee,onAction:s})},ae=u(),ie=D(async(e,t)=>{const a=("backtest"===t?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:n}=a,[s,d,c,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?l.markdownViewService.getBacktestReport(i,r,o,n):Promise.resolve(""),"live"===t?l.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),l.markdownViewService.getBreakevenReport(i,r,o,n,"backtest"===t),l.markdownViewService.getRiskReport(i,r,o,n,"backtest"===t),l.markdownViewService.getPartialReport(i,r,o,n,"backtest"===t),l.markdownViewService.getHighestProfitReport(i,r,o,n,"backtest"===t),l.markdownViewService.getMaxDrawdownReport(i,r,o,n,"backtest"===t),l.markdownViewService.getScheduleReport(i,r,o,n,"backtest"===t),l.markdownViewService.getPerformanceReport(i,r,o,n,"backtest"===t),l.markdownViewService.getSyncReport(i,r,o,n,"backtest"===t),l.markdownViewService.getHeatReport(r,o,n,"backtest"===t),l.markdownViewService.getStrategyReport(i,r,o,n,"backtest"===t)]);return{type:t,backtest:s,live:d,breakeven:c,risk:w,partial:p,highest_profit:h,max_drawdown:m,schedule:k,performance:g,sync:b,heat:v,strategy:y}},{timeout:45e3,key:([e,t])=>`${e}_${t}`}),re=()=>{const[t,a]=g(""),[o,n]=g("backtest"),d=b(),{push:c,pop:w}=d,[p,h]=v(ae.location.pathname),m=async()=>{const e=(await ie(t.current,o.current))[p.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},k=async()=>{const e=await ie(t.current,o.current),a=p.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);l.layoutService.downloadFile(t,`${a}_${o.current}_${Date.now()}.md`)}},u=async()=>{const e=("backtest"===o.current?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:r,frameName:n}=e,s=p.current.replace("/markdown_report/",""),d="backtest"===o.current;let c;if("backtest"===s?c=await l.markdownViewService.getBacktestData(a,i,r,n):"live"===s?c=await l.markdownViewService.getLiveData(a,i,r):"breakeven"===s?c=await l.markdownViewService.getBreakevenData(a,i,r,n,d):"risk"===s?c=await l.markdownViewService.getRiskData(a,i,r,n,d):"partial"===s?c=await l.markdownViewService.getPartialData(a,i,r,n,d):"highest_profit"===s?c=await l.markdownViewService.getHighestProfitData(a,i,r,n,d):"max_drawdown"===s?c=await l.markdownViewService.getMaxDrawdownData(a,i,r,n,d):"schedule"===s?c=await l.markdownViewService.getScheduleData(a,i,r,n,d):"performance"===s?c=await l.markdownViewService.getPerformanceData(a,i,r,n,d):"sync"===s?c=await l.markdownViewService.getSyncData(a,i,r,n,d):"heat"===s?c=await l.markdownViewService.getHeatData(i,r,n,d):"strategy"===s&&(c=await l.markdownViewService.getStrategyData(a,i,r,n,d)),void 0!==c){const e=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);l.layoutService.downloadFile(t,`${s}_${o.current}_${Date.now()}.json`)}},{pickData:D,render:O}=y({tabs:Z,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),h(a)},animation:"none",title:i("Markdown Report"),sizeRequest:f,history:ae,routes:Y,BeforeTitle:({onClose:t})=>{const{total:a}=b();return e(r,{sx:{mr:1,display:1===a?"none":"flex"},children:e(s,{onClick:t,children:e(N,{})})})},AfterTitle:({onClose:a})=>e(_,{direction:"row",gap:1,children:[e(s,{sx:{mr:"10px"},onClick:()=>m(),children:e(S,{})}),e(Q,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await l.backtestGlobalService.list():await l.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:n,exchangeName:s,frameName:d}=r,c="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await l.markdownViewService.getBacktestData(o,n,s,d),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await l.markdownViewService.getLiveData(o,n,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await l.markdownViewService.getBreakevenData(o,n,s,d,c),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await l.markdownViewService.getRiskData(o,n,s,d,c),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await l.markdownViewService.getPartialData(o,n,s,d,c),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await l.markdownViewService.getHighestProfitData(o,n,s,d,c),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await l.markdownViewService.getMaxDrawdownData(o,n,s,d,c),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await l.markdownViewService.getScheduleData(o,n,s,d,c),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await l.markdownViewService.getPerformanceData(o,n,s,d,c),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await l.markdownViewService.getSyncData(o,n,s,d,c),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await l.markdownViewService.getHeatData(n,s,d,c),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await l.markdownViewService.getStrategyData(o,n,s,d,c),null,2))})(p.current,t.current,o.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(te,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:u,onDownloadMarkdown:k,onDownloadPdf:m}),e(s,{onClick:a,children:e(x,{})})]}),fetchState:async()=>await ie(t.current,o.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:d,sync:c,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:d,sync:c,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),onClose:()=>{w()}});return(e,t)=>{c({id:"markdown_report_modal",render:O,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";ae.push(e),h(e)},onMount:()=>{a(e),n(t),D()}})}},oe="backtest-kit__groupHeader",ne="backtest-kit__groupRoot",le="backtest-kit__symbolImage",se=A()({root:{[`& .${ne}:hover .${oe}`]:{opacity:"1 !important"}}});function de(e){return E(e,"#000000")>E(e,"#FFFFFF")}const ce=[{type:B.Link,action:"back-action",label:e(q,{sx:{display:"block"}})},{type:B.Link,action:"back-action",label:i("Main")},{type:B.Link,action:"back-action",label:i("Markdown Report")}],we=[{action:"update-now",label:i("Refresh"),icon:()=>e(h,{icon:W,color:"#4caf50"})}],pe=(t,a)=>({type:P.Group,className:ne,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:P.Component,className:oe,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(_,{direction:"row",children:[e(j,{variant:"outlined",size:"small",color:"info",label:`${G.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(r,{flex:1})]})},{type:P.Group,fields:a.map(({symbol:t,label:a,id:i,type:o,color:n})=>((t,a,i,o,n)=>({type:P.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:l})=>e(I,{component:X,onClick:()=>{l.handleOpen(t,a)},sx:{width:"100%",background:n,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${le}`]:{transition:"filter 500ms"},"&:hover":{background:()=>de(n)?F(n,.33):H(n,.33),[`& .${le}`]:{transition:"filter 500ms",filter:de(n)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(U,{className:le,symbol:i}),children:e(r,{sx:{overflow:"hidden",textOverflow:"ellipsis",width:"75px"},children:o})})}))(i,o,t,a,n))}]}),he=[{id:"main",element:()=>{const{classes:t}=se(),{reloadTrigger:a,doReload:o}=O(),[n,{loading:s}]=R(async()=>await(async()=>{const[e,t,a]=await Promise.all([l.symbolGlobalService.getSymbolMap(),l.backtestGlobalService.list(),l.liveGlobalService.list()]),r={},o={};t.forEach(t=>{const a=e[t.symbol],i=t.strategyName;r[i]||(r[i]=[]),r[i].push({symbol:t.symbol,label:(null==a?void 0:a.displayName)||t.symbol,color:(null==a?void 0:a.color)||"#ccc",type:"backtest",id:t.id})}),a.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",id:t.id,type:"live"})});const n=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>pe(e,t)),s=Object.entries(o).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>pe(e,t));return s.length||n.length?[{type:P.Fragment,isVisible:()=>!!n.length,fields:[{type:P.Line,title:i("Backtest")},{type:P.Group,columns:"12",fields:n}]},{type:P.Fragment,isVisible:()=>!!s.length,fields:[{type:P.Line,title:i("Live")},{type:P.Group,columns:"12",fields:s}]}]:[]})(),{onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),deps:[a]}),d=re(),c=(e,t)=>{d(e,t)};return e(K,{children:[e(L,{items:ce,actions:we,onAction:e=>{"back-action"===e&&l.routerService.push("/"),"update-now"===e&&o()}}),s||!n?e($,{children:e(C,{variant:"h6",sx:{opacity:.5},children:i("Loading...")})}):n.length?e(M,{children:[e(J,{className:t.root,fields:n,payload:()=>({handleOpen:c})},a),e(r,{paddingBottom:"24px"})]}):e($,{children:e(C,{variant:"h6",sx:{opacity:.5},children:i("No pending signals")})})]})},isActive:e=>T(["/report"],e)}],me=({id:t})=>e(z,{history:l.routerService,onLoadStart:()=>l.layoutService.setAppbarLoader(!0),onLoadEnd:()=>l.layoutService.setAppbarLoader(!1),routes:he,params:{id:t}});export{me as StatusPage,me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e,f as t,t as n,c as r,r as i,i as o,S as a,F as l,a as c}from"./index-
|
|
1
|
+
import{P as e,f as t,t as n,c as r,r as i,i as o,S as a,F as l,a as c}from"./index-WZ_nxkBQ.js";const[s,u]=e("pine-code-context"),d=e=>t(s,{initialState:'//@version=5\nindicator("Simple MA", overlay=true)\n\nlength = input.int(20, "Length")\nsma = ta.sma(close, length)\n\nplot(sma, "SMA", color.blue, linewidth=2)',children:e.children}),[v,h]=e("pine-from-date-context"),m=e=>t(v,{initialState:"",children:e.children}),[p,g]=e("pine-limit-context"),f=e=>t(p,{initialState:250,children:e.children}),[y,b]=e("pine-symbol-context"),C=e=>t(y,{initialState:"BTCUSDT",children:e.children}),[D,x]=e("pine-timeframe-context"),S=e=>t(D,{initialState:"1",children:e.children}),[w,T]=e("pine-to-date-context"),k=e=>t(w,{initialState:"",children:e.children}),R=r(e=>t("div",{style:e.v0,children:[t("input",{type:"text",value:e.v1,onChange:e.v2,style:e.v3,placeholder:"BTCUSDT"}),t("select",{value:e.v4,onChange:e.v5,style:e.v6,children:e.v7}),t("input",{type:"number",value:e.v8,min:100,step:100,onChange:e.v9,style:e.v10,title:e.v11}),t("input",{type:"date",value:e.v12,onChange:e.v13,style:e.v14,title:e.v15}),t("input",{type:"date",value:e.v16,onChange:e.v17,style:e.v18,title:e.v19}),t("button",{onClick:e.v20,disabled:e.v21,style:e.v22,children:e.v23}),e.v24]}),{name:"Toolbar_1",portals:["v7","v23","v24"]}),z=function({symbol:e,timeframe:r,fromDate:i,toDate:o,limit:a,running:l,status:c,onSymbolChange:s,onTimeframeChange:u,onFromDateChange:d,onToDateChange:v,onLimitChange:h,onRun:m}){return t(R,{v0:{display:"flex",gap:8,padding:"8px 12px",background:"#1e293b",alignItems:"center",flexShrink:0},v1:e,v2:e=>s(e.target.value.toUpperCase()),v3:{...B,width:100},v4:r,v5:e=>u(e.target.value),v6:B,v7:F.map(e=>t("option",{children:e},e)),v8:a,v9:e=>h(Number(e.target.value)),v10:{...B,width:80},v11:n("Bars limit"),v12:i,v13:e=>d(e.target.value),v14:$,v15:n("From date"),v16:o,v17:e=>v(e.target.value),v18:$,v19:n("To date"),v20:m,v21:l,v22:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:4,padding:"5px 16px",fontSize:13,cursor:"pointer"},v23:l?"...":n("▶ Run"),v24:c&&t("span",{style:{fontSize:12,color:"#94a3b8",marginLeft:8},children:c})})},F=["1","5","15","60","D"],B={background:"#1e293b",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,padding:"4px 8px",fontSize:13},$={...B,colorScheme:"dark"},U=r(e=>t("textarea",{value:e.v0,onChange:e.v1,onKeyDown:e.v2,spellCheck:!1,style:e.v3}),{name:"CodeEditor_1"}),E=function({value:e,onChange:n,onRun:r}){return t(U,{v0:e,v1:e=>n(e.target.value),v2:e=>{e.ctrlKey&&"Enter"===e.key&&(e.preventDefault(),r())},v3:{width:320,flexShrink:0,resize:"none",background:"#1e293b",color:"#e2e8f0",border:"none",borderRight:"1px solid #334155",padding:12,fontFamily:"monospace",fontSize:13,lineHeight:1.5,outline:"none"}})},L={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h","1D":"1d",D:"1d"};function I(e){return{time:e.openTime,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}}class M{async getMarketData(e,t,n,r,i){const a=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),l=L[t]??t;return(await o.exchangeViewService.getRangeCandles({symbol:a,interval:l,limit:n,sDate:r,eDate:i})).map(e=>({openTime:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}async getSymbolInfo(e){const t=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),n=t.replace(/USDT$|BUSD$|USD$/,""),r=t.replace(n,"");return{ticker:t,tickerid:t,description:`${n}/${r}`,type:"crypto",basecurrency:n,currency:r||"USDT",timezone:"UTC"}}}const P=()=>t(a,{children:"\n #root > .MuiBox-root {\n padding-left: 0;\n padding-right: 0;\n }\n "}),A=()=>{const e=i.useRef(null),[r,o]=u(),[a,c]=b(),[s,d]=x(),[v,m]=h(),[p,f]=T(),[y,C]=g(),{run:D,status:S,running:w}=function(){const e=i.useRef(null),t=i.useRef(null),r=i.useRef(null),[o,a]=i.useState(""),[l,c]=i.useState(!1);function s(){if(r.current){try{r.current.stop()}catch{}r.current=null}}function u(){e.current&&(e.current.destroy(),e.current=null,t.current=null)}function d(e){a(`${n("Error")}: ${e.message}`),c(!1)}return i.useEffect(()=>{const t=()=>{var t;return null==(t=e.current)?void 0:t.resize()};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),s(),u()}},[]),{run:function({symbol:i,timeframe:o,fromDate:l,toDate:v,limit:h,code:m,containerRef:p}){if(!p.current)return;c(!0),a(n("Connecting...")),s(),u();const g=/indicator\([^)]*overlay\s*=\s*true/i.test(m);let f=!1;try{const s=l?new Date(l).getTime():void 0,u=v?new Date(v).getTime():void 0,y=new M,b=new PineTS(y,i,o,h,s,u).stream(m,{pageSize:500,live:!0,interval:3e3});r.current=b,b.on("data",l=>{var s,u;if(r.current===b)if(f)t.current&&l.plots&&t.current.updateData(l.plots),null==(u=e.current)||u.updateData([I(l.marketData[l.marketData.length-1])]);else{f=!0;const r=l.marketData.map(I);p.current.innerHTML="",e.current=new QFChart.QFChart(p.current,{title:`${i} · ${o}`,backgroundColor:"#0f172a",height:"100%",padding:.1,databox:{position:"right",triggerOn:"mousemove"},dataZoom:{visible:!0,position:"top",height:6,start:80,end:101},layout:{mainPaneHeight:"70%",gap:5},controls:{collapse:!1,maximize:!1,fullscreen:!1}}),e.current.setMarketData(r);const u=(null==(s=l.fullContext)?void 0:s.plots)??l.plots;t.current=e.current.addIndicator("indicator",u,{overlay:g,height:g?void 0:30,controls:{collapse:!1,maximize:!1}}),e.current.registerPlugin(new QFChart.MeasureTool),e.current.registerPlugin(new QFChart.LineTool),e.current.registerPlugin(new QFChart.FibonacciTool),a(`${r.length} ${n("bars loaded")}`),c(!1)}}),b.on("error",d)}catch(y){d(y)}},status:o,running:l}}();function k(){D({symbol:a,timeframe:s,fromDate:v,toDate:p,limit:y,code:r,containerRef:e})}return t(l,{children:t("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"#0f172a",color:"#e2e8f0",fontFamily:"monospace"},children:[t(z,{symbol:a,timeframe:s,fromDate:v,toDate:p,limit:y,running:w,status:S,onSymbolChange:c,onTimeframeChange:d,onFromDateChange:m,onToDateChange:f,onLimitChange:C,onRun:k}),t("div",{style:{display:"flex",flex:1,overflow:"clip"},children:[t(E,{value:r,onChange:o,onRun:k}),t("div",{style:{flex:1},children:t("div",{ref:e,style:{width:"100%",height:"100%"},children:t("p",{style:{color:"#475569",textAlign:"center",marginTop:"20%"},children:[n("Press")," ",t("b",{children:n("▶ Run")})," ",n("or")," ",t("b",{children:"Ctrl+Enter"})," ",n("to load the chart")]})})})]}),t(P,{})]})})},N=c(e=>t(d,{children:e}),e=>t(m,{children:e}),e=>t(k,{children:e}),e=>t(f,{children:e}),e=>t(C,{children:e}),e=>t(S,{children:e})),Q=()=>N(t(A,{}));export{Q as PinePage,Q as default};
|