@backtest-kit/ui 8.5.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +254 -254
  2. package/build/modules/frontend/build/3rdparty/ace_1.4.12/ace.js +21337 -21337
  3. package/build/modules/frontend/build/3rdparty/ace_1.4.12/mode-javascript.js +797 -797
  4. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-chrome.js +137 -137
  5. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-twilight.js +115 -115
  6. package/build/modules/frontend/build/3rdparty/ace_1.4.12/worker-javascript.js +15012 -15012
  7. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/echarts.min.js +45 -45
  8. package/build/modules/frontend/build/assets/{Article-Dh_vYreB.js → Article-DDKZjbkz.js} +1 -1
  9. package/build/modules/frontend/build/assets/{Background-B2ldn454.js → Background-5Pc2kls4.js} +1 -1
  10. package/build/modules/frontend/build/assets/{IconPhoto-C2SEjuLJ.js → IconPhoto-2KIaDXXx.js} +1 -1
  11. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-CXc4SNLm.js → KeyboardArrowLeft-nUGbVivG.js} +1 -1
  12. package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-BHHWm0bL.js → PictureAsPdfOutlined-BKzXxbqU.js} +1 -1
  13. package/build/modules/frontend/build/assets/{Refresh-OHKLL7G_.js → Refresh-6IBmzTpL.js} +1 -1
  14. package/build/modules/frontend/build/assets/emitters-1aP5uqiT.js +1 -0
  15. package/build/modules/frontend/build/assets/{hasRouteMatch-EVPvlDIB.js → hasRouteMatch-Bw2df_bl.js} +1 -1
  16. package/build/modules/frontend/build/assets/{html2canvas-YNpy5BaY.js → html2canvas-731slHaR.js} +1 -1
  17. package/build/modules/frontend/build/assets/{index-SfsF53Bs.js → index-BFZbztqX.js} +1 -1
  18. package/build/modules/frontend/build/assets/{index-B5xjPulX.js → index-BgpdZ4rO.js} +1 -1
  19. package/build/modules/frontend/build/assets/{index-CXKu4KrJ.js → index-CZUmXlNR.js} +1 -1
  20. package/build/modules/frontend/build/assets/{index-CME9eeIW.js → index-CljWW6CQ.js} +1 -1
  21. package/build/modules/frontend/build/assets/{index-ZZ-3mMMq.js → index-Cpcp7B0Y.js} +1 -1
  22. package/build/modules/frontend/build/assets/{index-EBlc2pjc.js → index-DVsJHggN.js} +1 -1
  23. package/build/modules/frontend/build/assets/{index-CylbBsJT.js → index-Dbf0lzpr.js} +1 -1
  24. package/build/modules/frontend/build/assets/{index-B8ACWkBR.js → index-DbkxgA90.js} +1 -1
  25. package/build/modules/frontend/build/assets/{index-BFgNsirj.js → index-Di2oEk8q.js} +1 -1
  26. package/build/modules/frontend/build/assets/{index-mIAPQczG.js → index-DtUu3BzB.js} +1 -1
  27. package/build/modules/frontend/build/assets/{index-CFsxiZyp.js → index-DywLUAcD.js} +1 -1
  28. package/build/modules/frontend/build/assets/{index-D6-5rbio.js → index-GZdKxtUQ.js} +1 -1
  29. package/build/modules/frontend/build/assets/{index-DA0cY5CT.js → index-is6UARFt.js} +7 -7
  30. package/build/modules/frontend/build/assets/{index.es-BGETDkul.js → index.es-CShnY6Uk.js} +1 -1
  31. package/build/modules/frontend/build/assets/{markdownit-DBOjQC5v.js → markdownit-DnS0ASYl.js} +1 -1
  32. package/build/modules/frontend/build/index.html +87 -87
  33. package/build/modules/frontend/build/manifest.json +23 -23
  34. package/package.json +118 -118
  35. package/build/modules/frontend/build/assets/emitters-ftFfHgfR.js +0 -1
