@backtest-kit/ui 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +30 -2
- package/build/index.mjs +30 -2
- package/build/modules/frontend/build/assets/index-BjHVzUVO.js +1 -0
- package/build/modules/frontend/build/assets/{index-CAek6PLo.js → index-CHpWEHVB.js} +9 -9
- package/build/modules/frontend/build/assets/{markdownit-CDD90XQe.js → markdownit-Bg4a7DMF.js} +1 -1
- package/build/modules/frontend/build/index.html +1 -1
- package/package.json +5 -3
- package/build/modules/frontend/build/assets/index-BquwQyZm.js +0 -1
package/build/index.cjs
CHANGED
|
@@ -395,14 +395,42 @@ class StorageViewService {
|
|
|
395
395
|
if (CC_ENABLE_MOCK) {
|
|
396
396
|
return await this.storageMockService.listSignalLive();
|
|
397
397
|
}
|
|
398
|
-
|
|
398
|
+
const signalList = await backtestKit.Storage.listSignalLive();
|
|
399
|
+
signalList.sort((a, b) => {
|
|
400
|
+
const aHasTime = "createdAt" in a;
|
|
401
|
+
const bHasTime = "createdAt" in b;
|
|
402
|
+
if (!aHasTime && bHasTime) {
|
|
403
|
+
return -1;
|
|
404
|
+
}
|
|
405
|
+
if (aHasTime && !bHasTime) {
|
|
406
|
+
return 1;
|
|
407
|
+
}
|
|
408
|
+
const aTime = aHasTime ? a.createdAt : 0;
|
|
409
|
+
const bTime = bHasTime ? b.createdAt : 0;
|
|
410
|
+
return bTime - aTime;
|
|
411
|
+
});
|
|
412
|
+
return signalList;
|
|
399
413
|
};
|
|
400
414
|
this.listSignalBacktest = async () => {
|
|
401
415
|
this.loggerService.log("storageViewService listSignalBacktest");
|
|
402
416
|
if (CC_ENABLE_MOCK) {
|
|
403
417
|
return await this.storageMockService.listSignalBacktest();
|
|
404
418
|
}
|
|
405
|
-
|
|
419
|
+
const signalList = await backtestKit.Storage.listSignalBacktest();
|
|
420
|
+
signalList.sort((a, b) => {
|
|
421
|
+
const aHasTime = "createdAt" in a;
|
|
422
|
+
const bHasTime = "createdAt" in b;
|
|
423
|
+
if (!aHasTime && bHasTime) {
|
|
424
|
+
return -1;
|
|
425
|
+
}
|
|
426
|
+
if (aHasTime && !bHasTime) {
|
|
427
|
+
return 1;
|
|
428
|
+
}
|
|
429
|
+
const aTime = aHasTime ? a.createdAt : 0;
|
|
430
|
+
const bTime = bHasTime ? b.createdAt : 0;
|
|
431
|
+
return bTime - aTime;
|
|
432
|
+
});
|
|
433
|
+
return signalList;
|
|
406
434
|
};
|
|
407
435
|
this.init = functoolsKit.singleshot(async () => {
|
|
408
436
|
this.loggerService.log("storageViewService init");
|
package/build/index.mjs
CHANGED
|
@@ -392,14 +392,42 @@ class StorageViewService {
|
|
|
392
392
|
if (CC_ENABLE_MOCK) {
|
|
393
393
|
return await this.storageMockService.listSignalLive();
|
|
394
394
|
}
|
|
395
|
-
|
|
395
|
+
const signalList = await Storage.listSignalLive();
|
|
396
|
+
signalList.sort((a, b) => {
|
|
397
|
+
const aHasTime = "createdAt" in a;
|
|
398
|
+
const bHasTime = "createdAt" in b;
|
|
399
|
+
if (!aHasTime && bHasTime) {
|
|
400
|
+
return -1;
|
|
401
|
+
}
|
|
402
|
+
if (aHasTime && !bHasTime) {
|
|
403
|
+
return 1;
|
|
404
|
+
}
|
|
405
|
+
const aTime = aHasTime ? a.createdAt : 0;
|
|
406
|
+
const bTime = bHasTime ? b.createdAt : 0;
|
|
407
|
+
return bTime - aTime;
|
|
408
|
+
});
|
|
409
|
+
return signalList;
|
|
396
410
|
};
|
|
397
411
|
this.listSignalBacktest = async () => {
|
|
398
412
|
this.loggerService.log("storageViewService listSignalBacktest");
|
|
399
413
|
if (CC_ENABLE_MOCK) {
|
|
400
414
|
return await this.storageMockService.listSignalBacktest();
|
|
401
415
|
}
|
|
402
|
-
|
|
416
|
+
const signalList = await Storage.listSignalBacktest();
|
|
417
|
+
signalList.sort((a, b) => {
|
|
418
|
+
const aHasTime = "createdAt" in a;
|
|
419
|
+
const bHasTime = "createdAt" in b;
|
|
420
|
+
if (!aHasTime && bHasTime) {
|
|
421
|
+
return -1;
|
|
422
|
+
}
|
|
423
|
+
if (aHasTime && !bHasTime) {
|
|
424
|
+
return 1;
|
|
425
|
+
}
|
|
426
|
+
const aTime = aHasTime ? a.createdAt : 0;
|
|
427
|
+
const bTime = bHasTime ? b.createdAt : 0;
|
|
428
|
+
return bTime - aTime;
|
|
429
|
+
});
|
|
430
|
+
return signalList;
|
|
403
431
|
};
|
|
404
432
|
this.init = singleshot(async () => {
|
|
405
433
|
this.loggerService.log("storageViewService init");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,_ as t,r as a,a as n,f as i,b as o,d as s,u as r,e as l,g as d,h as c,i as p,s as u,j as h,k as m,Z as b,q as g,I as x,D as y,l as v,B as f,J as k,m as w,n as S,z as W,X as R,R as L,L as C,o as $,p as G,T as M,v as N,t as j,w as F,x as T,y as P,A,C as O,E as B,F as D,G as z,H as E,S as I,K as H,M as V}from"./index-CHpWEHVB.js";const _=e(),J=["className","component","disableGutters","fixed","maxWidth","classes"],U=d(),X=_("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${s(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),q=e=>r({props:e,name:"MuiContainer",defaultTheme:U});const K=function(e={}){const{createStyledComponent:r=X,useThemeProps:d=q,componentName:p="MuiContainer"}=e,u=r(({theme:e,ownerState:a})=>t({width:"100%",marginLeft:"auto",boxSizing:"border-box",marginRight:"auto",display:"block"},!a.disableGutters&&{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up("sm")]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}),({theme:e,ownerState:t})=>t.fixed&&Object.keys(e.breakpoints.values).reduce((t,a)=>{const n=a,i=e.breakpoints.values[n];return 0!==i&&(t[e.breakpoints.up(n)]={maxWidth:`${i}${e.breakpoints.unit}`}),t},{}),({theme:e,ownerState:a})=>t({},"xs"===a.maxWidth&&{[e.breakpoints.up("xs")]:{maxWidth:Math.max(e.breakpoints.values.xs,444)}},a.maxWidth&&"xs"!==a.maxWidth&&{[e.breakpoints.up(a.maxWidth)]:{maxWidth:`${e.breakpoints.values[a.maxWidth]}${e.breakpoints.unit}`}}));return a.forwardRef(function(e,a){const r=d(e),{className:h,component:m="div",disableGutters:b=!1,fixed:g=!1,maxWidth:x="lg"}=r,y=n(r,J),v=t({},r,{component:m,disableGutters:b,fixed:g,maxWidth:x}),f=((e,t)=>{const{classes:a,fixed:n,disableGutters:i,maxWidth:o}=e,r={root:["root",o&&`maxWidth${s(String(o))}`,n&&"fixed",i&&"disableGutters"]};return l(r,e=>c(t,e),a)})(v,p);return i(u,t({as:m,ownerState:v,className:o(f.root,h),ref:a},y))})}({createStyledComponent:u("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,t[`maxWidth${s(String(a.maxWidth))}`],a.fixed&&t.fixed,a.disableGutters&&t.disableGutters]}}),useThemeProps:e=>p({props:e,name:"MuiContainer"})}),Y=h(i("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),"Refresh"),Z=new m,Q=[{type:b.Link,action:"back-action",label:"Main"},{type:b.Link,action:"back-action",label:"Dashboard"}],ee=[{action:"update-now",label:"Refresh",icon:()=>i(x,{icon:Y,color:"#4caf50"})},{divider:!0},{action:"download-action",label:"Download",icon:()=>i(x,{icon:y,color:"#4caf50"})}],te=()=>i(g,{items:Q,actions:ee,onAction:Z.next}),ae=({className:e,symbol:t,style:a,sx:n})=>i(k,{children:async()=>{try{const o=(await v.symbolGlobalService.getSymbolMap())[t],s=null==o?void 0:o.icon,r=(null==o?void 0:o.color)||"#ccc";return i(f,{className:e,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:s?"transparent":r,...n},style:a,children:s?i("img",{loading:"lazy",crossOrigin:"anonymous",src:s,alt:t,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"},onError:e=>{const t=e.target,a=t.parentElement;a&&(a.style.background=r,t.style.display="none")}}):i(f,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}catch(o){return i(f,{className:e,sx:{position:"relative",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"#ccc",...n},style:a,children:i(f,{sx:{width:"60%",height:"60%",borderRadius:"50%",backgroundColor:"rgba(255, 255, 255, 0.2)"}})})}}});const ne=({data:{type:e},setLoading:t})=>{const{elementRef:a,size:n}=w({closest:".MuiContainer-root",compute:e=>(e.height-=150,e)}),[o,{loading:s,execute:r}]=S(async()=>"live"===e?await v.storageViewService.listSignalLive():await v.storageViewService.listSignalBacktest(),{onLoadStart:()=>t(!0),onLoadEnd:()=>t(!1),deps:[e]}),l=W(o),d=W(e);R(()=>Z.subscribe(e=>{if("update-now"===e&&r(),"download-action"===e){const e=new Blob([JSON.stringify(l.current,null,2)],{type:"application/json"}),t=URL.createObjectURL(e);v.layoutService.downloadFile(t,`signals_${d.current}_${Date.now()}.json`)}}));const c=L.useMemo(()=>o?o.reduce((e,t)=>(e[t.symbol]||(e[t.symbol]=[]),e[t.symbol].push(t),e),{}):{},[o]),p=e=>{const t=c[e]||[];return t.length?i(E,{children:t.map((t,a)=>{return i(A,{sx:{background:e=>a%2==1?B(e.palette.getContrastText(e.palette.background.paper),.02):void 0},onClick:()=>v.layoutService.pickSignal(t.id),children:[i($,{primary:i(f,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center"},children:[i(M,{variant:"body2",component:"span",sx:{fontWeight:"bold",px:1,py:.5,borderRadius:1,background:"long"===t.position?"#1976D2":"#F57C00",color:"white"},children:"long"===t.position?"LONG":"SHORT"}),i(M,{variant:"body2",component:"span",sx:{fontWeight:"medium"},children:[i(f,{component:"span",sx:{color:"text.secondary",mr:.5},children:"Entry:"}),O(t.priceOpen),"$"]}),i(M,{variant:"body2",component:"span",sx:{fontWeight:"medium",color:"success.main"},children:[i(f,{component:"span",sx:{color:"text.secondary",mr:.5},children:"TP:"}),O(t.priceTakeProfit),"$"]}),i(M,{variant:"body2",component:"span",sx:{fontWeight:"medium",color:"error.main"},children:[i(f,{component:"span",sx:{color:"text.secondary",mr:.5},children:"SL:"}),O(t.priceStopLoss),"$"]}),"pnl"in t&&i(M,{variant:"body2",component:"span",sx:{fontWeight:"bold",px:1,py:.5,borderRadius:1,background:t.pnl.pnlPercentage>=0?B("#4caf50",.15):B("#f44336",.15),color:t.pnl.pnlPercentage>=0?"#2e7d32":"#c62828"},children:["PNL: ",t.pnl.pnlPercentage>=0?"+":"",t.pnl.pnlPercentage.toFixed(2),"%"]}),i(M,{variant:"caption",component:"span",sx:{px:1,py:.25,borderRadius:.5,background:"opened"===t.status?B("#4caf50",.2):"scheduled"===t.status?B("#ff9800",.2):"closed"===t.status?B("#9e9e9e",.2):B("#f44336",.2),color:"opened"===t.status?"#2e7d32":"scheduled"===t.status?"#e65100":"closed"===t.status?"#616161":"#c62828"},children:t.status})]}),secondary:i(M,{pt:.5,variant:"subtitle2",sx:{opacity:.5},children:(n=t.createdAt||t.pendingAt,new Date(n).toLocaleString([],{year:"numeric",month:"numeric",day:"numeric",hourCycle:"h24",hour:"2-digit",minute:"2-digit",second:"2-digit"}))})}),i(D,{disableRipple:!0,children:i(z,{})})]},`item-${e}-${t.id}`);var n})}):i(C,{children:i($,{sx:{"& .MuiTypography-body2":{maxWidth:"435px"}},primary:"Нет сигналов",secondary:"Сигналы будут отображены здесь после появления"})})};return s?null:i(T,{ref:a,sx:{width:"100%",maxHeight:n.height,overflowX:"hidden",overflowY:"auto",scrollbarWidth:"thin",bgcolor:"background.paper",position:"relative","& ul":{padding:0}},subheader:i("li",{}),children:i(k,{deps:[c],children:async()=>{const t=Object.keys(c),a=await v.symbolGlobalService.getSymbolMap();return t.length?t.map(e=>{var t,n,o;const s=null==(t=a[e])?void 0:t.color,r=(null==(n=c[e])?void 0:n.length)||0;return i("li",{children:i("ul",{children:[i(G,{sx:{background:(l=s,P(l,"#000000")>P(l,"#FFFFFF")?j(s,.1):F(s,.1)),color:"white !important",zIndex:9,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i(f,{sx:{position:"relative",paddingRight:"8px"},children:i(ae,{symbol:e})}),(null==(o=a[e])?void 0:o.displayName)||e,i(f,{flex:1}),i(M,{variant:"body2",sx:{fontWeight:"medium"},children:N(r,{one:"Signal",two:"Signals",many:"Signals"})})]}),i(f,{sx:{marginTop:"16px",marginBottom:"16px"},children:p(e)})]})},`section-${e}`);var l}):i(C,{children:i($,{primary:"No signals yet",secondary:"live"===e?"Live signals will be displayed here":"Backtest signals will be displayed here"})})}})})},ie=()=>i(I,{children:"\n body {\n background-color: #ddd !important;\n }\n "}),oe=V(),se=(e,t)=>e.some(e=>e.includes(t)),re=[{id:"backtest",element:ne,isActive:e=>se(["/backtest"],e)},{id:"live",element:ne,isActive:e=>se(["/live"],e)}],le=[{id:"backtest",label:"Backtest"},{id:"live",label:"Live"}],de=({symbol:e})=>{R(()=>oe.replace("/backtest"));return i(K,{children:[i(H,{withScroll:!0,sx:{height:"calc(100vh - 105px)"},BeforePaper:te,onLoadStart:()=>v.layoutService.setAppbarLoader(!0),onLoadEnd:()=>v.layoutService.setAppbarLoader(!1),routes:re,tabs:le,history:oe,initialData:()=>({backtest:{type:"backtest"},live:{type:"live"}}),payload:()=>({symbol:e}),onTabChange:(e,t)=>{"backtest"===e&&t.replace("/backtest"),"live"===e&&t.replace("/live")}}),i(ie,{})]})};export{de as MainPage,de as default};
|