@@ -1 +1 @@
1
- import{b as e,f as t,i as o,ak as a,al as n,am as l,r as i,an as r,p as s,T as c,ag as d,c as p,P as u,F as m,ao as h,ap as g,aq as y,B as f,ab as v,ar as b,as as x,a0 as C,at as k,au as w,av as P,aw as S,ax as L,ay as M,H as N,a4 as R,I as $,az as T,N as D,aA as j,L as B,O as I,z as V,J as A,X as E,aB as O,Y as z,Z as F,v as U,w as W,D as H,aC as G,aD as Y,x as _}from"./index-DA0cY5CT.js";import{I as K}from"./IconPhoto-C2SEjuLJ.js";import{C as X,R as J}from"./Refresh-OHKLL7G_.js";import{K as q}from"./KeyboardArrowLeft-CXc4SNLm.js";const Z=e(t("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 10V8h-2v4H8l4 4 4-4h-3z"}),"ArrowCircleDown"),Q=e(t("path",{d:"M12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0 2c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10zm-1-10v4h2v-4h3l-4-4-4 4h3z"}),"ArrowCircleUp"),ee=e(t("path",{d:"M7.5 5.6 10 7 8.6 4.5 10 2 7.5 3.4 5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.9959.9959 0 0 0-1.41 0L1.29 18.96c-.39.39-.39 1.02 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05c.39-.39.39-1.02 0-1.41l-2.33-2.35zm-1.03 5.49-2.12-2.12 2.44-2.44 2.12 2.12-2.44 2.44z"}),"AutoFixHigh"),te=e(t("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2z"}),"Circle"),oe=l(async e=>"live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),{key:([e])=>`${e}`,timeout:45e3}),ae=async(e,t)=>(await oe(t)).filter(t=>"closed"===t.status&&t.symbol===e),ne=async(e,t)=>{const o=await ae(e,t);return{total:o.length,resolvedCount:o.filter(e=>e.pnl.pnlPercentage>0).length,rejectedCount:o.filter(e=>e.pnl.pnlPercentage<=0).length}},le=async(e,t)=>{const o=await ae(e,t),a=e=>Math.abs(e.pnl.priceClose-e.priceTakeProfit)/e.priceTakeProfit<.005,n=e=>Math.abs(e.pnl.priceClose-e.priceStopLoss)/e.priceStopLoss<.005;return{resolvedTakeProfitCount:o.filter(e=>e.pnl.pnlPercentage>0&&a(e)).length,rejectedStopLossCount:o.filter(e=>e.pnl.pnlPercentage<=0&&n(e)).length,resolvedCloseCount:o.filter(e=>e.pnl.pnlPercentage>0&&!a(e)).length,rejectedCloseCount:o.filter(e=>e.pnl.pnlPercentage<=0&&!n(e)).length}},ie=async(e,t)=>{const o=await ae(e,t),l=new Map;for(const i of o){const e=a(n(i.updatedAt)),t=l.get(e)??{resolved:0,rejected:0};i.pnl.pnlPercentage>0?l.set(e,{...t,resolved:t.resolved+1}):l.set(e,{...t,rejected:t.rejected+1})}return Array.from(l.entries()).map(([e,{resolved:t,rejected:o}])=>({stamp:e,count:t+o,resolved:t,rejected:o}))},re=async(e,t)=>{const o=await ae(e,t),a="backtest"===t&&o.length?o.reduce((e,t)=>Math.max(e,t.updatedAt),0):Date.now(),l=n(a).startOf("day").valueOf(),i=l-864e5,r=l-6048e5,s=l-26784e5,c=e=>e.reduce((e,t)=>e+t.pnl.pnlCost,0),d=o.filter(e=>e.updatedAt>=l),p=o.filter(e=>e.updatedAt>=i&&e.updatedAt<l),u=o.filter(e=>e.updatedAt>=r),m=o.filter(e=>e.updatedAt>=s);return{symbol:e,todayRevenue:c(d),yesterdayRevenue:c(p),sevenDaysRevenue:c(u),thirtyOneDaysRevenue:c(m),todayCount:d.length,yesterdayCount:p.length,sevenDaysCount:u.length,thirtyOneDaysCount:m.length}};var se=(e=>(e.Red="#DD4049",e.Orange="#F3A43A",e.Green="#2EA96F",e.Blue="#2979ff",e.Violet="#d500f9",e))(se||{});const ce=i.createContext(null),de=({value:e,children:o})=>t(ce.Provider,{value:e,children:o}),pe=()=>i.useContext(ce);var ue=(e=>(e.Semi="semi",e.Solid="solid",e.Unset="unset",e))(ue||{});const me=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"stretch",whiteSpace:"nowrap",gap:"8px",overflow:"clip",padding:"10px",borderTop:`1px solid ${e.palette.divider}`,"& > *":{flex:1}},solidBackground:{color:"#fff","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}},semiBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}}})),he=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=me(),{footerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...s===ue.Solid&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},ge=(e,t=2)=>{let o=1;for(let a=0;a<t;a++)o*=10;return Math.round(e*o)/o},ye=s()({root:{position:"relative",width:"100%",height:"0px"},container:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center"}}),fe=({caption:e})=>{const{classes:o}=ye();return t("div",{className:o.root,children:t("div",{className:o.container,children:t(c,{variant:"caption",sx:{opacity:.5,fontSize:12,textAlign:"center",padding:"0 8px"},children:e})})})},ve=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},solidBackground:{"& > :first-of-type":{color:"#fff",fontWeight:"bold"},"& > :last-of-type":{color:"#fff"}},unsetBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},semiBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},content:{display:"flex",alignItems:"baseline",flexDirection:"row",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),be=p(e=>t("div",{className:e.v0,style:e.v1,children:[t("div",{className:e.v2,children:[e.v3,e.v4]}),e.v5]}),{name:"Content_1",portals:["v3","v4","v5"]}),xe=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=ve(),{backgroundMode:l=ue.Solid,roundDigits:s=2,value:p,caption:u,valueUnit:m="Unit"}=pe(),h=i.useMemo(()=>({...o,...l===ue.Solid&&{backgroundColor:a}}),[a,l,o]);return t(be,{v0:r(e,n.root),v1:h,v2:r(n.content,{[n.solidBackground]:l===ue.Solid,[n.unsetBackground]:l===ue.Unset,[n.semiBackground]:l===ue.Semi}),v3:t(c,{fontWeight:"bold",children:d(ge(p,s))}),v4:t(c,{children:m}),v5:!!u&&t(fe,{caption:u})})},Ce=s()(e=>({root:{display:"flex",alignItems:"center",whiteSpace:"nowrap",fontWeight:700,fontSize:"18px",paddingLeft:"8px",gap:"8px",overflow:"clip",borderBottom:`1px solid ${e.palette.divider}`},solidBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},semiBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,padding:"10px","& svg":{fill:e.palette.text.primary}}})),ke=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=Ce(),{headerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...(s===ue.Solid||s===ue.Semi)&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},we=s()({root:{overflow:"clip",height:"100%",width:"100%",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},click:{cursor:"pointer"},header:{minHeight:"36px"},content:{flex:1},footer:{minHeight:"32px"}}),Pe=({className:e,style:o})=>{const{classes:a}=we(),{backgroundColor:n,onClick:l,footerLabel:i}=pe();return t(u,{className:r(e,a.root,{[a.click]:!!l}),onClick:l,style:o,children:[t(ke,{backgroundColor:n}),t(xe,{backgroundColor:n,className:a.content}),!!i&&t(he,{backgroundColor:n,className:a.footer})]})},Se=i.memo(({className:e,style:o,...a})=>t(de,{value:a,children:t(Pe,{className:e,style:o})})),Le=(e,{one:t,many:o,two:a=o})=>`${(()=>{if(0===e||e>=11&&e<20)return o;let n=e%10;return 0===n?o:1===n?t:n<5?a:o})()}`,Me=i.createContext(null),Ne=({value:e,children:o})=>t(Me.Provider,{value:e,children:o}),Re=()=>i.useContext(Me),$e=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",paddingLeft:"20px",paddingRight:"20px",overflow:"clip"},container:{flex:1,display:"flex",alignItems:"stretch",justifyContent:"center",gap:"40px"},item:{gap:"4px",display:"flex",alignItems:"center",justifyContent:"center","& > span":{fontWeight:500,fontSize:"12px",color:"var(--black-6)",whiteSpace:"nowrap"}},circle:{borderRadius:"50%",height:"8px",width:"8px"}}),Te=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Footer_1",portals:["v3"]}),De=({className:e,style:o})=>{const{classes:a}=$e(),{items:n}=Re();return t(Te,{v0:r(e,a.root),v1:o,v2:a.container,v3:[...n].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,o)=>t("div",{className:a.item,children:[t("div",{className:a.circle,style:{background:e.color}}),t("span",{children:[e.label," ",e.value?e.value():e.maxValue]})]},o))})},je=s()(()=>({circle:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%","& > div":{borderRadius:"50%"}}})),Be=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{style:e.v2})}),{name:"Circle_1"}),Ie=({className:e,style:o,lineWidth:a,side:n,color:l,rotate:i})=>{const{classes:s}=je();return t(Be,{v0:r(e,s.circle),v1:{...o},v2:{borderTop:`${a}px solid ${l}`,borderLeft:`${a}px solid ${l}`,borderRight:`${a}px solid transparent`,borderBottom:`${a}px solid transparent`,transform:`rotate(${i}deg)`,height:n,width:n}})},Ve=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",background:e.palette.background.paper}})),Ae=({side:e})=>{const{classes:o}=Ve();return t("div",{className:o.dot,style:{height:e,width:e}})},Ee=s()(e=>({line:{position:"absolute",background:e.palette.background.paper,height:"100%",width:"1px",left:"50%",transformOrigin:"center bottom"}})),Oe=({angle:e})=>{const{classes:o}=Ee();return t("div",{className:o.line,style:{transform:`rotate(${e}deg)`}})},ze=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",outline:`100vmax solid ${e.palette.background.paper}`}})),Fe=({side:e})=>{const{classes:o}=ze();return t("div",{className:o.dot,style:{height:e,width:e}})},Ue=s()(e=>({pointer:{position:"absolute",left:"21%",width:"29%",bottom:"0%",zIndex:1,transformOrigin:"right center",fill:e.palette.text.primary}})),We=p(e=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 87 8",className:e.v0,style:e.v1,...e.v2,children:[t("rect",{x:"0.5",y:"2.5",width:"79",height:"3"}),t("circle",{cx:"82.5",cy:"4",r:"4"})]}),{name:"Pointer_1",svg:!0}),He=({className:e,style:o,angle:a,scale:n=1,...l})=>{const{classes:i}=Ue();return t(We,{v0:r(e,i.pointer),v1:{...o,transform:`rotate(${a}deg) scale(${n}) translateX(5px)`},v2:l})},Ge=e=>e*Math.PI/180,Ye=(e,t)=>({left:t*Math.cos(Ge(e))+t,top:t*Math.sin(Ge(e))+t}),_e=s()(e=>({root:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",display:"flex",alignItems:"stretch",justifyContent:"stretch"},container:{flex:1,position:"relative"},label:{position:"absolute",transform:"translate(-50%, -50%)",color:e.palette.text.primary,zIndex:2}})),Ke=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Labels_1",portals:["v3"]}),Xe=({items:e,side:o})=>{const{classes:a}=_e(),n=i.useMemo(()=>Math.floor(o/2),[o]);return t(Ke,{v0:a.root,v1:{height:o,width:o},v2:a.container,v3:e.slice(0,e.length-1).map(({angle:e,value:o},l)=>t("span",{className:a.label,style:{...Ye(e+180,n),...e<90&&{marginLeft:10},...e>90&&{marginLeft:-10},...e>15&&e<165&&{marginTop:5}},children:o},l))})},Je=({width:e,side:o,chunks:a,maxValue:n,minValue:l,value:r})=>{const s=i.useMemo(()=>.5*o,[o]),c=i.useMemo(()=>.63*o,[o]),d=i.useMemo(()=>.58*o,[o]),p=i.useCallback(e=>180/(n-l)*(e.minValue-l)+45,[n,l]),u=i.useMemo(()=>Math.min(r/n*180,180),[n,r]),h=i.useMemo(()=>e>o?c/e*1.5:1,[c,e,o]),g=i.useMemo(()=>[...a].sort(({maxValue:e},{maxValue:t})=>e-t).slice(0,a.length-1).map(e=>({angle:180/n*e.maxValue,value:e.maxValue})),[a,n]),y=i.useMemo(()=>[{angle:0,value:0},...g,{angle:180,value:n}],[g,n]);return t(m,{children:[t(He,{angle:u,scale:h}),[...a].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,a)=>t(Ie,{rotate:p(e),color:e.color,side:o,lineWidth:s},`${e.color}-${a}`)),g.map(({angle:e},o)=>t(Oe,{angle:e-90},`${e}-${o}`)),t(Fe,{side:o}),t(Ae,{side:c}),t(Xe,{items:y,side:d})]})},qe=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",overflow:"clip"},container:{flex:1,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},bottomCenterLabel:{position:"absolute",zIndex:2,bottom:"0",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:"4px","& > *":{fontSize:"20px",lineHeight:"24px"},"& > :first-of-type":{fontWeight:"bold"},"& > :last-of-type":{color:"var(--black-6)"}}}),Ze=({className:e,height:o,width:a})=>{const{classes:n}=qe(),{value:l,items:s}=Re(),c=Math.min(2*o,a),d=i.useMemo(()=>[...s].filter(e=>!e.hidden).sort(({maxValue:e},{maxValue:t})=>t-e).map((e,t,o)=>{const a=o[t+1],n=a?a.maxValue:0;return{...e,minValue:n,value:e.maxValue-n}}),[s]),p=i.useMemo(()=>{const e=d.find(({minValue:e,maxValue:t})=>l>=e&&l<=t);if(e)return e.color;return d.reduce((e,t)=>t.minValue>=e.minValue?t:e).color},[d,l]),u=i.useMemo(()=>d.reduce((e,{minValue:t})=>Math.min(e,t),Number.POSITIVE_INFINITY),[d]),m=i.useMemo(()=>d.reduce((e,{maxValue:t})=>Math.max(e,t),Number.NEGATIVE_INFINITY),[d]);return t("div",{className:r(e,n.root),children:t("div",{className:n.container,children:t(Je,{chunks:d,value:l,minValue:u,maxValue:m,side:c,width:a,color:p})})})},Qe=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",borderLeft:0,borderRight:0,borderWidth:"1px 0",borderStyle:"solid",borderColor:e.palette.divider},container:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row"},content:{display:"flex",alignItems:"baseline",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),et=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:t("div",{className:e.v3,children:[e.v4,e.v5]})})}),{name:"Note_1",portals:["v4","v5"]}),tt=({className:e,style:o})=>{const{classes:a}=Qe(),{value:n,roundDigits:l=3,valueUnit:i="Unit"}=Re();return t(et,{v0:r(e,a.root),v1:o,v2:a.container,v3:a.content,v4:t(c,{children:ge(n,l)}),v5:t(c,{children:i})})},ot=s()(e=>({root:{position:"relative",overflow:"clip",height:"100%",width:"100%",background:e.palette.background.paper},container:{position:"absolute",top:"0",left:"0"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},chart:{flex:1,paddingTop:"6px",paddingBottom:"6px"},footer:{minHeight:"32px"},note:{minHeight:"60px"}})),at=({className:e,style:o})=>{const{classes:a}=ot(),n=e=>{let t=e;return t-=32,t-=12,t-=60,t},l=e=>{let t=e;return t-=12,t};return t(u,{className:r(e,a.root),style:o,children:t(h,{className:a.container,children:({height:e=0,width:o=0})=>t("div",{className:a.content,style:{height:e,width:o},children:[t(Ze,{className:a.chart,height:n(e),width:l(o)}),t(tt,{className:a.note}),t(De,{className:a.footer})]})})})},nt=i.memo(({className:e,style:o,...a})=>t(Ne,{value:a,children:t(at,{className:e,style:o})})),lt=s()({root:{position:"relative",height:10,flex:1},bar:{position:"absolute !important",top:"42%",left:0,right:10}}),it=e=>{const{classes:o}=lt(),a=["done","inprogress","waiting","archive"],n=t=>{var o;return null==(o=e.data[t])?void 0:o.value},l=a.map(t=>{const o=n(t);var a,l;return`${a=t,(null==(l=e.data[a])?void 0:l.title)||t} - ${o}`}).join(" | "),i=a.map(t=>{const o=(t=>{var o;return null==(o=e.data[t])?void 0:o.color})(t);return{color:o,value:n(t),key:t}}).map(({color:e,value:t,key:o},l)=>{let i=0;if(0!==l)for(let r=l-1;r>=0;r--)i+=n(a[r]);return{value:t>0?t+i:t,key:o,color:e}}).sort(({value:e},{value:t})=>t-e),r=Math.max(...i.map(({value:e})=>e));return t(y,{title:l,arrow:!0,children:t("div",{className:o.root,children:i.map(({color:e,value:a,key:n},l)=>{const i=((e,t=100)=>Math.min(100,Math.round(Math.max(Number(e),0)/t*100)))(a,r);return t(g,{sx:{height:"10px !important",zIndex:`${l+1} !important`,backgroundColor:"transparent !important","& .MuiLinearProgress-bar":{borderTopRightRadius:5,borderBottomRightRadius:5,backgroundColor:`${e} !important`}},variant:"determinate",className:o.bar,value:i},`${l}-${n}`)})})})},rt=s()({root:{display:"flex"},work:{display:"flex",alignItems:"center"},row:{flex:1,paddingLeft:5,paddingRight:5,paddingBottom:15}}),st=({title:e,description:o,avatar:a,done:n,inprogress:l,waiting:i,archive:r})=>{const{classes:s}=rt();return t(f,{className:s.root,children:t(f,{className:s.row,children:[t(f,{className:s.work,children:[t(a,{}),t(v,{primary:e,secondary:o,sx:{flex:"none",marginLeft:"0.5em"}})]}),t(f,{flex:"1",children:t(it,{data:{done:{color:"#7FB537",title:"Take profit",value:n},inprogress:{color:"#4FC0E8",title:"Resolved",value:l},waiting:{color:"#FE9B31",title:"Rejected",value:i},archive:{color:"#FA5F5A",title:"Stop loss",value:r}}})})]})})},ct=s()({root:{position:"relative",width:"100%"},container:{position:"absolute",top:0,height:"100%",width:"100%",overflowY:"auto",overflowX:"hidden"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"}}),dt=({items:e,sx:o})=>{const{classes:a}=ct();return t(u,{className:a.root,sx:o,children:[t(b,{disableRight:!0,color:"#fff",className:a.container,children:t("div",{className:a.content,children:e.map((e,o)=>t(st,{...e},o))})}),t(f,{sx:{position:"absolute",bottom:10,right:10,zIndex:10,pointerEvents:"auto",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(10px)",borderRadius:"12px",border:"1px solid rgba(255, 255, 255, 0.2)",padding:"12px 16px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.1)",opacity:.35,transition:"opacity 0.3s ease","&:hover":{opacity:1}},children:[t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#7FB537",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Take profit"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#4FC0E8",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Resolved"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FE9B31",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Rejected"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FA5F5A",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Stop loss"})]})]})]})},pt=s()({root:{position:"relative"},tooltip:{position:"absolute",color:"gray",margin:0,left:5,top:5}}),ut={layout:{textColor:"#d1d4dc",backgroundColor:"#0000"},rightPriceScale:{scaleMargins:{top:.3,bottom:.25}},crosshair:{vertLine:{width:4,color:"#ebe0e301",style:0},horzLine:{visible:!1,labelVisible:!1}},grid:{vertLines:{color:"#f8b3"},horzLines:{color:"#f8b3"}},handleScroll:{vertTouchDrag:!1}},mt={color:"#90cbfa",lineWidth:2,crosshairMarkerVisible:!1,lastValueVisible:!1,priceLineVisible:!1},ht=({height:e,width:o,items:a})=>{const{classes:n}=pt(),l=i.useRef(void 0),r=i.useRef(void 0);return i.useLayoutEffect(()=>{const{current:t}=l,{current:n}=r,i=x(t,{...ut,height:e,width:o});i.addLineSeries({...mt}).setData(a);const s=({time:e})=>{if(e)try{const{day:t,month:o,year:l}=e,i=a.find(({time:e})=>e.day===t&&e.month===o&&e.year===l);if(i){const e=Math.round(Math.round(100*i.value)/100);n.innerHTML=`${C("Total")}: ${e}, ${C("Resolved")}: ${i.resolved}, ${C("Rejected")}: ${i.rejected}`}else n.innerHTML=""}catch(t){console.log(t),n.innerHTML=""}else n.innerHTML=""};return i.timeScale().fitContent(),i.subscribeCrosshairMove(s),()=>{i.unsubscribeCrosshairMove(s),i.remove()}},[e,o,a]),t("div",{ref:l,className:n.root,children:t("p",{ref:r,className:n.tooltip})})},gt=({items:e})=>t(h,{children:({height:o,width:a})=>t(ht,{height:o,width:a,items:e})}),yt=s()({root:{},container:{position:"relative",margin:0,padding:0,overflow:"clip"},editor:{position:"absolute",top:0,left:0,right:0,bottom:0}}),ft=({items:e,sx:o})=>{const{classes:a}=yt(),n=i.useMemo(()=>[...e].sort(({stamp:e},{stamp:t})=>e-t).map(({count:e,rejected:t,resolved:o,stamp:a})=>{const n=k(a);return{time:{year:n.get("year"),month:n.get("month")+1,day:n.get("date")},rejected:t,resolved:o,value:e}}),[e]);return t(u,{className:a.container,sx:o,children:t("div",{className:a.editor,children:t(gt,{items:n})})})},vt=e=>P({handler:async(t,a)=>{const n=S(t,a);for await(const l of(e=>w(async()=>{const t="live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),a=t.filter(e=>"closed"===e.status).map(e=>({id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:e.pnl.pnlPercentage,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"finished"}));return"backtest"===e?a:[...t.filter(e=>"opened"===e.status).map(e=>({id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:e.pnl.pnlPercentage,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"pending"})),...a]}))(e))if(n([l]).done)break;return n([]).rows}}),bt=[{field:"color",label:B.nbsp,minWidth:45,width:()=>45,format:({symbol:e})=>t(A,{children:async()=>{var a;try{const n=await o.symbolGlobalService.getSymbolMap();return t(te,{sx:{color:(null==(a=n[e])?void 0:a.color)||"#ccc"}})}catch(n){return t(te,{sx:{color:"#ccc"}})}}})},{field:"symbol",label:"Symbol",minWidth:115,width:e=>Math.max(e-45-90-145-80-90-80,45),format:({symbol:e})=>e},{field:"position",label:"Position",minWidth:90,width:()=>90,format:({position:e})=>{const o="long"===e;return t("span",{style:{color:o?"#1976D2":"#F57C00",padding:"4px 8px",borderRadius:"4px",fontWeight:"bold",fontSize:"11px"},children:o?"🔵 LONG":"🟠 SHORT"})}},{field:"buyPrice",label:"Entry",minWidth:145,width:()=>145,format:({buyPrice:e})=>`${d(e)}$`},{field:"pnlEntries",label:"Invested",minWidth:80,width:()=>80,format:({pnlEntries:e})=>`${d(e)}$`},{field:"profitLossPercentage",label:"PNL %",minWidth:90,width:()=>90,format:({profitLossPercentage:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",e.toFixed(2),"%"]})}},{field:"pnlCost",label:"PNL $",minWidth:80,width:()=>80,format:({pnlCost:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",d(e),"$"]})}}],xt=[{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"position",title:"Position",readonly:!0,compute:e=>"long"===e.position?"🔵 LONG (profit on rise)":"🟠 SHORT (profit on fall)"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"date",title:"Date",readonly:!0,compute:e=>e.date?n(e.date).format("DD/MM/YYYY HH:mm"):""},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"buyPrice",title:"Entry",readonly:!0,compute:e=>e.buyPrice?`${d(e.buyPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalBuyPrice",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalBuyPrice&&e.originalBuyPrice!==e.buyPrice,compute:e=>e.originalBuyPrice?`${d(e.originalBuyPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"takeProfitPrice",title:"Take Profit",readonly:!0,compute:e=>e.takeProfitPrice?`${d(e.takeProfitPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalTakeProfitPrice",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalTakeProfitPrice&&e.originalTakeProfitPrice!==e.takeProfitPrice,compute:e=>e.originalTakeProfitPrice?`${d(e.originalTakeProfitPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"stopLossPrice",title:"Stop Loss",readonly:!0,compute:e=>e.stopLossPrice?`${d(e.stopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalStopLossPrice",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalStopLossPrice&&e.originalStopLossPrice!==e.stopLossPrice,compute:e=>e.originalStopLossPrice?`${d(e.originalStopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlEntries",title:"Invested",readonly:!0,compute:e=>`${d(e.pnlEntries)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"profitLossPercentage",title:"PNL %",readonly:!0,trailingIcon:({data:e})=>e.profitLossPercentage<0?t(Z,{sx:{color:"red"}}):t(Q,{sx:{color:"green"}}),compute:e=>`${e.profitLossPercentage>=0?"+":""}${e.profitLossPercentage.toFixed(2)}%`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlCost",title:"PNL $",readonly:!0,compute:e=>`${e.pnlCost>=0?"+":""}${d(e.pnlCost)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:N.Component,sx:{mt:2},element:({payload:e})=>t(I,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Ct=[{label:"Details",icon:()=>t(V,{icon:ee,color:"#4caf50"}),action:"open-action"}],kt=({sx:e,mode:a})=>{const n=vt(a),[l,i]=L(null),{pickData:r,setOpen:s,render:c}=M({title:"Info",AfterTitle:({onClose:e})=>t(D,{direction:"row",gap:2,children:[t(R,{onClick:()=>o.layoutService.pickSignal(l.current.id),variant:"outlined",children:"Show Details"}),t($,{size:"small",onClick:e,children:t(T,{})})]}),payload:()=>({handleClose(){s(!1)}}),fields:xt,handler:()=>l.current,withActionButton:!1});return t(m,{children:[t(u,{sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",background:"whitesmote",overflow:"clip",...e},children:t(j,{sx:{flex:1,background:"transparent !important"},rowColor:({status:e})=>"pending"===e?"#ffc40085":"transparent",hasMore:n.hasMore,loading:n.loading,onSkip:n.onSkip,data:n.data,columns:bt,rowActions:Ct,onRowClick:e=>{i(e),r(e.id)},onRowAction:(e,t)=>{"open-action"===e&&o.layoutService.pickSignal(t.id)}})}),c()]})},wt=[{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.thirtyOneDaysRevenue)||0,a=(null==e?void 0:e.thirtyOneDaysCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"31 days",footerLabel:"Profit for 31 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.sevenDaysRevenue)||0,a=(null==e?void 0:e.sevenDaysCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"7 days",footerLabel:"Profit for 7 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.yesterdayRevenue)||0,a=(null==e?void 0:e.yesterdayCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Yesterday",footerLabel:"Yesterday's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.todayRevenue)||0,a=(null==e?void 0:e.todayCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Today",footerLabel:"Today's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({tradePerfomance:e})=>{const o=[{color:"#DD4049",label:"Failed",maxValue:Math.max(e.rejectedCount+1,1),value:()=>e.rejectedCount},{color:"#2EA96F",label:"Successful",maxValue:Math.max(e.rejectedCount+e.resolvedCount+2,2),value:()=>e.resolvedCount},{color:"#F3A43A",label:"Total",hidden:!0,maxValue:Math.max(e.total+3,3),value:()=>e.total}];return t(nt,{style:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o,valueUnit:Le(Math.abs(e.resolvedCount),{one:"Successful signal",many:"Successful signals"}),value:e.resolvedCount})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({dailyTrades:e})=>t(ft,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:e})},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({successRate:e})=>{const o=e.map(({symbol:e,displayName:o,rejectedCloseCount:a,rejectedStopLossCount:n,resolvedCloseCount:l,resolvedTakeProfitCount:i})=>({title:o||e,description:e,avatar:()=>t(K,{symbol:e}),done:i,archive:n,waiting:a,inprogress:l})).filter(({done:e,archive:t,waiting:o,inprogress:a})=>{let n=!1;return n=n||!!e,n=n||!!t,n=n||!!o,n=n||!!a,n});return t(dt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:e})=>t(kt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},mode:e.mode})}],Pt={rejectedCount:0,resolvedCount:0,total:0},St=[{action:"download-action",label:"Download",icon:()=>t(V,{icon:H,color:"#4caf50"})},{divider:!0},{action:"live-action",label:"Switch to LIVE",isVisible:e=>"backtest"===e,icon:()=>t(V,{icon:G,color:"#4caf50"})},{action:"backtest-action",label:"Switch to BACKTEST",isVisible:e=>"live"===e,icon:()=>t(V,{icon:Y,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>t(V,{icon:J,color:"#4caf50"})}],Lt=[{type:W.Link,action:"back-action",label:t(q,{sx:{display:"block"}})},{type:W.Link,action:"back-action",label:"Main"},{type:W.Link,action:"back-action",label:"Dashboard"},{type:W.Link,action:"back-action",compute:e=>`KPI ${String(e).toUpperCase()}`}],Mt=new F,Nt=({mode:e="backtest"})=>{const[a,{loading:n,execute:l}]=E(async()=>{const t=await o.symbolGlobalService.getSymbolList(),a=await o.symbolGlobalService.getSymbolMap(),n=new Map,l=[],i={...Pt};let r={symbol:"TOTAL",todayRevenue:0,yesterdayRevenue:0,sevenDaysRevenue:0,thirtyOneDaysRevenue:0,todayCount:0,yesterdayCount:0,sevenDaysCount:0,thirtyOneDaysCount:0};await Promise.all(t.map(async t=>{var o;const[s=[],c,d,p]=await Promise.all([ie(t,e),le(t,e),ne(t,e),re(t,e)]);for(const e of s){const t=n.get(e.stamp)||{count:0,resolved:0,rejected:0};n.set(e.stamp,{count:t.count+e.count,resolved:t.resolved+e.resolved,rejected:t.rejected+e.rejected})}l.push({...c,symbol:t,displayName:(null==(o=a[t])?void 0:o.displayName)||t}),i.rejectedCount+=d.rejectedCount,i.resolvedCount+=d.resolvedCount,i.total+=d.total,r.todayRevenue+=p.todayRevenue,r.yesterdayRevenue+=p.yesterdayRevenue,r.sevenDaysRevenue+=p.sevenDaysRevenue,r.thirtyOneDaysRevenue+=p.thirtyOneDaysRevenue,r.todayCount+=p.todayCount,r.yesterdayCount+=p.yesterdayCount,r.sevenDaysCount+=p.sevenDaysCount,r.thirtyOneDaysCount+=p.thirtyOneDaysCount}));return{dailyTrades:Array.from(n).map(([e,{count:t,resolved:o,rejected:a}])=>({stamp:e,count:t,resolved:o,rejected:a})),successRate:l,tradePerfomance:i,revenueCount:r}},{onLoadStart:()=>o.layoutService.setModalLoader(!0),onLoadEnd:()=>o.layoutService.setModalLoader(!1),deps:[e]}),{execute:i}=O(async()=>{const t=await oe(e),a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(a);o.layoutService.downloadFile(n,`signals_${e}_${Date.now()}.json`)},{onLoadStart:()=>o.layoutService.setAppbarLoader(!0),onLoadEnd:()=>o.layoutService.setAppbarLoader(!1)});z(()=>Mt.subscribe(l));return t(X,{children:[t(U,{items:Lt,actions:St,payload:e,onAction:async e=>{"download-action"===e&&await i(),"update-now"===e&&(oe.clear(),await Mt.next()),"live-action"===e&&o.routerService.push("/dashboard/live"),"backtest-action"===e&&o.routerService.push("/dashboard/backtest"),"back-action"===e&&o.routerService.push("/")}}),a?n?null:t(_,{handler:a,payload:()=>({handleUpdate(){Mt.next()},mode:e}),fields:wt}):null]})};export{Nt as DashboardPage,Nt as default};
1
+ import{b as e,f as t,i as o,ak as a,al as n,am as l,r as i,an as r,p as s,T as c,ag as d,c as p,P as u,F as m,ao as h,ap as g,aq as y,B as f,ab as v,ar as b,as as x,a0 as C,at as k,au as w,av as P,aw as S,ax as L,ay as M,H as N,a4 as R,I as $,az as T,N as D,aA as j,L as B,O as I,z as V,J as A,X as E,aB as O,Y as z,Z as F,v as U,w as W,D as H,aC as G,aD as Y,x as _}from"./index-is6UARFt.js";import{I as K}from"./IconPhoto-2KIaDXXx.js";import{C as X,R as J}from"./Refresh-6IBmzTpL.js";import{K as q}from"./KeyboardArrowLeft-nUGbVivG.js";const Z=e(t("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 10V8h-2v4H8l4 4 4-4h-3z"}),"ArrowCircleDown"),Q=e(t("path",{d:"M12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0 2c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10zm-1-10v4h2v-4h3l-4-4-4 4h3z"}),"ArrowCircleUp"),ee=e(t("path",{d:"M7.5 5.6 10 7 8.6 4.5 10 2 7.5 3.4 5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.9959.9959 0 0 0-1.41 0L1.29 18.96c-.39.39-.39 1.02 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05c.39-.39.39-1.02 0-1.41l-2.33-2.35zm-1.03 5.49-2.12-2.12 2.44-2.44 2.12 2.12-2.44 2.44z"}),"AutoFixHigh"),te=e(t("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2z"}),"Circle"),oe=l(async e=>"live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),{key:([e])=>`${e}`,timeout:45e3}),ae=async(e,t)=>(await oe(t)).filter(t=>"closed"===t.status&&t.symbol===e),ne=async(e,t)=>{const o=await ae(e,t);return{total:o.length,resolvedCount:o.filter(e=>e.pnl.pnlPercentage>0).length,rejectedCount:o.filter(e=>e.pnl.pnlPercentage<=0).length}},le=async(e,t)=>{const o=await ae(e,t),a=e=>Math.abs(e.pnl.priceClose-e.priceTakeProfit)/e.priceTakeProfit<.005,n=e=>Math.abs(e.pnl.priceClose-e.priceStopLoss)/e.priceStopLoss<.005;return{resolvedTakeProfitCount:o.filter(e=>e.pnl.pnlPercentage>0&&a(e)).length,rejectedStopLossCount:o.filter(e=>e.pnl.pnlPercentage<=0&&n(e)).length,resolvedCloseCount:o.filter(e=>e.pnl.pnlPercentage>0&&!a(e)).length,rejectedCloseCount:o.filter(e=>e.pnl.pnlPercentage<=0&&!n(e)).length}},ie=async(e,t)=>{const o=await ae(e,t),l=new Map;for(const i of o){const e=a(n(i.updatedAt)),t=l.get(e)??{resolved:0,rejected:0};i.pnl.pnlPercentage>0?l.set(e,{...t,resolved:t.resolved+1}):l.set(e,{...t,rejected:t.rejected+1})}return Array.from(l.entries()).map(([e,{resolved:t,rejected:o}])=>({stamp:e,count:t+o,resolved:t,rejected:o}))},re=async(e,t)=>{const o=await ae(e,t),a="backtest"===t&&o.length?o.reduce((e,t)=>Math.max(e,t.updatedAt),0):Date.now(),l=n(a).startOf("day").valueOf(),i=l-864e5,r=l-6048e5,s=l-26784e5,c=e=>e.reduce((e,t)=>e+t.pnl.pnlCost,0),d=o.filter(e=>e.updatedAt>=l),p=o.filter(e=>e.updatedAt>=i&&e.updatedAt<l),u=o.filter(e=>e.updatedAt>=r),m=o.filter(e=>e.updatedAt>=s);return{symbol:e,todayRevenue:c(d),yesterdayRevenue:c(p),sevenDaysRevenue:c(u),thirtyOneDaysRevenue:c(m),todayCount:d.length,yesterdayCount:p.length,sevenDaysCount:u.length,thirtyOneDaysCount:m.length}};var se=(e=>(e.Red="#DD4049",e.Orange="#F3A43A",e.Green="#2EA96F",e.Blue="#2979ff",e.Violet="#d500f9",e))(se||{});const ce=i.createContext(null),de=({value:e,children:o})=>t(ce.Provider,{value:e,children:o}),pe=()=>i.useContext(ce);var ue=(e=>(e.Semi="semi",e.Solid="solid",e.Unset="unset",e))(ue||{});const me=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"stretch",whiteSpace:"nowrap",gap:"8px",overflow:"clip",padding:"10px",borderTop:`1px solid ${e.palette.divider}`,"& > *":{flex:1}},solidBackground:{color:"#fff","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}},semiBackground:{color:e.palette.text.primary,"& svg":{fill:e.palette.text.primary}}})),he=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=me(),{footerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...s===ue.Solid&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},ge=(e,t=2)=>{let o=1;for(let a=0;a<t;a++)o*=10;return Math.round(e*o)/o},ye=s()({root:{position:"relative",width:"100%",height:"0px"},container:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center"}}),fe=({caption:e})=>{const{classes:o}=ye();return t("div",{className:o.root,children:t("div",{className:o.container,children:t(c,{variant:"caption",sx:{opacity:.5,fontSize:12,textAlign:"center",padding:"0 8px"},children:e})})})},ve=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},solidBackground:{"& > :first-of-type":{color:"#fff",fontWeight:"bold"},"& > :last-of-type":{color:"#fff"}},unsetBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},semiBackground:{"& > :first-of-type":{color:e.palette.text.primary,fontWeight:"bold"},"& > :last-of-type":{color:e.palette.text.primary}},content:{display:"flex",alignItems:"baseline",flexDirection:"row",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),be=p(e=>t("div",{className:e.v0,style:e.v1,children:[t("div",{className:e.v2,children:[e.v3,e.v4]}),e.v5]}),{name:"Content_1",portals:["v3","v4","v5"]}),xe=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=ve(),{backgroundMode:l=ue.Solid,roundDigits:s=2,value:p,caption:u,valueUnit:m="Unit"}=pe(),h=i.useMemo(()=>({...o,...l===ue.Solid&&{backgroundColor:a}}),[a,l,o]);return t(be,{v0:r(e,n.root),v1:h,v2:r(n.content,{[n.solidBackground]:l===ue.Solid,[n.unsetBackground]:l===ue.Unset,[n.semiBackground]:l===ue.Semi}),v3:t(c,{fontWeight:"bold",children:d(ge(p,s))}),v4:t(c,{children:m}),v5:!!u&&t(fe,{caption:u})})},Ce=s()(e=>({root:{display:"flex",alignItems:"center",whiteSpace:"nowrap",fontWeight:700,fontSize:"18px",paddingLeft:"8px",gap:"8px",overflow:"clip",borderBottom:`1px solid ${e.palette.divider}`},solidBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},semiBackground:{color:"#fff",padding:"10px","& svg":{fill:"#fff"}},unsetBackground:{color:e.palette.text.primary,padding:"10px","& svg":{fill:e.palette.text.primary}}})),ke=({className:e,style:o,backgroundColor:a})=>{const{classes:n}=Ce(),{headerLabel:l,backgroundMode:s=ue.Solid}=pe(),c=i.useMemo(()=>({...o,...(s===ue.Solid||s===ue.Semi)&&{backgroundColor:a}}),[a,s,o]);return t("div",{className:r(e,n.root,{[n.solidBackground]:s===ue.Solid,[n.unsetBackground]:s===ue.Unset,[n.semiBackground]:s===ue.Semi}),style:c,children:l})},we=s()({root:{overflow:"clip",height:"100%",width:"100%",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},click:{cursor:"pointer"},header:{minHeight:"36px"},content:{flex:1},footer:{minHeight:"32px"}}),Pe=({className:e,style:o})=>{const{classes:a}=we(),{backgroundColor:n,onClick:l,footerLabel:i}=pe();return t(u,{className:r(e,a.root,{[a.click]:!!l}),onClick:l,style:o,children:[t(ke,{backgroundColor:n}),t(xe,{backgroundColor:n,className:a.content}),!!i&&t(he,{backgroundColor:n,className:a.footer})]})},Se=i.memo(({className:e,style:o,...a})=>t(de,{value:a,children:t(Pe,{className:e,style:o})})),Le=(e,{one:t,many:o,two:a=o})=>`${(()=>{if(0===e||e>=11&&e<20)return o;let n=e%10;return 0===n?o:1===n?t:n<5?a:o})()}`,Me=i.createContext(null),Ne=({value:e,children:o})=>t(Me.Provider,{value:e,children:o}),Re=()=>i.useContext(Me),$e=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",paddingLeft:"20px",paddingRight:"20px",overflow:"clip"},container:{flex:1,display:"flex",alignItems:"stretch",justifyContent:"center",gap:"40px"},item:{gap:"4px",display:"flex",alignItems:"center",justifyContent:"center","& > span":{fontWeight:500,fontSize:"12px",color:"var(--black-6)",whiteSpace:"nowrap"}},circle:{borderRadius:"50%",height:"8px",width:"8px"}}),Te=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Footer_1",portals:["v3"]}),De=({className:e,style:o})=>{const{classes:a}=$e(),{items:n}=Re();return t(Te,{v0:r(e,a.root),v1:o,v2:a.container,v3:[...n].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,o)=>t("div",{className:a.item,children:[t("div",{className:a.circle,style:{background:e.color}}),t("span",{children:[e.label," ",e.value?e.value():e.maxValue]})]},o))})},je=s()(()=>({circle:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%","& > div":{borderRadius:"50%"}}})),Be=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{style:e.v2})}),{name:"Circle_1"}),Ie=({className:e,style:o,lineWidth:a,side:n,color:l,rotate:i})=>{const{classes:s}=je();return t(Be,{v0:r(e,s.circle),v1:{...o},v2:{borderTop:`${a}px solid ${l}`,borderLeft:`${a}px solid ${l}`,borderRight:`${a}px solid transparent`,borderBottom:`${a}px solid transparent`,transform:`rotate(${i}deg)`,height:n,width:n}})},Ve=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",background:e.palette.background.paper}})),Ae=({side:e})=>{const{classes:o}=Ve();return t("div",{className:o.dot,style:{height:e,width:e}})},Ee=s()(e=>({line:{position:"absolute",background:e.palette.background.paper,height:"100%",width:"1px",left:"50%",transformOrigin:"center bottom"}})),Oe=({angle:e})=>{const{classes:o}=Ee();return t("div",{className:o.line,style:{transform:`rotate(${e}deg)`}})},ze=s()(e=>({dot:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",borderRadius:"50%",outline:`100vmax solid ${e.palette.background.paper}`}})),Fe=({side:e})=>{const{classes:o}=ze();return t("div",{className:o.dot,style:{height:e,width:e}})},Ue=s()(e=>({pointer:{position:"absolute",left:"21%",width:"29%",bottom:"0%",zIndex:1,transformOrigin:"right center",fill:e.palette.text.primary}})),We=p(e=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 87 8",className:e.v0,style:e.v1,...e.v2,children:[t("rect",{x:"0.5",y:"2.5",width:"79",height:"3"}),t("circle",{cx:"82.5",cy:"4",r:"4"})]}),{name:"Pointer_1",svg:!0}),He=({className:e,style:o,angle:a,scale:n=1,...l})=>{const{classes:i}=Ue();return t(We,{v0:r(e,i.pointer),v1:{...o,transform:`rotate(${a}deg) scale(${n}) translateX(5px)`},v2:l})},Ge=e=>e*Math.PI/180,Ye=(e,t)=>({left:t*Math.cos(Ge(e))+t,top:t*Math.sin(Ge(e))+t}),_e=s()(e=>({root:{position:"absolute",transform:"translate(-50%, 50%)",bottom:"0",left:"50%",display:"flex",alignItems:"stretch",justifyContent:"stretch"},container:{flex:1,position:"relative"},label:{position:"absolute",transform:"translate(-50%, -50%)",color:e.palette.text.primary,zIndex:2}})),Ke=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:e.v3})}),{name:"Labels_1",portals:["v3"]}),Xe=({items:e,side:o})=>{const{classes:a}=_e(),n=i.useMemo(()=>Math.floor(o/2),[o]);return t(Ke,{v0:a.root,v1:{height:o,width:o},v2:a.container,v3:e.slice(0,e.length-1).map(({angle:e,value:o},l)=>t("span",{className:a.label,style:{...Ye(e+180,n),...e<90&&{marginLeft:10},...e>90&&{marginLeft:-10},...e>15&&e<165&&{marginTop:5}},children:o},l))})},Je=({width:e,side:o,chunks:a,maxValue:n,minValue:l,value:r})=>{const s=i.useMemo(()=>.5*o,[o]),c=i.useMemo(()=>.63*o,[o]),d=i.useMemo(()=>.58*o,[o]),p=i.useCallback(e=>180/(n-l)*(e.minValue-l)+45,[n,l]),u=i.useMemo(()=>Math.min(r/n*180,180),[n,r]),h=i.useMemo(()=>e>o?c/e*1.5:1,[c,e,o]),g=i.useMemo(()=>[...a].sort(({maxValue:e},{maxValue:t})=>e-t).slice(0,a.length-1).map(e=>({angle:180/n*e.maxValue,value:e.maxValue})),[a,n]),y=i.useMemo(()=>[{angle:0,value:0},...g,{angle:180,value:n}],[g,n]);return t(m,{children:[t(He,{angle:u,scale:h}),[...a].sort(({maxValue:e},{maxValue:t})=>e-t).map((e,a)=>t(Ie,{rotate:p(e),color:e.color,side:o,lineWidth:s},`${e.color}-${a}`)),g.map(({angle:e},o)=>t(Oe,{angle:e-90},`${e}-${o}`)),t(Fe,{side:o}),t(Ae,{side:c}),t(Xe,{items:y,side:d})]})},qe=s()({root:{display:"flex",alignItems:"stretch",justifyContent:"stretch",overflow:"clip"},container:{flex:1,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},bottomCenterLabel:{position:"absolute",zIndex:2,bottom:"0",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row",gap:"4px","& > *":{fontSize:"20px",lineHeight:"24px"},"& > :first-of-type":{fontWeight:"bold"},"& > :last-of-type":{color:"var(--black-6)"}}}),Ze=({className:e,height:o,width:a})=>{const{classes:n}=qe(),{value:l,items:s}=Re(),c=Math.min(2*o,a),d=i.useMemo(()=>[...s].filter(e=>!e.hidden).sort(({maxValue:e},{maxValue:t})=>t-e).map((e,t,o)=>{const a=o[t+1],n=a?a.maxValue:0;return{...e,minValue:n,value:e.maxValue-n}}),[s]),p=i.useMemo(()=>{const e=d.find(({minValue:e,maxValue:t})=>l>=e&&l<=t);if(e)return e.color;return d.reduce((e,t)=>t.minValue>=e.minValue?t:e).color},[d,l]),u=i.useMemo(()=>d.reduce((e,{minValue:t})=>Math.min(e,t),Number.POSITIVE_INFINITY),[d]),m=i.useMemo(()=>d.reduce((e,{maxValue:t})=>Math.max(e,t),Number.NEGATIVE_INFINITY),[d]);return t("div",{className:r(e,n.root),children:t("div",{className:n.container,children:t(Je,{chunks:d,value:l,minValue:u,maxValue:m,side:c,width:a,color:p})})})},Qe=s()(e=>({root:{display:"flex",alignItems:"center",justifyContent:"center",borderLeft:0,borderRight:0,borderWidth:"1px 0",borderStyle:"solid",borderColor:e.palette.divider},container:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"row"},content:{display:"flex",alignItems:"baseline",gap:"2.5px","& > *":{fontWeight:"bold"},"& > :first-of-type":{fontSize:"22px"},"& > :last-of-type":{fontSize:"16px",opacity:.85}}})),et=p(e=>t("div",{className:e.v0,style:e.v1,children:t("div",{className:e.v2,children:t("div",{className:e.v3,children:[e.v4,e.v5]})})}),{name:"Note_1",portals:["v4","v5"]}),tt=({className:e,style:o})=>{const{classes:a}=Qe(),{value:n,roundDigits:l=3,valueUnit:i="Unit"}=Re();return t(et,{v0:r(e,a.root),v1:o,v2:a.container,v3:a.content,v4:t(c,{children:ge(n,l)}),v5:t(c,{children:i})})},ot=s()(e=>({root:{position:"relative",overflow:"clip",height:"100%",width:"100%",background:e.palette.background.paper},container:{position:"absolute",top:"0",left:"0"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"},chart:{flex:1,paddingTop:"6px",paddingBottom:"6px"},footer:{minHeight:"32px"},note:{minHeight:"60px"}})),at=({className:e,style:o})=>{const{classes:a}=ot(),n=e=>{let t=e;return t-=32,t-=12,t-=60,t},l=e=>{let t=e;return t-=12,t};return t(u,{className:r(e,a.root),style:o,children:t(h,{className:a.container,children:({height:e=0,width:o=0})=>t("div",{className:a.content,style:{height:e,width:o},children:[t(Ze,{className:a.chart,height:n(e),width:l(o)}),t(tt,{className:a.note}),t(De,{className:a.footer})]})})})},nt=i.memo(({className:e,style:o,...a})=>t(Ne,{value:a,children:t(at,{className:e,style:o})})),lt=s()({root:{position:"relative",height:10,flex:1},bar:{position:"absolute !important",top:"42%",left:0,right:10}}),it=e=>{const{classes:o}=lt(),a=["done","inprogress","waiting","archive"],n=t=>{var o;return null==(o=e.data[t])?void 0:o.value},l=a.map(t=>{const o=n(t);var a,l;return`${a=t,(null==(l=e.data[a])?void 0:l.title)||t} - ${o}`}).join(" | "),i=a.map(t=>{const o=(t=>{var o;return null==(o=e.data[t])?void 0:o.color})(t);return{color:o,value:n(t),key:t}}).map(({color:e,value:t,key:o},l)=>{let i=0;if(0!==l)for(let r=l-1;r>=0;r--)i+=n(a[r]);return{value:t>0?t+i:t,key:o,color:e}}).sort(({value:e},{value:t})=>t-e),r=Math.max(...i.map(({value:e})=>e));return t(y,{title:l,arrow:!0,children:t("div",{className:o.root,children:i.map(({color:e,value:a,key:n},l)=>{const i=((e,t=100)=>Math.min(100,Math.round(Math.max(Number(e),0)/t*100)))(a,r);return t(g,{sx:{height:"10px !important",zIndex:`${l+1} !important`,backgroundColor:"transparent !important","& .MuiLinearProgress-bar":{borderTopRightRadius:5,borderBottomRightRadius:5,backgroundColor:`${e} !important`}},variant:"determinate",className:o.bar,value:i},`${l}-${n}`)})})})},rt=s()({root:{display:"flex"},work:{display:"flex",alignItems:"center"},row:{flex:1,paddingLeft:5,paddingRight:5,paddingBottom:15}}),st=({title:e,description:o,avatar:a,done:n,inprogress:l,waiting:i,archive:r})=>{const{classes:s}=rt();return t(f,{className:s.root,children:t(f,{className:s.row,children:[t(f,{className:s.work,children:[t(a,{}),t(v,{primary:e,secondary:o,sx:{flex:"none",marginLeft:"0.5em"}})]}),t(f,{flex:"1",children:t(it,{data:{done:{color:"#7FB537",title:"Take profit",value:n},inprogress:{color:"#4FC0E8",title:"Resolved",value:l},waiting:{color:"#FE9B31",title:"Rejected",value:i},archive:{color:"#FA5F5A",title:"Stop loss",value:r}}})})]})})},ct=s()({root:{position:"relative",width:"100%"},container:{position:"absolute",top:0,height:"100%",width:"100%",overflowY:"auto",overflowX:"hidden"},content:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column"}}),dt=({items:e,sx:o})=>{const{classes:a}=ct();return t(u,{className:a.root,sx:o,children:[t(b,{disableRight:!0,color:"#fff",className:a.container,children:t("div",{className:a.content,children:e.map((e,o)=>t(st,{...e},o))})}),t(f,{sx:{position:"absolute",bottom:10,right:10,zIndex:10,pointerEvents:"auto",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(10px)",borderRadius:"12px",border:"1px solid rgba(255, 255, 255, 0.2)",padding:"12px 16px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.1)",opacity:.35,transition:"opacity 0.3s ease","&:hover":{opacity:1}},children:[t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#7FB537",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Take profit"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#4FC0E8",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Resolved"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FE9B31",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Rejected"})]}),t(f,{sx:{display:"flex",alignItems:"center"},children:[t("div",{style:{background:"#FA5F5A",width:15,height:15,borderRadius:"3px",marginRight:"5px"}}),t("span",{children:"Stop loss"})]})]})]})},pt=s()({root:{position:"relative"},tooltip:{position:"absolute",color:"gray",margin:0,left:5,top:5}}),ut={layout:{textColor:"#d1d4dc",backgroundColor:"#0000"},rightPriceScale:{scaleMargins:{top:.3,bottom:.25}},crosshair:{vertLine:{width:4,color:"#ebe0e301",style:0},horzLine:{visible:!1,labelVisible:!1}},grid:{vertLines:{color:"#f8b3"},horzLines:{color:"#f8b3"}},handleScroll:{vertTouchDrag:!1}},mt={color:"#90cbfa",lineWidth:2,crosshairMarkerVisible:!1,lastValueVisible:!1,priceLineVisible:!1},ht=({height:e,width:o,items:a})=>{const{classes:n}=pt(),l=i.useRef(void 0),r=i.useRef(void 0);return i.useLayoutEffect(()=>{const{current:t}=l,{current:n}=r,i=x(t,{...ut,height:e,width:o});i.addLineSeries({...mt}).setData(a);const s=({time:e})=>{if(e)try{const{day:t,month:o,year:l}=e,i=a.find(({time:e})=>e.day===t&&e.month===o&&e.year===l);if(i){const e=Math.round(Math.round(100*i.value)/100);n.innerHTML=`${C("Total")}: ${e}, ${C("Resolved")}: ${i.resolved}, ${C("Rejected")}: ${i.rejected}`}else n.innerHTML=""}catch(t){console.log(t),n.innerHTML=""}else n.innerHTML=""};return i.timeScale().fitContent(),i.subscribeCrosshairMove(s),()=>{i.unsubscribeCrosshairMove(s),i.remove()}},[e,o,a]),t("div",{ref:l,className:n.root,children:t("p",{ref:r,className:n.tooltip})})},gt=({items:e})=>t(h,{children:({height:o,width:a})=>t(ht,{height:o,width:a,items:e})}),yt=s()({root:{},container:{position:"relative",margin:0,padding:0,overflow:"clip"},editor:{position:"absolute",top:0,left:0,right:0,bottom:0}}),ft=({items:e,sx:o})=>{const{classes:a}=yt(),n=i.useMemo(()=>[...e].sort(({stamp:e},{stamp:t})=>e-t).map(({count:e,rejected:t,resolved:o,stamp:a})=>{const n=k(a);return{time:{year:n.get("year"),month:n.get("month")+1,day:n.get("date")},rejected:t,resolved:o,value:e}}),[e]);return t(u,{className:a.container,sx:o,children:t("div",{className:a.editor,children:t(gt,{items:n})})})},vt=e=>P({handler:async(t,a)=>{const n=S(t,a);for await(const l of(e=>w(async()=>{const t="live"===e?await o.storageViewService.listSignalLive():await o.storageViewService.listSignalBacktest(),a=t.filter(e=>"closed"===e.status).map(e=>({id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:e.pnl.pnlPercentage,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"finished"}));return"backtest"===e?a:[...t.filter(e=>"opened"===e.status).map(e=>({id:e.id,symbol:e.symbol,position:e.position,takeProfitPrice:e.priceTakeProfit,originalTakeProfitPrice:e.originalPriceTakeProfit,stopLossPrice:e.priceStopLoss,originalStopLossPrice:e.originalPriceStopLoss,profitLossPercentage:e.pnl.pnlPercentage,pnlCost:e.pnl.pnlCost,pnlEntries:e.pnl.pnlEntries,buyPrice:e.priceOpen,originalBuyPrice:e.originalPriceOpen,cost:e.cost,totalEntries:e.totalEntries,totalPartials:e.totalPartials,partialExecuted:e.partialExecuted,date:new Date(e.createdAt).toISOString(),status:"pending"})),...a]}))(e))if(n([l]).done)break;return n([]).rows}}),bt=[{field:"color",label:B.nbsp,minWidth:45,width:()=>45,format:({symbol:e})=>t(A,{children:async()=>{var a;try{const n=await o.symbolGlobalService.getSymbolMap();return t(te,{sx:{color:(null==(a=n[e])?void 0:a.color)||"#ccc"}})}catch(n){return t(te,{sx:{color:"#ccc"}})}}})},{field:"symbol",label:"Symbol",minWidth:115,width:e=>Math.max(e-45-90-145-80-90-80,45),format:({symbol:e})=>e},{field:"position",label:"Position",minWidth:90,width:()=>90,format:({position:e})=>{const o="long"===e;return t("span",{style:{color:o?"#1976D2":"#F57C00",padding:"4px 8px",borderRadius:"4px",fontWeight:"bold",fontSize:"11px"},children:o?"🔵 LONG":"🟠 SHORT"})}},{field:"buyPrice",label:"Entry",minWidth:145,width:()=>145,format:({buyPrice:e})=>`${d(e)}$`},{field:"pnlEntries",label:"Invested",minWidth:80,width:()=>80,format:({pnlEntries:e})=>`${d(e)}$`},{field:"profitLossPercentage",label:"PNL %",minWidth:90,width:()=>90,format:({profitLossPercentage:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",e.toFixed(2),"%"]})}},{field:"pnlCost",label:"PNL $",minWidth:80,width:()=>80,format:({pnlCost:e})=>{const o=e>=0;return t("span",{style:{color:o?"green":"red"},children:[o?"+":"",d(e),"$"]})}}],xt=[{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"symbol",title:"Symbol",readonly:!0,compute:e=>e.symbol||"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"position",title:"Position",readonly:!0,compute:e=>"long"===e.position?"🔵 LONG (profit on rise)":"🟠 SHORT (profit on fall)"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"date",title:"Date",readonly:!0,compute:e=>e.date?n(e.date).format("DD/MM/YYYY HH:mm"):""},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"buyPrice",title:"Entry",readonly:!0,compute:e=>e.buyPrice?`${d(e.buyPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalBuyPrice",title:"Original Entry",readonly:!0,isVisible:e=>null!=e.originalBuyPrice&&e.originalBuyPrice!==e.buyPrice,compute:e=>e.originalBuyPrice?`${d(e.originalBuyPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"takeProfitPrice",title:"Take Profit",readonly:!0,compute:e=>e.takeProfitPrice?`${d(e.takeProfitPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalTakeProfitPrice",title:"Original Take Profit",readonly:!0,isVisible:e=>null!=e.originalTakeProfitPrice&&e.originalTakeProfitPrice!==e.takeProfitPrice,compute:e=>e.originalTakeProfitPrice?`${d(e.originalTakeProfitPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"stopLossPrice",title:"Stop Loss",readonly:!0,compute:e=>e.stopLossPrice?`${d(e.stopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"originalStopLossPrice",title:"Original Stop Loss",readonly:!0,isVisible:e=>null!=e.originalStopLossPrice&&e.originalStopLossPrice!==e.stopLossPrice,compute:e=>e.originalStopLossPrice?`${d(e.originalStopLossPrice)}$`:"N/A"},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlEntries",title:"Invested",readonly:!0,compute:e=>`${d(e.pnlEntries)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"profitLossPercentage",title:"PNL %",readonly:!0,trailingIcon:({data:e})=>e.profitLossPercentage<0?t(Z,{sx:{color:"red"}}):t(Q,{sx:{color:"green"}}),compute:e=>`${e.profitLossPercentage>=0?"+":""}${e.profitLossPercentage.toFixed(2)}%`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"pnlCost",title:"PNL $",readonly:!0,compute:e=>`${e.pnlCost>=0?"+":""}${d(e.pnlCost)}$`},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalEntries",title:"Total Entries",readonly:!0,isVisible:e=>null!=e.totalEntries&&e.totalEntries>1,compute:e=>String(e.totalEntries)},{type:N.Text,outlined:!1,desktopColumns:"12",tabletColumns:"12",phoneColumns:"12",name:"totalPartials",title:"Total Closes",readonly:!0,isVisible:e=>null!=e.totalPartials&&e.totalPartials>0,compute:e=>String(e.totalPartials)},{type:N.Component,sx:{mt:2},element:({payload:e})=>t(I,{variant:"outlined",onClick:e.handleClose,children:"Back"})}],Ct=[{label:"Details",icon:()=>t(V,{icon:ee,color:"#4caf50"}),action:"open-action"}],kt=({sx:e,mode:a})=>{const n=vt(a),[l,i]=L(null),{pickData:r,setOpen:s,render:c}=M({title:"Info",AfterTitle:({onClose:e})=>t(D,{direction:"row",gap:2,children:[t(R,{onClick:()=>o.layoutService.pickSignal(l.current.id),variant:"outlined",children:"Show Details"}),t($,{size:"small",onClick:e,children:t(T,{})})]}),payload:()=>({handleClose(){s(!1)}}),fields:xt,handler:()=>l.current,withActionButton:!1});return t(m,{children:[t(u,{sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",background:"whitesmote",overflow:"clip",...e},children:t(j,{sx:{flex:1,background:"transparent !important"},rowColor:({status:e})=>"pending"===e?"#ffc40085":"transparent",hasMore:n.hasMore,loading:n.loading,onSkip:n.onSkip,data:n.data,columns:bt,rowActions:Ct,onRowClick:e=>{i(e),r(e.id)},onRowAction:(e,t)=>{"open-action"===e&&o.layoutService.pickSignal(t.id)}})}),c()]})},wt=[{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.thirtyOneDaysRevenue)||0,a=(null==e?void 0:e.thirtyOneDaysCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"31 days",footerLabel:"Profit for 31 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.sevenDaysRevenue)||0,a=(null==e?void 0:e.sevenDaysCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"7 days",footerLabel:"Profit for 7 days",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.yesterdayRevenue)||0,a=(null==e?void 0:e.yesterdayCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Yesterday",footerLabel:"Yesterday's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"3",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({revenueCount:e})=>{const o=(null==e?void 0:e.todayRevenue)||0,a=(null==e?void 0:e.todayCount)||0,n=o<0?se.Red:o>0?se.Green:se.Orange;return t(Se,{style:{height:"max(calc((100dvh - 100px) / 3), 275px)"},value:o,backgroundColor:n,backgroundMode:ue.Semi,valueUnit:"USDT",headerLabel:"Today",footerLabel:"Today's profit",caption:`${a} ${Le(a,{one:"trade",many:"trades"})}`})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({tradePerfomance:e})=>{const o=[{color:"#DD4049",label:"Failed",maxValue:Math.max(e.rejectedCount+1,1),value:()=>e.rejectedCount},{color:"#2EA96F",label:"Successful",maxValue:Math.max(e.rejectedCount+e.resolvedCount+2,2),value:()=>e.resolvedCount},{color:"#F3A43A",label:"Total",hidden:!0,maxValue:Math.max(e.total+3,3),value:()=>e.total}];return t(nt,{style:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o,valueUnit:Le(Math.abs(e.resolvedCount),{one:"Successful signal",many:"Successful signals"}),value:e.resolvedCount})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({dailyTrades:e})=>t(ft,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:e})},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({successRate:e})=>{const o=e.map(({symbol:e,displayName:o,rejectedCloseCount:a,rejectedStopLossCount:n,resolvedCloseCount:l,resolvedTakeProfitCount:i})=>({title:o||e,description:e,avatar:()=>t(K,{symbol:e}),done:i,archive:n,waiting:a,inprogress:l})).filter(({done:e,archive:t,waiting:o,inprogress:a})=>{let n=!1;return n=n||!!e,n=n||!!t,n=n||!!o,n=n||!!a,n});return t(dt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},items:o})}},{type:N.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:e})=>t(kt,{sx:{height:"max(calc((100dvh - 100px) / 2), 450px)"},mode:e.mode})}],Pt={rejectedCount:0,resolvedCount:0,total:0},St=[{action:"download-action",label:"Download",icon:()=>t(V,{icon:H,color:"#4caf50"})},{divider:!0},{action:"live-action",label:"Switch to LIVE",isVisible:e=>"backtest"===e,icon:()=>t(V,{icon:G,color:"#4caf50"})},{action:"backtest-action",label:"Switch to BACKTEST",isVisible:e=>"live"===e,icon:()=>t(V,{icon:Y,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>t(V,{icon:J,color:"#4caf50"})}],Lt=[{type:W.Link,action:"back-action",label:t(q,{sx:{display:"block"}})},{type:W.Link,action:"back-action",label:"Main"},{type:W.Link,action:"back-action",label:"Dashboard"},{type:W.Link,action:"back-action",compute:e=>`KPI ${String(e).toUpperCase()}`}],Mt=new F,Nt=({mode:e="backtest"})=>{const[a,{loading:n,execute:l}]=E(async()=>{const t=await o.symbolGlobalService.getSymbolList(),a=await o.symbolGlobalService.getSymbolMap(),n=new Map,l=[],i={...Pt};let r={symbol:"TOTAL",todayRevenue:0,yesterdayRevenue:0,sevenDaysRevenue:0,thirtyOneDaysRevenue:0,todayCount:0,yesterdayCount:0,sevenDaysCount:0,thirtyOneDaysCount:0};await Promise.all(t.map(async t=>{var o;const[s=[],c,d,p]=await Promise.all([ie(t,e),le(t,e),ne(t,e),re(t,e)]);for(const e of s){const t=n.get(e.stamp)||{count:0,resolved:0,rejected:0};n.set(e.stamp,{count:t.count+e.count,resolved:t.resolved+e.resolved,rejected:t.rejected+e.rejected})}l.push({...c,symbol:t,displayName:(null==(o=a[t])?void 0:o.displayName)||t}),i.rejectedCount+=d.rejectedCount,i.resolvedCount+=d.resolvedCount,i.total+=d.total,r.todayRevenue+=p.todayRevenue,r.yesterdayRevenue+=p.yesterdayRevenue,r.sevenDaysRevenue+=p.sevenDaysRevenue,r.thirtyOneDaysRevenue+=p.thirtyOneDaysRevenue,r.todayCount+=p.todayCount,r.yesterdayCount+=p.yesterdayCount,r.sevenDaysCount+=p.sevenDaysCount,r.thirtyOneDaysCount+=p.thirtyOneDaysCount}));return{dailyTrades:Array.from(n).map(([e,{count:t,resolved:o,rejected:a}])=>({stamp:e,count:t,resolved:o,rejected:a})),successRate:l,tradePerfomance:i,revenueCount:r}},{onLoadStart:()=>o.layoutService.setModalLoader(!0),onLoadEnd:()=>o.layoutService.setModalLoader(!1),deps:[e]}),{execute:i}=O(async()=>{const t=await oe(e),a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(a);o.layoutService.downloadFile(n,`signals_${e}_${Date.now()}.json`)},{onLoadStart:()=>o.layoutService.setAppbarLoader(!0),onLoadEnd:()=>o.layoutService.setAppbarLoader(!1)});z(()=>Mt.subscribe(l));return t(X,{children:[t(U,{items:Lt,actions:St,payload:e,onAction:async e=>{"download-action"===e&&await i(),"update-now"===e&&(oe.clear(),await Mt.next()),"live-action"===e&&o.routerService.push("/dashboard/live"),"backtest-action"===e&&o.routerService.push("/dashboard/backtest"),"back-action"===e&&o.routerService.push("/")}}),a?n?null:t(_,{handler:a,payload:()=>({handleUpdate(){Mt.next()},mode:e}),fields:wt}):null]})};export{Nt as DashboardPage,Nt as default};
@@ -1 +1 @@
1
- import{b as e,f as a,r as t,ba as i,bb as o,X as r,i as s,bc as n,bd as c,be as l,I as d,az as p,aU as h,bf as b,p as u,a5 as m,bg as f,G as y,T as g,aW as v,aa as x,Q as w,bh as L,ab as S,bi as k,aQ as A,y as j,Y as z,Z as C,v as N,w as E,b0 as H,B as R,z as T,a6 as I}from"./index-DA0cY5CT.js";import{h as M}from"./hasRouteMatch-EVPvlDIB.js";import{B as V}from"./Background-B2ldn454.js";import{A as B}from"./Article-Dh_vYreB.js";import{C as D,R as F}from"./Refresh-OHKLL7G_.js";import{K}from"./KeyboardArrowLeft-CXc4SNLm.js";const W=e(a("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"Image"),P=e(a("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"}),"InsertDriveFile"),Q="65px",X=e=>e.mimeType.startsWith("image/")?a(W,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(j,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(B,{sx:{color:"#1976d2",fontSize:20}}):a(P,{sx:{color:"#546e7a",fontSize:20}}),G=u()(e=>({root:{position:"relative",height:"100%",width:"100%",background:"#eee",overflow:"clip"},header:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"8px",paddingRight:"4px",height:Q},input:{height:Q,paddingRight:e.spacing(2),paddingLeft:e.spacing(1),width:"100%"},container:{position:"absolute",top:Q,left:0,right:0,bottom:0,height:`calc(100% - ${Q})`,width:"100%",background:"white",overflow:"clip",display:"flex",alignItems:"stretch",justifyContent:"stretch"},content:{display:"flex",flex:1},loader:{height:"100%",width:"100%"},accent:{background:m("#00c3ff",.05)}})),O=({outlinePaper:e,className:u,style:m,sx:j,nodes:z,initialSearch:C=""})=>{const{classes:N,cx:E}=G(),[H,R]=t.useState(C),T=i(H),[I,{flush:M}]=o(H,2500),[V,{loading:B}]=r(async()=>await(async(e,a)=>{const t=e.trim().toLowerCase(),i=[];let o=0;for(const r of s.explorerHelperService.deepFlat(a))if("file"!==r.type||t&&!r.path.toLowerCase().includes(t)||i.push(r),++o%1e4==0&&await f(0),i.length>25e3)break;return i})(I,z),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),deps:[I,z]}),{execute:D}=n(async e=>{await s.layoutService.pickDumpContent(e)},{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});return a(b,{outlinePaper:e,className:E(N.root,u),style:m,sx:j,children:[a("div",{className:N.header,children:a(c,{disabled:B,className:N.input,endAdornment:a(l,{position:"end",children:a(d,{disabled:B||!H,onClick:()=>{T.once(async()=>{await f(500),M()}),R("")},edge:"end",children:a(H?p:h,{})})}),placeholder:"Search",value:H,onBlur:()=>M(),onChange:({target:e})=>R(e.value),onKeyDown:({key:e,currentTarget:a})=>"Enter"===e&&a.blur()})}),a("div",{className:N.container,children:a("div",{className:N.content,children:V?V.length?a(A,{withScrollbar:!0,children:V.map((e,t)=>a(x,{className:E({[N.accent]:t%2==1}),component:w,onClick:()=>(async e=>{await D(e)})(e.id),children:[a(L,{children:X(e)}),a(S,{primary:e.label,secondary:e.path}),a(k,{content:e.path,label:"Copy path"})]},e.id))}):a(v,{sx:{height:"100%",width:"100%"},children:a(g,{variant:"h6",sx:{opacity:.5},children:"Not found"})}):a(y,{className:N.loader})})})]})},U=[{type:E.Link,action:"back-action",label:a(K,{sx:{display:"block"}})},{type:E.Link,action:"back-action",label:"Main"},{type:E.Link,action:"back-action",label:"Dump Explorer"}],Y=[{action:"update-now",label:"Refresh",icon:()=>a(T,{icon:F,color:"#4caf50"})}],Z=new C,$=({params:e})=>{const[t,{loading:i,execute:o}]=r(async()=>await s.explorerViewService.getFolderTree(),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});z(()=>Z.subscribe(o));return a(D,{children:[a(N,{items:U,actions:Y,onAction:e=>{"back-action"===e&&s.routerService.push("/"),"update-now"===e&&(s.explorerViewService.clear(),Z.next())}}),a(H,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(R,{pr:2,pl:2,children:i||!t?a(v,{children:a(g,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(O,{nodes:t,initialSearch:e.search})})}),a(V,{})]})},q=[{id:"search",element:$,isActive:e=>M(["/dump/:search"],e)},{id:"main",element:$,isActive:e=>M(["/dump"],e)}],J=({search:e=""})=>a(I,{history:s.routerService,onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),routes:q,params:{search:e}});export{J as DumpPage,J as default};
1
+ import{b as e,f as a,r as t,ba as i,bb as o,X as r,i as s,bc as n,bd as c,be as l,I as d,az as p,aU as h,bf as b,p as u,a5 as m,bg as f,G as y,T as g,aW as v,aa as x,Q as w,bh as L,ab as S,bi as k,aQ as A,y as j,Y as z,Z as C,v as N,w as E,b0 as H,B as R,z as T,a6 as I}from"./index-is6UARFt.js";import{h as M}from"./hasRouteMatch-Bw2df_bl.js";import{B as V}from"./Background-5Pc2kls4.js";import{A as B}from"./Article-DDKZjbkz.js";import{C as D,R as F}from"./Refresh-6IBmzTpL.js";import{K}from"./KeyboardArrowLeft-nUGbVivG.js";const W=e(a("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"Image"),P=e(a("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"}),"InsertDriveFile"),Q="65px",X=e=>e.mimeType.startsWith("image/")?a(W,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(j,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(B,{sx:{color:"#1976d2",fontSize:20}}):a(P,{sx:{color:"#546e7a",fontSize:20}}),G=u()(e=>({root:{position:"relative",height:"100%",width:"100%",background:"#eee",overflow:"clip"},header:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"8px",paddingRight:"4px",height:Q},input:{height:Q,paddingRight:e.spacing(2),paddingLeft:e.spacing(1),width:"100%"},container:{position:"absolute",top:Q,left:0,right:0,bottom:0,height:`calc(100% - ${Q})`,width:"100%",background:"white",overflow:"clip",display:"flex",alignItems:"stretch",justifyContent:"stretch"},content:{display:"flex",flex:1},loader:{height:"100%",width:"100%"},accent:{background:m("#00c3ff",.05)}})),O=({outlinePaper:e,className:u,style:m,sx:j,nodes:z,initialSearch:C=""})=>{const{classes:N,cx:E}=G(),[H,R]=t.useState(C),T=i(H),[I,{flush:M}]=o(H,2500),[V,{loading:B}]=r(async()=>await(async(e,a)=>{const t=e.trim().toLowerCase(),i=[];let o=0;for(const r of s.explorerHelperService.deepFlat(a))if("file"!==r.type||t&&!r.path.toLowerCase().includes(t)||i.push(r),++o%1e4==0&&await f(0),i.length>25e3)break;return i})(I,z),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),deps:[I,z]}),{execute:D}=n(async e=>{await s.layoutService.pickDumpContent(e)},{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});return a(b,{outlinePaper:e,className:E(N.root,u),style:m,sx:j,children:[a("div",{className:N.header,children:a(c,{disabled:B,className:N.input,endAdornment:a(l,{position:"end",children:a(d,{disabled:B||!H,onClick:()=>{T.once(async()=>{await f(500),M()}),R("")},edge:"end",children:a(H?p:h,{})})}),placeholder:"Search",value:H,onBlur:()=>M(),onChange:({target:e})=>R(e.value),onKeyDown:({key:e,currentTarget:a})=>"Enter"===e&&a.blur()})}),a("div",{className:N.container,children:a("div",{className:N.content,children:V?V.length?a(A,{withScrollbar:!0,children:V.map((e,t)=>a(x,{className:E({[N.accent]:t%2==1}),component:w,onClick:()=>(async e=>{await D(e)})(e.id),children:[a(L,{children:X(e)}),a(S,{primary:e.label,secondary:e.path}),a(k,{content:e.path,label:"Copy path"})]},e.id))}):a(v,{sx:{height:"100%",width:"100%"},children:a(g,{variant:"h6",sx:{opacity:.5},children:"Not found"})}):a(y,{className:N.loader})})})]})},U=[{type:E.Link,action:"back-action",label:a(K,{sx:{display:"block"}})},{type:E.Link,action:"back-action",label:"Main"},{type:E.Link,action:"back-action",label:"Dump Explorer"}],Y=[{action:"update-now",label:"Refresh",icon:()=>a(T,{icon:F,color:"#4caf50"})}],Z=new C,$=({params:e})=>{const[t,{loading:i,execute:o}]=r(async()=>await s.explorerViewService.getFolderTree(),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});z(()=>Z.subscribe(o));return a(D,{children:[a(N,{items:U,actions:Y,onAction:e=>{"back-action"===e&&s.routerService.push("/"),"update-now"===e&&(s.explorerViewService.clear(),Z.next())}}),a(H,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(R,{pr:2,pl:2,children:i||!t?a(v,{children:a(g,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(O,{nodes:t,initialSearch:e.search})})}),a(V,{})]})},q=[{id:"search",element:$,isActive:e=>M(["/dump/:search"],e)},{id:"main",element:$,isActive:e=>M(["/dump"],e)}],J=({search:e=""})=>a(I,{history:s.routerService,onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),routes:q,params:{search:e}});export{J as DumpPage,J as default};
@@ -1 +1 @@
1
- import{b as a,f as e,aQ as t,B as o,N as r,$ as n,T as i,al as s,K as c,F as l,aE as d,P as h,aF as p,aS as u,aT as w,av as b,Z as f,i as x,aw as g,a8 as v,aB as y,v as m,w as S,aU as k,aR as L,D as j,z}from"./index-DA0cY5CT.js";import{A}from"./Article-Dh_vYreB.js";import{C as R,R as H}from"./Refresh-OHKLL7G_.js";import{K as B}from"./KeyboardArrowLeft-CXc4SNLm.js";const C=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),E=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(C,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(A,{sx:t})}},F=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:E(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),D=[{action:"download-action",label:"Download",icon:()=>e(z,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(z,{icon:H,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(B,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:k,action:"search-action",label:"Search"}],U=new f,Y=()=>{const[a,o]=w(""),{data:r,hasMore:n,loading:i,onSkip:s}=b({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:U}),c=v(r),{execute:l}=y(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:M,actions:D,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await U.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void U.next();o(""),U.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:L,hasMore:n,children:r.map(a=>e(F,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
1
+ import{b as a,f as e,aQ as t,B as o,N as r,$ as n,T as i,al as s,K as c,F as l,aE as d,P as h,aF as p,aS as u,aT as w,av as b,Z as f,i as x,aw as g,a8 as v,aB as y,v as m,w as S,aU as k,aR as L,D as j,z}from"./index-is6UARFt.js";import{A}from"./Article-DDKZjbkz.js";import{C as R,R as H}from"./Refresh-6IBmzTpL.js";import{K as B}from"./KeyboardArrowLeft-nUGbVivG.js";const C=a(e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"}),"BugReport"),E=a=>{const t={color:"white",fontSize:28};switch(a.type){case"debug":return e(C,{sx:t});case"info":return e(u,{sx:t});case"warn":return e(p,{sx:t});default:return e(A,{sx:t})}},F=t.virtualize(({data:a,sx:t})=>{const p=(a=>{switch(a.type){case"debug":default:return"#9E9E9E";case"info":return"#2196F3";case"warn":return"#FF9800";case"log":return"#4CAF50"}})(a);return e(h,{variant:"outlined",sx:{display:"flex",alignItems:"stretch",justifyContent:"stretch",...t},children:e(o,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[e(r,{direction:"row",spacing:2,sx:{p:2},children:[e(n,{sx:{width:56,height:56,background:p},children:E(a)}),e(r,{flex:1,spacing:1,children:[e(r,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[e(i,{variant:"h6",sx:{fontWeight:600,wordBreak:"break-all"},children:a.topic}),e(i,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(a.createdAt).format("HH:mm DD/MM/YYYY")})]}),e(r,{direction:"row",spacing:1,flexWrap:"wrap",children:e(c,{size:"small",label:a.type.toUpperCase(),sx:{background:p,color:"white",fontWeight:500}})}),a.args.length>0&&e(l,{children:[e(d,{sx:{my:1}}),e(o,{component:"pre",sx:{m:0,fontSize:"0.75rem",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"text.secondary"},children:JSON.stringify(1===a.args.length?a.args[0]:a.args,null,2)})]})]})]}),e(o,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:p}})]})})}),D=[{action:"download-action",label:"Download",icon:()=>e(z,{icon:j,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh manually",icon:()=>e(z,{icon:H,color:"#4caf50"})}],M=[{type:S.Link,action:"back-action",label:e(B,{sx:{display:"block"}})},{type:S.Link,action:"back-action",label:"Main"},{type:S.Link,action:"back-action",label:"Logs"},{type:S.Button,icon:k,action:"search-action",label:"Search"}],U=new f,Y=()=>{const[a,o]=w(""),{data:r,hasMore:n,loading:i,onSkip:s}=b({handler:async(e,t)=>{const o=await x.logViewService.getList(),r=g(e,t);for(const n of o)if(new RegExp(a.current,"i").test(n.topic)&&r([n]).done)break;return r().rows},onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1),reloadSubject:U}),c=v(r),{execute:l}=y(async()=>{const a=new Blob([JSON.stringify(c.current,null,2)],{type:"application/json"}),e=URL.createObjectURL(a);x.layoutService.downloadFile(e,`logs_${Date.now()}.json`)},{onLoadStart:()=>x.layoutService.setAppbarLoader(!0),onLoadEnd:()=>x.layoutService.setAppbarLoader(!1)});return e(R,{children:[e(m,{items:M,actions:D,onAction:async a=>{"back-action"===a&&x.routerService.push("/"),"download-action"===a&&l(),"update-now"===a&&(o(""),await U.next()),"search-action"===a&&(async()=>{const a=await x.layoutService.prompt("Search keyword");if(a)return o(a),void U.next();o(""),U.next()})()}}),e(t,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:i,onDataRequest:s,bufferSize:L,hasMore:n,children:r.map(a=>e(F,{data:a,sx:{mb:1}},a.id))})]})};export{Y as LogPage,Y as default};
@@ -1 +1 @@
1
- import{f as t,T as e,L as a,bj as o,H as n,P as i,p as l,X as r,i as c,Y as s,v as d,w as p,y as m,z as y,A as u,E as h,G as w,x,b0 as f,q as b,a6 as g}from"./index-DA0cY5CT.js";import{h as v}from"./hasRouteMatch-EVPvlDIB.js";import{r as R}from"./emitters-ftFfHgfR.js";import{I as S}from"./IconPhoto-C2SEjuLJ.js";import{P as F}from"./PictureAsPdfOutlined-BHHWm0bL.js";import{C as L,R as A}from"./Refresh-OHKLL7G_.js";import{K as N}from"./KeyboardArrowLeft-CXc4SNLm.js";const j=l()(t=>({root:{position:"relative",background:"#0001",overflow:"clip"},header:{position:"absolute",top:0,left:0,height:"48px",width:"calc(100% - 16px)",display:"flex",alignItems:"center",justifyContent:"space-between",marginLeft:"8px",marginRight:"8px"},container:{marginTop:"48px",width:"100%",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center"},content:{display:"flex",width:"100%",padding:t.spacing(1),paddingBottom:t.spacing(2),gap:10,flexDirection:"column"},avatar:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"128px",minWidth:"128px"}})),k=[{type:n.Text,name:"totalPnl",title:"Total PNL",compute:t=>null!==t.totalPnl?`${t.totalPnl.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"winRate",title:"Win Rate",compute:t=>null!==t.winRate?`${t.winRate.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"profitFactor",title:"Profit Factor",compute:t=>null!==t.profitFactor?t.profitFactor.toFixed(2):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"maxDrawdown",title:"Max Drawdown",compute:t=>null!==t.maxDrawdown?`${t.maxDrawdown.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"expectancy",title:"Expectancy",compute:t=>null!==t.expectancy?`${t.expectancy.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"sortinoRatio",title:"Sortino Ratio",compute:t=>null!==t.sortinoRatio?t.sortinoRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"calmarRatio",title:"Calmar Ratio",compute:t=>null!==t.calmarRatio?t.calmarRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"recoveryFactor",title:"Recovery Factor",compute:t=>null!==t.recoveryFactor?t.recoveryFactor.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"totalTrades",title:"Trades",readonly:!0}],D=({row:n})=>{const{classes:l}=j();return t(i,{className:l.root,children:[t("div",{className:l.header,children:t(e,{variant:"h6",sx:{opacity:.8},children:`${a.bullet} ${n.symbol}`})}),t("div",{className:l.container,children:t("div",{className:l.content,children:[t("div",{className:l.avatar,children:t(S,{symbol:n.symbol,sx:{width:128,height:128}})}),t(o,{handler:()=>n,fields:k,sx:{mb:2}})]})})]})},T=[{type:p.Link,action:"back-action",label:t(N,{sx:{display:"block"}})},{type:p.Link,action:"back-action",label:"Dashboard"},{type:p.Link,action:"back-action",label:"Heatmap"},{type:p.Button,action:"download-pdf",label:"Download PDF",icon:F}],P=[{action:"download-json",label:"Download JSON",icon:()=>t(y,{icon:m,color:"#4caf50"})},{action:"download-markdown",label:"Download Markdown",icon:()=>t(y,{icon:u,color:"#4caf50"})},{action:"download-pdf",label:"Download PDF",icon:()=>t(y,{icon:h,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>t(y,{icon:A,color:"#4caf50"})}],C=[{id:"main",element:()=>{const[e,{loading:a,execute:o}]=r(async()=>(e=>{if(!e.length)return[{type:n.Typography,typoVariant:"h6",placeholder:"No data",sx:{textAlign:"center",opacity:.5,mt:4}}];const a=e.map(e=>({type:n.Group,desktopColumns:"4",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",child:{type:n.Component,element:()=>t(D,{row:e})}}));return a.length>2?a:[{type:n.Center,sx:t=>({[t.breakpoints.up("lg")]:{"@media (min-height: 900px)":{height:"calc(100dvh - 165px)","& > *":{transform:"translateY(-56px)"}}}}),fields:a}]})((await c.heatViewService.getStrategyHeatData()).symbols),{onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1)});s(()=>R.subscribe(o));return t(L,{children:[t(d,{items:T,actions:P,onAction:async t=>{"back-action"===t&&c.routerService.push("/"),"update-now"===t&&await R.next(),"download-markdown"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport(),e=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(e);c.layoutService.downloadFile(a,`heat_${Date.now()}.md`)})(),"download-pdf"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport();await b(t)})(),"download-json"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatData(),e=JSON.stringify(t,null,2),a=new Blob([e],{type:"text/plain"}),o=URL.createObjectURL(a);c.layoutService.downloadFile(o,`heat_${Date.now()}.md`)})()}}),!e||a?t(w,{sx:{height:"calc(100dvh - 165px)"}}):t(f,{withScrollbar:!0,sx:{height:"calc(100dvh - 165px)"},hideOverflowX:!0,children:t(x,{fields:e})})]})},isActive:t=>v(["/heat"],t)}],$=({id:e})=>t(g,{history:c.routerService,onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1),routes:C,params:{id:e}});export{$ as HeatPage,$ as default};
1
+ import{f as t,T as e,L as a,bj as o,H as n,P as i,p as l,X as r,i as c,Y as s,v as d,w as p,y as m,z as y,A as u,E as h,G as w,x,b0 as f,q as b,a6 as g}from"./index-is6UARFt.js";import{h as v}from"./hasRouteMatch-Bw2df_bl.js";import{r as R}from"./emitters-1aP5uqiT.js";import{I as S}from"./IconPhoto-2KIaDXXx.js";import{P as F}from"./PictureAsPdfOutlined-BKzXxbqU.js";import{C as L,R as A}from"./Refresh-6IBmzTpL.js";import{K as N}from"./KeyboardArrowLeft-nUGbVivG.js";const j=l()(t=>({root:{position:"relative",background:"#0001",overflow:"clip"},header:{position:"absolute",top:0,left:0,height:"48px",width:"calc(100% - 16px)",display:"flex",alignItems:"center",justifyContent:"space-between",marginLeft:"8px",marginRight:"8px"},container:{marginTop:"48px",width:"100%",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center"},content:{display:"flex",width:"100%",padding:t.spacing(1),paddingBottom:t.spacing(2),gap:10,flexDirection:"column"},avatar:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"128px",minWidth:"128px"}})),k=[{type:n.Text,name:"totalPnl",title:"Total PNL",compute:t=>null!==t.totalPnl?`${t.totalPnl.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"winRate",title:"Win Rate",compute:t=>null!==t.winRate?`${t.winRate.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"profitFactor",title:"Profit Factor",compute:t=>null!==t.profitFactor?t.profitFactor.toFixed(2):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"maxDrawdown",title:"Max Drawdown",compute:t=>null!==t.maxDrawdown?`${t.maxDrawdown.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"expectancy",title:"Expectancy",compute:t=>null!==t.expectancy?`${t.expectancy.toFixed(2)}%`:"N/A",readonly:!0},{type:n.Text,columns:"6",name:"sortinoRatio",title:"Sortino Ratio",compute:t=>null!==t.sortinoRatio?t.sortinoRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"calmarRatio",title:"Calmar Ratio",compute:t=>null!==t.calmarRatio?t.calmarRatio.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"recoveryFactor",title:"Recovery Factor",compute:t=>null!==t.recoveryFactor?t.recoveryFactor.toFixed(3):"N/A",readonly:!0},{type:n.Text,columns:"6",name:"totalTrades",title:"Trades",readonly:!0}],D=({row:n})=>{const{classes:l}=j();return t(i,{className:l.root,children:[t("div",{className:l.header,children:t(e,{variant:"h6",sx:{opacity:.8},children:`${a.bullet} ${n.symbol}`})}),t("div",{className:l.container,children:t("div",{className:l.content,children:[t("div",{className:l.avatar,children:t(S,{symbol:n.symbol,sx:{width:128,height:128}})}),t(o,{handler:()=>n,fields:k,sx:{mb:2}})]})})]})},T=[{type:p.Link,action:"back-action",label:t(N,{sx:{display:"block"}})},{type:p.Link,action:"back-action",label:"Dashboard"},{type:p.Link,action:"back-action",label:"Heatmap"},{type:p.Button,action:"download-pdf",label:"Download PDF",icon:F}],P=[{action:"download-json",label:"Download JSON",icon:()=>t(y,{icon:m,color:"#4caf50"})},{action:"download-markdown",label:"Download Markdown",icon:()=>t(y,{icon:u,color:"#4caf50"})},{action:"download-pdf",label:"Download PDF",icon:()=>t(y,{icon:h,color:"#4caf50"})},{divider:!0},{action:"update-now",label:"Refresh",icon:()=>t(y,{icon:A,color:"#4caf50"})}],C=[{id:"main",element:()=>{const[e,{loading:a,execute:o}]=r(async()=>(e=>{if(!e.length)return[{type:n.Typography,typoVariant:"h6",placeholder:"No data",sx:{textAlign:"center",opacity:.5,mt:4}}];const a=e.map(e=>({type:n.Group,desktopColumns:"4",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",child:{type:n.Component,element:()=>t(D,{row:e})}}));return a.length>2?a:[{type:n.Center,sx:t=>({[t.breakpoints.up("lg")]:{"@media (min-height: 900px)":{height:"calc(100dvh - 165px)","& > *":{transform:"translateY(-56px)"}}}}),fields:a}]})((await c.heatViewService.getStrategyHeatData()).symbols),{onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1)});s(()=>R.subscribe(o));return t(L,{children:[t(d,{items:T,actions:P,onAction:async t=>{"back-action"===t&&c.routerService.push("/"),"update-now"===t&&await R.next(),"download-markdown"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport(),e=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(e);c.layoutService.downloadFile(a,`heat_${Date.now()}.md`)})(),"download-pdf"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatReport();await b(t)})(),"download-json"===t&&await(async()=>{const t=await c.heatViewService.getStrategyHeatData(),e=JSON.stringify(t,null,2),a=new Blob([e],{type:"text/plain"}),o=URL.createObjectURL(a);c.layoutService.downloadFile(o,`heat_${Date.now()}.md`)})()}}),!e||a?t(w,{sx:{height:"calc(100dvh - 165px)"}}):t(f,{withScrollbar:!0,sx:{height:"calc(100dvh - 165px)"},hideOverflowX:!0,children:t(x,{fields:e})})]})},isActive:t=>v(["/heat"],t)}],$=({id:e})=>t(g,{history:c.routerService,onLoadStart:()=>c.layoutService.setAppbarLoader(!0),onLoadEnd:()=>c.layoutService.setAppbarLoader(!1),routes:C,params:{id:e}});export{$ as HeatPage,$ as default};
@@ -1 +1 @@
1
- import{f as e,b0 as t,M as a,B as i,b1 as r,b2 as o,i as n,b3 as l,b4 as s,aY as c,b5 as d,y as w,z as p,A as h,E as m,aT as k,b6 as g,ax as b,b7 as v,aj as y,b8 as u,a_ as f,az as S,N as x,b9 as _,am as D,q as V,aV as N,X as O,v as R,w as L,p as B,H as A,T as P,aW as C,x as $,F as M,K as J,L as j,Q as G,l as X,n as F,O as H,V as E,a6 as I}from"./index-DA0cY5CT.js";import{h as z}from"./hasRouteMatch-EVPvlDIB.js";import{I as T}from"./IconPhoto-C2SEjuLJ.js";import{C as U,R as K}from"./Refresh-OHKLL7G_.js";import{K as W}from"./KeyboardArrowLeft-CXc4SNLm.js";const q=[{id:"backtest",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Q=[{id:"backtest",label:"Backtest",isVisible:({type:e})=>"backtest"===e},{id:"live",label:"Live",isVisible:({type:e})=>"live"===e},{id:"strategy",label:"Strategy"},{id:"breakeven",label:"Breakeven"},{id:"risk",label:"Risk"},{id:"partial",label:"Partial"},{id:"highest_profit",label:"Highest Profit"},{id:"max_drawdown",label:"Max Drawdown"},{id:"schedule",label:"Schedule"},{id:"performance",label:"Performance"},{id:"sync",label:"Sync"},{id:"heat",label:"Heat"}],Y=({disabled:t,className:a,style:i,sx:c,onClick:d,color:w})=>e(l,{className:a,style:i,sx:c,disabled:t,color:w,size:36,onClick:async e=>{const[t,{resolve:a}]=o();e.preventDefault(),e.stopPropagation(),await d(e,e=>a(e));const i=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 s(String(e))})(i),n.alertService.notify("Copied!")},children:e(r,{})}),Z=[{action:"json",label:"Download JSON",icon:()=>e(p,{icon:w,color:"#4caf50"})},{action:"markdown",label:"Download Markdown",icon:()=>e(p,{icon:h,color:"#4caf50"})},{action:"pdf",label:"Download PDF",icon:()=>e(p,{icon:m,color:"#4caf50"})}],ee=({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(d,{transparent:!0,keepMounted:!0,className:a,style:i,sx:r,disabled:t,options:Z,onAction:s})},te=y(),ae=D(async(e,t)=>{const a=("backtest"===t?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:l}=a,[s,c,d,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?n.markdownViewService.getBacktestReport(i,r,o,l):Promise.resolve(""),"live"===t?n.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),n.markdownViewService.getBreakevenReport(i,r,o,l,"backtest"===t),n.markdownViewService.getRiskReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPartialReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHighestProfitReport(i,r,o,l,"backtest"===t),n.markdownViewService.getMaxDrawdownReport(i,r,o,l,"backtest"===t),n.markdownViewService.getScheduleReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPerformanceReport(i,r,o,l,"backtest"===t),n.markdownViewService.getSyncReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHeatReport(r,o,l,"backtest"===t),n.markdownViewService.getStrategyReport(i,r,o,l,"backtest"===t)]);return{type:t,backtest:s,live:c,breakeven:d,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}`}),ie=()=>{const[t,a]=k(""),[r,o]=k("backtest"),s=g(),{push:c,pop:d}=s,[w,p]=b(te.location.pathname),h=async()=>{const e=(await ae(t.current,r.current))[w.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},m=async()=>{const e=await ae(t.current,r.current),a=w.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${a}_${r.current}_${Date.now()}.md`)}},y=async()=>{const e=("backtest"===r.current?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:o,frameName:l}=e,s=w.current.replace("/markdown_report/",""),c="backtest"===r.current;let d;if("backtest"===s?d=await n.markdownViewService.getBacktestData(a,i,o,l):"live"===s?d=await n.markdownViewService.getLiveData(a,i,o):"breakeven"===s?d=await n.markdownViewService.getBreakevenData(a,i,o,l,c):"risk"===s?d=await n.markdownViewService.getRiskData(a,i,o,l,c):"partial"===s?d=await n.markdownViewService.getPartialData(a,i,o,l,c):"highest_profit"===s?d=await n.markdownViewService.getHighestProfitData(a,i,o,l,c):"max_drawdown"===s?d=await n.markdownViewService.getMaxDrawdownData(a,i,o,l,c):"schedule"===s?d=await n.markdownViewService.getScheduleData(a,i,o,l,c):"performance"===s?d=await n.markdownViewService.getPerformanceData(a,i,o,l,c):"sync"===s?d=await n.markdownViewService.getSyncData(a,i,o,l,c):"heat"===s?d=await n.markdownViewService.getHeatData(i,o,l,c):"strategy"===s&&(d=await n.markdownViewService.getStrategyData(a,i,o,l,c)),void 0!==d){const e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${s}_${r.current}_${Date.now()}.json`)}},{pickData:D,render:N}=v({tabs:Q,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),p(a)},animation:"none",title:"Markdown Report",sizeRequest:u,history:te,routes:q,BeforeTitle:({onClose:t})=>{const{total:a}=g();return e(i,{sx:{mr:1,display:1===a?"none":"flex"},children:e(l,{onClick:t,children:e(_,{})})})},AfterTitle:({onClose:a})=>e(x,{direction:"row",gap:1,children:[e(l,{sx:{mr:"10px"},onClick:()=>h(),children:e(f,{})}),e(Y,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:l,exchangeName:s,frameName:c}=r,d="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await n.markdownViewService.getBacktestData(o,l,s,c),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await n.markdownViewService.getLiveData(o,l,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await n.markdownViewService.getBreakevenData(o,l,s,c,d),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await n.markdownViewService.getRiskData(o,l,s,c,d),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await n.markdownViewService.getPartialData(o,l,s,c,d),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await n.markdownViewService.getHighestProfitData(o,l,s,c,d),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await n.markdownViewService.getMaxDrawdownData(o,l,s,c,d),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await n.markdownViewService.getScheduleData(o,l,s,c,d),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await n.markdownViewService.getPerformanceData(o,l,s,c,d),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await n.markdownViewService.getSyncData(o,l,s,c,d),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await n.markdownViewService.getHeatData(l,s,c,d),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await n.markdownViewService.getStrategyData(o,l,s,c,d),null,2))})(w.current,t.current,r.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(ee,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:y,onDownloadMarkdown:m,onDownloadPdf:h}),e(l,{onClick:a,children:e(S,{})})]}),fetchState:async()=>await ae(t.current,r.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),onClose:()=>{d()}});return(e,t)=>{c({id:"markdown_report_modal",render:N,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";te.push(e),p(e)},onMount:()=>{a(e),o(t),D()}})}},re="backtest-kit__groupHeader",oe="backtest-kit__groupRoot",ne="backtest-kit__symbolImage",le=B()({root:{[`& .${oe}:hover .${re}`]:{opacity:"1 !important"}}});function se(e){return E(e,"#000000")>E(e,"#FFFFFF")}const ce=[{type:L.Link,action:"back-action",label:e(W,{sx:{display:"block"}})},{type:L.Link,action:"back-action",label:"Main"},{type:L.Link,action:"back-action",label:"Markdown Report"}],de=[{action:"update-now",label:"Refresh",icon:()=>e(p,{icon:K,color:"#4caf50"})}],we=(t,a)=>({type:A.Group,className:oe,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:A.Component,className:re,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(x,{direction:"row",children:[e(J,{variant:"outlined",size:"small",color:"info",label:`${j.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(i,{flex:1})]})},{type:A.Group,fields:a.map(({symbol:t,label:a,id:i,type:r,color:o})=>((t,a,i,r,o)=>({type:A.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:n})=>e(H,{component:G,onClick:()=>{n.handleOpen(t,a)},sx:{width:"100%",background:o,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${ne}`]:{transition:"filter 500ms"},"&:hover":{background:()=>se(o)?X(o,.33):F(o,.33),[`& .${ne}`]:{transition:"filter 500ms",filter:se(o)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(T,{className:ne,symbol:i}),children:r})}))(i,r,t,a,o))}]}),pe=[{id:"main",element:()=>{const{classes:t}=le(),{reloadTrigger:a,doReload:r}=N(),[o,{loading:l}]=O(async()=>await(async()=>{const[e,t,a]=await Promise.all([n.symbolGlobalService.getSymbolMap(),n.backtestGlobalService.list(),n.liveGlobalService.list()]),i={},r={};t.forEach(t=>{const a=e[t.symbol],r=t.strategyName;i[r]||(i[r]=[]),i[r].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;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",id:t.id,type:"live"})});const o=Object.entries(i).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t)),l=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t));return l.length||o.length?[{type:A.Fragment,isVisible:()=>!!o.length,fields:[{type:A.Line,title:"Backtest"},{type:A.Group,columns:"12",fields:o}]},{type:A.Fragment,isVisible:()=>!!l.length,fields:[{type:A.Line,title:"Live"},{type:A.Group,columns:"12",fields:l}]}]:[]})(),{onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),deps:[a]}),s=ie(),c=(e,t)=>{s(e,t)};return e(U,{children:[e(R,{items:ce,actions:de,onAction:e=>{"back-action"===e&&n.routerService.push("/"),"update-now"===e&&r()}}),l||!o?e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o.length?e(M,{children:[e($,{className:t.root,fields:o,payload:()=>({handleOpen:c})},a),e(i,{paddingBottom:"24px"})]}):e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>z(["/report"],e)}],he=({id:t})=>e(I,{history:n.routerService,onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),routes:pe,params:{id:t}});export{he as StatusPage,he as default};
1
+ import{f as e,b0 as t,M as a,B as i,b1 as r,b2 as o,i as n,b3 as l,b4 as s,aY as c,b5 as d,y as w,z as p,A as h,E as m,aT as k,b6 as g,ax as b,b7 as v,aj as y,b8 as u,a_ as f,az as S,N as x,b9 as _,am as D,q as V,aV as N,X as O,v as R,w as L,p as B,H as A,T as P,aW as C,x as $,F as M,K as J,L as j,Q as G,l as X,n as F,O as H,V as E,a6 as I}from"./index-is6UARFt.js";import{h as z}from"./hasRouteMatch-Bw2df_bl.js";import{I as T}from"./IconPhoto-2KIaDXXx.js";import{C as U,R as K}from"./Refresh-6IBmzTpL.js";import{K as W}from"./KeyboardArrowLeft-nUGbVivG.js";const q=[{id:"backtest",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/backtest")},{id:"live",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/live")},{id:"breakeven",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/breakeven")},{id:"risk",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/risk")},{id:"partial",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/partial")},{id:"highest_profit",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/highest_profit")},{id:"max_drawdown",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/max_drawdown")},{id:"schedule",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/schedule")},{id:"performance",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/performance")},{id:"sync",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/sync")},{id:"heat",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/heat")},{id:"strategy",element:({data:r})=>e(i,{sx:{height:"100%",width:"100%",pt:1},children:e(t,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"100%"},children:e("div",{children:[e(a,{content:r||"# Нет данных"}),e(i,{sx:{paddingBottom:"65px"}})]})})}),isActive:e=>e.includes("/markdown_report/strategy")}],Q=[{id:"backtest",label:"Backtest",isVisible:({type:e})=>"backtest"===e},{id:"live",label:"Live",isVisible:({type:e})=>"live"===e},{id:"strategy",label:"Strategy"},{id:"breakeven",label:"Breakeven"},{id:"risk",label:"Risk"},{id:"partial",label:"Partial"},{id:"highest_profit",label:"Highest Profit"},{id:"max_drawdown",label:"Max Drawdown"},{id:"schedule",label:"Schedule"},{id:"performance",label:"Performance"},{id:"sync",label:"Sync"},{id:"heat",label:"Heat"}],Y=({disabled:t,className:a,style:i,sx:c,onClick:d,color:w})=>e(l,{className:a,style:i,sx:c,disabled:t,color:w,size:36,onClick:async e=>{const[t,{resolve:a}]=o();e.preventDefault(),e.stopPropagation(),await d(e,e=>a(e));const i=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 s(String(e))})(i),n.alertService.notify("Copied!")},children:e(r,{})}),Z=[{action:"json",label:"Download JSON",icon:()=>e(p,{icon:w,color:"#4caf50"})},{action:"markdown",label:"Download Markdown",icon:()=>e(p,{icon:h,color:"#4caf50"})},{action:"pdf",label:"Download PDF",icon:()=>e(p,{icon:m,color:"#4caf50"})}],ee=({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(d,{transparent:!0,keepMounted:!0,className:a,style:i,sx:r,disabled:t,options:Z,onAction:s})},te=y(),ae=D(async(e,t)=>{const a=("backtest"===t?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(t=>t.id===e);if(!a)throw new Error(`Item not found: ${e}`);const{symbol:i,strategyName:r,exchangeName:o,frameName:l}=a,[s,c,d,w,p,h,m,k,g,b,v,y]=await Promise.all(["backtest"===t?n.markdownViewService.getBacktestReport(i,r,o,l):Promise.resolve(""),"live"===t?n.markdownViewService.getLiveReport(i,r,o):Promise.resolve(""),n.markdownViewService.getBreakevenReport(i,r,o,l,"backtest"===t),n.markdownViewService.getRiskReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPartialReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHighestProfitReport(i,r,o,l,"backtest"===t),n.markdownViewService.getMaxDrawdownReport(i,r,o,l,"backtest"===t),n.markdownViewService.getScheduleReport(i,r,o,l,"backtest"===t),n.markdownViewService.getPerformanceReport(i,r,o,l,"backtest"===t),n.markdownViewService.getSyncReport(i,r,o,l,"backtest"===t),n.markdownViewService.getHeatReport(r,o,l,"backtest"===t),n.markdownViewService.getStrategyReport(i,r,o,l,"backtest"===t)]);return{type:t,backtest:s,live:c,breakeven:d,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}`}),ie=()=>{const[t,a]=k(""),[r,o]=k("backtest"),s=g(),{push:c,pop:d}=s,[w,p]=b(te.location.pathname),h=async()=>{const e=(await ae(t.current,r.current))[w.current.replace("/markdown_report/","")];"string"==typeof e&&await V(e)},m=async()=>{const e=await ae(t.current,r.current),a=w.current.replace("/markdown_report/",""),i=e[a];if("string"==typeof i){const e=new Blob([i],{type:"text/plain"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${a}_${r.current}_${Date.now()}.md`)}},y=async()=>{const e=("backtest"===r.current?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t.current);if(!e)throw new Error(`Item not found: ${t.current}`);const{symbol:a,strategyName:i,exchangeName:o,frameName:l}=e,s=w.current.replace("/markdown_report/",""),c="backtest"===r.current;let d;if("backtest"===s?d=await n.markdownViewService.getBacktestData(a,i,o,l):"live"===s?d=await n.markdownViewService.getLiveData(a,i,o):"breakeven"===s?d=await n.markdownViewService.getBreakevenData(a,i,o,l,c):"risk"===s?d=await n.markdownViewService.getRiskData(a,i,o,l,c):"partial"===s?d=await n.markdownViewService.getPartialData(a,i,o,l,c):"highest_profit"===s?d=await n.markdownViewService.getHighestProfitData(a,i,o,l,c):"max_drawdown"===s?d=await n.markdownViewService.getMaxDrawdownData(a,i,o,l,c):"schedule"===s?d=await n.markdownViewService.getScheduleData(a,i,o,l,c):"performance"===s?d=await n.markdownViewService.getPerformanceData(a,i,o,l,c):"sync"===s?d=await n.markdownViewService.getSyncData(a,i,o,l,c):"heat"===s?d=await n.markdownViewService.getHeatData(i,o,l,c):"strategy"===s&&(d=await n.markdownViewService.getStrategyData(a,i,o,l,c)),void 0!==d){const e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);n.layoutService.downloadFile(t,`${s}_${r.current}_${Date.now()}.json`)}},{pickData:D,render:N}=v({tabs:Q,withStaticAction:!0,onTabChange:(e,t)=>{const a=`/markdown_report/${e}`;t.replace(a),p(a)},animation:"none",title:"Markdown Report",sizeRequest:u,history:te,routes:q,BeforeTitle:({onClose:t})=>{const{total:a}=g();return e(i,{sx:{mr:1,display:1===a?"none":"flex"},children:e(l,{onClick:t,children:e(_,{})})})},AfterTitle:({onClose:a})=>e(x,{direction:"row",gap:1,children:[e(l,{sx:{mr:"10px"},onClick:()=>h(),children:e(f,{})}),e(Y,{onClick:async(e,a)=>{await(async(e,t,a,i)=>{const r=("backtest"===a?await n.backtestGlobalService.list():await n.liveGlobalService.list()).find(e=>e.id===t);if(!r)throw new Error(`Item not found: ${t}`);const{symbol:o,strategyName:l,exchangeName:s,frameName:c}=r,d="backtest"===a;e.includes("/markdown_report/backtest")?i(JSON.stringify(await n.markdownViewService.getBacktestData(o,l,s,c),null,2)):e.includes("/markdown_report/live")?i(JSON.stringify(await n.markdownViewService.getLiveData(o,l,s),null,2)):e.includes("/markdown_report/breakeven")?i(JSON.stringify(await n.markdownViewService.getBreakevenData(o,l,s,c,d),null,2)):e.includes("/markdown_report/risk")?i(JSON.stringify(await n.markdownViewService.getRiskData(o,l,s,c,d),null,2)):e.includes("/markdown_report/partial")?i(JSON.stringify(await n.markdownViewService.getPartialData(o,l,s,c,d),null,2)):e.includes("/markdown_report/highest_profit")?i(JSON.stringify(await n.markdownViewService.getHighestProfitData(o,l,s,c,d),null,2)):e.includes("/markdown_report/max_drawdown")?i(JSON.stringify(await n.markdownViewService.getMaxDrawdownData(o,l,s,c,d),null,2)):e.includes("/markdown_report/schedule")?i(JSON.stringify(await n.markdownViewService.getScheduleData(o,l,s,c,d),null,2)):e.includes("/markdown_report/performance")?i(JSON.stringify(await n.markdownViewService.getPerformanceData(o,l,s,c,d),null,2)):e.includes("/markdown_report/sync")?i(JSON.stringify(await n.markdownViewService.getSyncData(o,l,s,c,d),null,2)):e.includes("/markdown_report/heat")?i(JSON.stringify(await n.markdownViewService.getHeatData(l,s,c,d),null,2)):e.includes("/markdown_report/strategy")&&i(JSON.stringify(await n.markdownViewService.getStrategyData(o,l,s,c,d),null,2))})(w.current,t.current,r.current,a)},sx:{mr:"10px",mt:"2.5px"}}),e(ee,{sx:{mr:"10px",mt:"0.5px"},onDownloadJson:y,onDownloadMarkdown:m,onDownloadPdf:h}),e(l,{onClick:a,children:e(S,{})})]}),fetchState:async()=>await ae(t.current,r.current),mapInitialData:([{type:e,backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p}])=>({backtest:t,live:a,breakeven:i,risk:r,partial:o,highest_profit:n,max_drawdown:l,schedule:s,performance:c,sync:d,heat:w,strategy:p,type:e}),mapPayload:([{type:e}])=>({type:e}),onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),onClose:()=>{d()}});return(e,t)=>{c({id:"markdown_report_modal",render:N,onInit:()=>{const e="live"===t?"/markdown_report/live":"/markdown_report/backtest";te.push(e),p(e)},onMount:()=>{a(e),o(t),D()}})}},re="backtest-kit__groupHeader",oe="backtest-kit__groupRoot",ne="backtest-kit__symbolImage",le=B()({root:{[`& .${oe}:hover .${re}`]:{opacity:"1 !important"}}});function se(e){return E(e,"#000000")>E(e,"#FFFFFF")}const ce=[{type:L.Link,action:"back-action",label:e(W,{sx:{display:"block"}})},{type:L.Link,action:"back-action",label:"Main"},{type:L.Link,action:"back-action",label:"Markdown Report"}],de=[{action:"update-now",label:"Refresh",icon:()=>e(p,{icon:K,color:"#4caf50"})}],we=(t,a)=>({type:A.Group,className:oe,sx:{p:2},tabletColumns:"12",desktopColumns:"3",fields:[{type:A.Component,className:re,style:{transition:"opacity 500ms",opacity:.5},element:()=>e(x,{direction:"row",children:[e(J,{variant:"outlined",size:"small",color:"info",label:`${j.bullet} ${t}`,sx:{mb:1,pr:.5,fontSize:"14px",background:"white",cursor:"not-allowed"}}),e(i,{flex:1})]})},{type:A.Group,fields:a.map(({symbol:t,label:a,id:i,type:r,color:o})=>((t,a,i,r,o)=>({type:A.Component,desktopColumns:"6",tabletColumns:"6",phoneColumns:"12",fieldRightMargin:"1",fieldBottomMargin:"1",element:({payload:n})=>e(H,{component:G,onClick:()=>{n.handleOpen(t,a)},sx:{width:"100%",background:o,color:"white",fontWeight:"bold",fontSize:"14px",height:"75px",minHeight:"75px",textWrap:"wrap",padding:"16px",[`& .${ne}`]:{transition:"filter 500ms"},"&:hover":{background:()=>se(o)?X(o,.33):F(o,.33),[`& .${ne}`]:{transition:"filter 500ms",filter:se(o)?"brightness(0.7) contrast(1.2)":"brightness(1.3) contrast(0.5)"}},transition:"background 500ms"},startIcon:e(T,{className:ne,symbol:i}),children:r})}))(i,r,t,a,o))}]}),pe=[{id:"main",element:()=>{const{classes:t}=le(),{reloadTrigger:a,doReload:r}=N(),[o,{loading:l}]=O(async()=>await(async()=>{const[e,t,a]=await Promise.all([n.symbolGlobalService.getSymbolMap(),n.backtestGlobalService.list(),n.liveGlobalService.list()]),i={},r={};t.forEach(t=>{const a=e[t.symbol],r=t.strategyName;i[r]||(i[r]=[]),i[r].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;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",id:t.id,type:"live"})});const o=Object.entries(i).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t)),l=Object.entries(r).sort(([,e],[,t])=>t.length-e.length).map(([e,t])=>we(e,t));return l.length||o.length?[{type:A.Fragment,isVisible:()=>!!o.length,fields:[{type:A.Line,title:"Backtest"},{type:A.Group,columns:"12",fields:o}]},{type:A.Fragment,isVisible:()=>!!l.length,fields:[{type:A.Line,title:"Live"},{type:A.Group,columns:"12",fields:l}]}]:[]})(),{onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),deps:[a]}),s=ie(),c=(e,t)=>{s(e,t)};return e(U,{children:[e(R,{items:ce,actions:de,onAction:e=>{"back-action"===e&&n.routerService.push("/"),"update-now"===e&&r()}}),l||!o?e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):o.length?e(M,{children:[e($,{className:t.root,fields:o,payload:()=>({handleOpen:c})},a),e(i,{paddingBottom:"24px"})]}):e(C,{children:e(P,{variant:"h6",sx:{opacity:.5},children:"No pending signals"})})]})},isActive:e=>z(["/report"],e)}],he=({id:t})=>e(I,{history:n.routerService,onLoadStart:()=>n.layoutService.setAppbarLoader(!0),onLoadEnd:()=>n.layoutService.setAppbarLoader(!1),routes:pe,params:{id:t}});export{he as StatusPage,he as default};