1"use strict";(self.webpackChunktrest_ai=self.webpackChunktrest_ai||[]).push([[233],{89736:(e,t,a)=>{a.d(t,{Kj:()=>h,Od:()=>d,U2:()=>u,Ue:()=>c,f1:()=>m,pb:()=>l});var s=a(12903),i=a(4886),n=a(97892),o=a.n(n),r=a(76914);async function l(e,t,a,n){let o={Success:!1,Message:"",TokenExpired:!1,Backtestings:[]};const l={Authorization:i.Z.authorization,token:e,"application-language":(0,r.lR)()};let c={};t&&(c={...c,portfolio_code:t}),a&&(c={...c,start_date:a.toISOString().slice(0,10)}),n&&(c={...c,end_date:n.toISOString().slice(0,10)});try{const e=await s.Z.post(i.Z.baseURL+"/backtesting/list",c,{headers:l});o.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(o.Message=e.data.error):(o.Success=!0,o.Backtestings=e.data.backtestings.map((e=>({code:e.backtest.code,name:e.backtest.name,portfolioCode:e.portfolio.code,portfolioName:e.portfolio.name,status:e.backtest.status,errorDetail:e.backtest.error_detail,initialValue:Number(e.backtest.initial_value),finalValue:Number(e.backtest.final_value),marketFinalValue:Number(e.backtest.market_final_value),pnl:(0,r.aQ)(e.backtest.final_value,e.backtest.initial_value),requestedDate:new Date(e.backtest.requested_date+"Z"),completedDate:new Date(e.backtest.completed_date+"Z"),startDate:new Date(e.backtest.start_date+"Z"),finishDate:new Date(e.backtest.end_date+"Z"),timePeriod:e.backtest.interval,transactions:[],initialAmounts:e.backtest.initial_amounts,algorithm:e.algorithm}))))}catch(d){o.Message="Something went wrong. Please try again later.",console.log(d)}return o}async function c(e,t){let a={Success:!1,Message:"",TokenExpired:!1,Backtesting:{}};const n={Authorization:i.Z.authorization,token:t,"application-language":(0,r.lR)()},l=e.startDate.getTimezoneOffset(),c={name:e.name,portfolio_code:e.portfolioCode,algorithm_id:e.algorithm.id,start_date:o()(e.startDate).add(l,"minute").toDate().toISOString().slice(0,19).replace("T"," "),end_date:o()(e.finishDate).add(l,"minute").toDate().toISOString().slice(0,19).replace("T"," "),interval:e.timePeriod};try{const e=await s.Z.post(i.Z.baseURL+"/backtesting/create",c,{headers:n});a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):(a.Success=!0,a.Backtesting=e.data.backtesting)}catch(d){a.Message="Something went wrong. Please try again later.",console.log(d)}return a}async function d(e,t){let a={Success:!1,Message:"",TokenExpired:!1};const n={Authorization:i.Z.authorization,token:t,"application-language":(0,r.lR)()},o={code:e};try{const e=await s.Z.post(i.Z.baseURL+"/backtesting/delete",o,{headers:n});a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):a.Success=!0}catch(l){a.Message="Something went wrong. Please try again later.",console.log(l)}return a}async function u(e,t){let a={Success:!1,Message:"",TokenExpired:!1,Backtesting:{}};const n={Authorization:i.Z.authorization,token:t,"application-language":(0,r.lR)()};try{const t=await s.Z.get(i.Z.baseURL+"/backtesting/"+e,{headers:n});a.TokenExpired=t.data.token_expired||!1,0==t.data.status?t.data.error.length>0&&(a.Message=t.data.error):(a.Success=!0,a.Backtesting={code:t.data.backtesting.code,name:t.data.backtesting.name,portfolioName:t.data.backtesting.portfolio_name,portfolioCode:t.data.backtesting.portfolio_code,status:t.data.backtesting.status,errorDetail:t.data.backtesting.error_detail,initialValue:Number(t.data.backtesting.initial_value),finalValue:Number(t.data.backtesting.final_value),marketFinalValue:Number(t.data.backtesting.market_final_value),pnl:(0,r.aQ)(t.data.backtesting.final_value,t.data.backtesting.initial_value),requestedDate:new Date(t.data.backtesting.requested_date+"Z"),completedDate:new Date(t.data.backtesting.completed_date+"Z"),startDate:new Date(t.data.backtesting.start_date+"Z"),finishDate:new Date(t.data.backtesting.end_date+"Z"),timePeriod:t.data.backtesting.interval,initialAmounts:t.data.backtesting.initial_amounts,algorithm:t.data.algorithm,transactions:[]},t.data.transactions.map((e=>{var t;null===(t=a.Backtesting.transactions)||void 0===t||t.push({type:e.type,symbol
1:e.symbol,amount:Number(e.amount),price:Number(e.price),date:new Date(e.date+"Z")})})))}catch(o){a.Message="Something went wrong. Please try again later.",console.log(o)}return a}async function m(e,t){let a={Success:!1,Message:"",TokenExpired:!1,Transactions:[]};const n={Authorization:i.Z.authorization,token:t,"application-language":(0,r.lR)()},o={code:e};try{const e=await s.Z.post(i.Z.baseURL+"/backtesting/transaction/history",o,{headers:n});a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):(a.Success=!0,e.data.transactions&&e.data.transactions.map((e=>{a.Transactions.push({type:e.type,symbol:e.symbol,amount:Number(e.amount),price:Number(e.price),date:new Date(e.date+"Z")})})))}catch(l){a.Message="Something went wrong. Please try again later.",console.log(l)}return a}async function h(e,t){let a={Success:!1,Message:"",TokenExpired:!1,History:[]};const n={Authorization:i.Z.authorization,token:t,"application-language":(0,r.lR)()},o={code:e};try{const e=await s.Z.post(i.Z.baseURL+"/backtesting/value/history",o,{headers:n});a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):(a.Success=!0,e.data&&e.data.data.map((e=>{a.History.push({amount:Number(e.total_value),date:new Date(e.date+"Z")})})))}catch(l){a.Message="Something went wrong. Please try again later.",console.log(l)}return a}},9916:(e,t,a)=>{a.d(t,{CO:()=>o,WB:()=>c,rf:()=>r,yV:()=>l});var s=a(12903),i=a(4886),n=a(76914);async function o(e,t){var a;let o={Success:!1,Message:"",TokenExpired:!1,Data:[]};const r={Authorization:null!==(a=i.Z.authorization)&&void 0!==a?a:"",token:e,"application-language":(0,n.lR)()};t&&!isNaN(t)&&t>0&&(r["Max-Risk-Score"]=t);try{await s.Z.get(i.Z.baseURL+"/snapshot/list",{headers:r}).then((e=>{o.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(o.Message=e.data.error):(o.Success=!0,o.Data=e.data.snapshot)}))}catch(l){o.Message="Something went wrong. Please try again later.",console.log(l)}return o}async function r(e){var t;let a={Success:!1,Message:"",TokenExpired:!1,Data:[]};const o={Authorization:null!==(t=i.Z.authorization)&&void 0!==t?t:"",token:e,"application-language":(0,n.lR)()};try{const e=await s.Z.get(i.Z.baseURL+"/snapshot/list/user",{headers:o});a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):(a.Success=!0,a.Data=e.data.snapshot)}catch(r){a.Message="Something went wrong. Please try again later.",console.log(r)}return a}
1async function l(e,t){let a={Success:!1,Message:"",TokenExpired:!1,Data:{}};const o={Authorization:i.Z.authorization,token:t,"application-language":(0,n.lR)()},r={asset:e};try{await s.Z.post(i.Z.baseURL+"/coin/detail",r,{headers:o}).then((e=>{a.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(a.Message=e.data.error):(a.Success=!0,a.Data.intraday=e.data.details.Intraday?{...e.data.details.Intraday,datetime:new Date(e.data.details.Intraday.datetime+"Z")}:{},a.Data.yesterday=e.data.details["1d"]?{...e.data.details["1d"],datetime:new Date(e.data.details["1d"].datetime+"Z")}:{},a.Data.week=e.data.details["7d"]?{...e.data.details["7d"],datetime:new Date(e.data.details["7d"].datetime+"Z")}:{},a.Data.month=e.data.details["30d"]?{...e.data.details["30d"],datetime:new Date(e.data.details["30d"].datetime+"Z")}:{},e.data.risk_scores?a.Data.riskScores={calculationDate:new Date(e.data.risk_scores.calc_date+"Z"),volatility:e.data.risk_scores.volatility_score,trend:e.data.risk_scores.trend_score,liquidity:e.data.risk_scores.liquidity_score,risk:e.data.risk_scores.overall_score,level:e.data.risk_scores.level}:a.Data.riskScores={calculationDate:new Date,volatility:0,trend:0,liquidity:0,risk:0,level:"N/A"})}))}catch(l){a.Message="Something went wrong. Please try again later.",console.log(l)}return a}async function c(e,t,a,o,r){let l={Success:!1,Message:"",TokenExpired:!1,Data:[]};const c={Authorization:i.Z.authorization,token:r,"application-language":(0,n.lR)()},d={asset:e,start_datetime:t.toISOString().slice(0,19).replace("T"," "),finish_datetime:a.toISOString().slice(0,19).replace("T"," "),interval:"day"===o?"1d":"hour"===o?"1h":o};try{await s.Z.post(i.Z.baseURL+"/coin/history",d,{headers:c}).then((e=>{l.TokenExpired=e.data.token_expired||!1,0==e.data.status?e.data.error.length>0&&(l.Message=e.data.error):(l.Success=!0,e.data.history.map((e=>{l.Data.push({symbol:e.asset,close:e.close,high:e.high,low:e.low,open:e.open,time:new Date(e.datetime+"Z")})})))}))}catch(u){l.Message="Something went wrong. Please try again later.",console.log(u)}return l}},86246:(e,t,a)=>{a.d(t,{$:()=>r});var s=a(30063),i=a(72791),n=a(56424),o=a(80184);const r=e=>{var t;const{id:a,chartOptions:r,series:l,showLegend:c,locale:d}=e,u=(0,i.useRef)(null),m=(0,i.useRef)(null),{darkModeStatus:h}=(0,n.Z)();return(0,i.useEffect)((()=>{if(m.current){var e,t,a,i,n,o,g,x,p,v,f,k,b,y,j,w,N,S;const L=()=>{m.current&&T.applyOptions({width:m.current.clientWidth})},P={...r,layout:{...r.layout,attributionLogo:!1},grid:{vertLines:{color:h?"#444":null===(e=r.grid)||void 0===e||null===(t=e.vertLines)||void 0===t?void 0:t.color},horzLines:{color:h?"#444":null===(a=r.grid)||void 0===a||null===(i=a.horzLines)||void 0===i?void 0:i.color}},crosshair:{...r.crosshair,mode:null!==(n=null===(o=r.crosshair)||void 0===o?void 0:o.mode)&&void 0!==n?n:s.rM.Normal,vertLine:null!==(g=null===(x=r.crosshair)||void 0===x?void 0:x.vertLine)&&void 0!==g?g:{color:"#9B7DFF",labelBackgroundColor:"#9B7DFF"},horzLine:null!==(p=null===(v=r.crosshair)||void 0===v?void 0:v.horzLine)&&void 0!==p?p:{color:"#9B7DFF",labelBackgroundColor:"#9B7DFF"}},timeScale:{borderColor:null!==(f=null===(k=r.timeScale)||void 0===k?void 0:k.borderColor)&&void 0!==f?f:"rgba(197, 203, 206, 0.8)",timeVisible:null===(b=null===(y=r.timeScale)||void 0===y?void 0:y.timeVisible)||void 0===b||b},localization:{locale:d||"en"},rightPriceScale:{borderColor:null!==(j=null===(w=r.rightPriceScale)||void 0===w?void 0:w.borderColor)&&void 0!==j?j:"rgba(197, 203, 206, 0.8)"},width:null!==(N=r.width)&&void 0!==N?N:m.current.clientWidth,height:null!==(S=r.height)&&void 0!==S?S:300};c&&u.current&&(u.current.style.position="absolute",u.current.style.left="20px",u.current.style.top="-40px",u.current.style.zIndex="1",u.current.innerHTML="");const T=(0,s.C2)(m.current,P);for(var Z=0;Z<l.length;Z++){var D,_,M=l[Z];if((_="wickDownColor"in(null!==(D=M.options)&&void 0!==D?D:[])?T.addCandlestickSeries(M.options):T.addLineSeries(M.options)).setData(M.data),M.markers&&M.markers.length>0&&_.setMarkers(M.markers),c&&u.current){var C;let e=h?"#fff":"#000";"color"in(null!==(C=M.options)&&void 0!==C?C:[])&&(e=M.options.color||e);const t=document.createElement("div");t.innerHTML=M.name,t.style.color=e,u.current.appendChild(t)}}return T.timeScale().fitContent(),window.addEventListener("resize",L),(
1)=>{window.removeEventListener("resize",L),T.remove()}}}),[r,l]),(0,o.jsx)("div",{ref:m,id:a,style:{position:"relative",height:null!==(t=r.height)&&void 0!==t?t:300},children:c&&(0,o.jsx)("div",{ref:u})},a)}},64233:(e,t,a)=>{a.d(t,{Z:()=>E});var s=a(72791),i=a(11592),n=a(56424),o=a(89736),r=a(9916),l=a(76914),c=a(98588),d=a(97892),u=a.n(d),m=a(41418),h=a.n(m),g=a(39230),x=a(13345),p=a(63542),v=a(15177),f=a(13341),k=a(96787),b=a(57689),y=a(7134),j=a(57110),w=a(4886),N=a(4010),S=a(29466),Z=a(80184);const D=e=>{const{transactions:t}=e,a=(0,b.s0)(),{darkModeStatus:i}=(0,n.Z)(),{userData:o}=(0,s.useContext)(c.ZP),{mobileDesign:r}=(0,s.useContext)(j.Z),{t:d}=(0,g.$G)(["translation","menu"]),{width:m,height:D}=(0,k.Z)(),_=m<=640,M=e=>("buy"===e||"deposit"===e?"success":"withdrawal"===e&&"danger")||"sell"===e&&"danger",[C,L]=(0,s.useState)(1),[P,T]=(0,s.useState)(f.LD[15]),{items:z,requestSort:B,getClassNamesFor:E}=(0,v.Z)(t);return(0,Z.jsxs)(x.ZP,{children:[(0,Z.jsxs)(x.Ol,{children:[(0,Z.jsx)(x.oL,{children:(0,Z.jsx)(x.ll,{tag:"div",className:"h5",children:d("Backtesting History")})}),(0,Z.jsx)(x.T$,{children:(0,Z.jsx)("div",{})})]}),(0,Z.jsx)(x.eW,{isScrollable:!0,className:h()("h-25",{"mt-1":r}),children:(0,Z.jsxs)("div",{className:"row g-4",children:[(0,Z.jsx)("div",{className:"table-responsive",children:(0,Z.jsxs)("table",{className:"table table-sm table-hover table-borderless",children:[(0,Z.jsx)("thead",{children:(0,Z.jsxs)("tr",{className:"align-items-center",children:[(0,Z.jsxs)("th",{className:"cursor-pointer text-decoration-underline text-center text-nowrap",onClick:()=>B("type"),children:[d("Type")," ",(0,Z.jsx)(p.Z,{size:"lg",className:E("type"),icon:"FilterList"})]}),(0,Z.jsxs)("th",{onClick:()=>B("symbol"),className:"cursor-pointer text-decoration-underline text-nowrap",children:[d("Coin")," ",(0,Z.jsx)(p.Z,{size:"lg",className:E("symbol"),icon:"FilterList"})]}),(0,Z.jsxs)("th",{onClick:()=>B("date"),className:"cursor-pointer text-decoration-underline text-nowrap",children:[d("Date")," ",(0,Z.jsx)(p.Z,{size:"lg",className:E("date"),icon:"FilterList"})]}),(0,Z.jsxs)("th",{onClick:()=>B("price"),className:"cursor-pointer text-decoration-underline text-end text-nowrap",children:[d("Price (USDt)")," ",(0,Z.jsx)(p.Z,{size:"lg",className:E("price"),icon:"FilterList"})]}),(0,Z.jsxs)("th",{onClick:()=>B("amount"),className:"cursor-pointer text-decoration-underline text-end text-nowrap",children:[d("Amount")," ",(0,Z.jsx)(p.Z,{size:"lg",className:E("amount"),icon:"FilterList"})]})]})}),(0,Z.jsx)("tbody",{children:(0,f.c9)(z,C,P).map(((e,t)=>(0,Z.jsxs)("tr",{className:"align-items-center",children:[(0,Z.jsx)("td",{className:"align-middle justify-content-center text-nowrap",children:(0,Z.jsx)("div",{className:h()("bg-l".concat(i?"o25":"10","-").concat(M(e.type)," text-").concat(M(e.type)," rounded-pill me-3 text-capitalize text-center ").concat(_?"fs-6":"fw-bold")),children:d(e.type)})}),(0,Z.jsxs)("td",{className:"align-middle text-nowrap cursor-pointer",onClick:()=>a("../".concat(y.q_.coin.path,"/").concat(e.symbol)),children:[(0,Z.jsx)(N.Z,{className:"rounded-circle me-2",width:16,height:16,src:"".concat(w.Z.cdnServer,"/img/coins/64x64/").concat(e.symbol,".png"),alternateSrc:S.Z},"ci_".concat(e.symbol,"_").concat(t)),(0,Z.jsx)("u",{children:e.symbol})]}),(0,Z.jsx)("td",{className:"align-middle text-nowrap",children:u()(e.date).format("lll")}),(0,Z.jsxs)("td",{className:"text-end align-middle text-nowrap",children:["$",(0,l.xG)(e.price,8,!0)]}),(0,Z.jsx)("td",{className:"text-end align-middle text-nowrap",children:(0,l.xG)(e.amount,8,!0)})]},"tr_".concat(t))))})]})}),t.length>5&&(0,Z.jsx)(f.ZP,{data:z,label:"",setCurrentPage:L,currentPage:C,perPage:P,setPerPage:T,showPerPage:!r})]})})]})};var _=a(54452),M=a(30063),C=a(86246),L=a(46433);const P=e=>{const{lineSeries:t}=e,{darkModeStatus:a}=(0,n.Z)(),{mobileDesign:i}=(0,s.useContext)(j.Z),{userData:o}=(0,s.useContext)(c.ZP),{t:r}=(0,g.$G)("translation"),d=[],m={height:200,layout:{background:{type:M.Mr.Solid,color:"transparent"},textColor:a?"white":"black"},localization:{timeFormatter:e=>u().unix(e).format("LLL")}},p={color:"#4d69fa"};for(var v=0;v<t.length;v++){const e=[],a=[];t[v].transactions.map((e=>{a.push({time:u()(e.date).unix(),position:"buy"==e.type?"belowBar":"aboveBar",color:"buy"==e.type?"#46bcaa":"#f35421",shape:"buy"==e.type?"arrowUp":"arrowDown",text:"".concat(e.type[0].toUpperCase()+e.type.slice(1))})}));var f="";t[v].assetPriceHistories.priceHistory.map((a=>{f=t[v].assetPriceHistories.symbol,e.push({time:u()(a.time).unix(),value:a.close})}));const s=Math.min(...t[v].assetPriceHistories.priceHistory.map((e=>e.close))),i=s>100?.01:s>1?1e-4:1e-8,n=s>100?2:s>1?4:8;p.priceFormat={type:"custom",minMove:i,formatter:e=>(0,l.xG)(e,n,!0)},d.push({name:f,data:e,markers:a,options:p})}return(0,Z.jsxs)(x.ZP,{children:[(0,Z.jsxs)(x.Ol,{children:[(0,Z.jsx)(x.oL,{children:(0,Z.jsx)(x.ll,{tag:"div",className:"h5",children:r("Buy/Sell Action Charts")})}),(0,Z.jsx)(x.T$,{children:(0,Z.jsx)("div",{})})]}),(0,Z.jsx)(x.eW,{className:h()({"px-0":i}),children:d&&d.length>0?d.map(((e,t)=>(0,Z.jsxs)("div",{className:"mt-3",children:[(0,Z.jsxs)("div",{className:"h4",children:[(0,Z.jsx)(N.Z,{className:"rounded-circle me-3",width:32,height:32,src:"".concat(w.Z.cdnServer,"/img/coins/64x64/").concat(e.name,".png"),alternateSrc:S.Z},"ci_".concat(e.name,"_").concat(t)),e.name," ",r("Actions")]}),(0,Z.jsx)(C.$,{id:"tvc_".concat(t),series:[e],chartOptions:m,showLegend:!1,locale:o.language})]},"dvc_".concat(t)))):(0,Z.jsx)("div",{className:"position-relative",style:{height:300},children:(0,Z.jsx)(L.Z,{color:"primary",inButton:"onlyIcon",className:"position-absolute top-50 start-50"})})})]})};var T=a(93666),z=a.n(T);const B=e=>{const{lineSeries:t,coinInitialValues:a,valuationHistory:i}=e,{darkModeStatus:o}=(0,n.Z)(),{mobileDesign:r}=(0,s.useContext)(j.Z),{userData:d}=(0,s.useContext)(c.ZP),{t:m}
1=(0,g.$G)("translation"),[p,v]=(0,s.useState)(!1),[f,k]=(0,s.useState)([]),b=[],y={height:200,layout:{background:{type:M.Mr.Solid,color:"transparent"},textColor:o?"white":"black"},localization:{timeFormatter:e=>u().unix(e).format("LLL")}};let w=!1;return(0,s.useEffect)((()=>(w||((()=>{let e=0;const s=[],n=a.find((e=>"USDT"===e.symbol&&e.amount>0));n&&(e=n.amount);for(let i=0;i<t.length;i++){let n=0;const o=t[i].assetPriceHistories.symbol,r=a.find((e=>e.symbol===o&&e.amount>0));r&&(n=r.amount),t[i].assetPriceHistories.priceHistory.map((t=>{let a=t.close*n;0==i&&e>0&&(a+=e);const o=u()(t.time).unix(),r=s.findIndex((e=>e.time===o));r>=0?s[r].value+=a:s.push({time:o,value:a})}))}const o=Math.min(...s.map((e=>e.value))),r=o>100?.01:o>1?1e-4:1e-8,c=o>100?2:o>1?4:8;b.push({name:m("Market Value"),data:s,options:{color:"#4d69fa",priceFormat:{type:"custom",minMove:r,formatter:e=>(0,l.xG)(e,c,!0)}}}),b.push({name:m("Portfolio Value"),data:i.map((e=>({time:u()(e.date).unix(),value:e.amount}))),options:{color:"#ff00ff",priceFormat:{type:"custom",minMove:r,formatter:e=>(0,l.xG)(e,c,!0)}}}),k(b)})(),v(!0)),()=>{w=!0})),[]),(0,Z.jsxs)(x.ZP,{children:[(0,Z.jsxs)(x.Ol,{children:[(0,Z.jsx)(x.oL,{children:(0,Z.jsx)(x.ll,{tag:"div",className:"h5",children:m("Portfolio vs Market Performance")})}),(0,Z.jsx)(x.T$,{children:(0,Z.jsx)("div",{})})]}),(0,Z.jsx)(x.eW,{className:h()({"px-0":r}),children:p?(0,Z.jsx)("div",{className:"mt-3",children:(0,Z.jsx)(C.$,{id:"tvBTPerfChart",series:f,chartOptions:y,showLegend:!0,locale:d.language})},"dvPerfContainer"):(0,Z.jsx)("div",{className:"position-relative",style:{height:300},children:(0,Z.jsx)(L.Z,{color:"primary",inButton:"onlyIcon",className:"position-absolute top-50 start-50"})})})]})},E=e=>{var t;const{backtesting:a,assets:d,handleListClicked:m}=e,h=(0,b.s0)(),{darkModeStatus:v}=(0,n.Z)(),{userData:f}=(0,s.useContext)(c.ZP),{t:k}=(0,g.$G)("translation"),[j,w]=(0,s.useState)(0),[N,S]=(0,s.useState)(0),[M,C]=(0,s.useState)(0),[T,E]=(0,s.useState)(""),[O,R]=(0,s.use
1State)(""),[F,I]=(0,s.useState)(!1),[V,A]=(0,s.useState)(a.transactions||[]),[H,U]=(0,s.useState)([]),[$,q]=(0,s.useState)([]),[G,W]=(0,s.useState)([d.filter((e=>"USDT"!==e)).length,0]),Y=()=>{o.Kj(a.code,f.token||"").then((e=>{if(e.Success)U(e.History.sort(((e,t)=>e.date.valueOf()-t.date.valueOf()))),I(!0);else{if(e.TokenExpired)return void h("../../".concat(y.jt.login.path));console.log(e.Message)}}))};let K=!1;(0,s.useEffect)((()=>(F||K||(async()=>{var e;let t=[];if(0==(null===(e=a.transactions)||void 0===e?void 0:e.length)){const e=await o.f1(a.code,f.token||"");if(e.Success)t=e.Transactions;else{if(e.TokenExpired)return void h("../../".concat(y.jt.login.path));console.log(e.Message)}}else t=a.transactions||[];A([...t].sort(((e,t)=>e.date.valueOf()-t.date.valueOf()))),Y()})(),()=>{K=!0})),[F]);let Q=!1;(0,s.useEffect)((()=>(!Q&&F&&d.map((e=>{"USDT"!=e&&(async e=>{try{const t=await(0,r.WB)(e,a.startDate,a.finishDate,a.timePeriod,f.token||"");return t.Success?{symbol:e,priceHistory:t.Data.sort(((e,t)=>e.time.valueOf()-t.time.valueOf())).slice(0,-1)}:(console.error(t.Message),{symbol:e,priceHistory:[]})}catch(t){return console.error("Error fetching coin history:",t),{symbol:e,priceHistory:[]}}})(e).then((t=>{let a={transactions:V.filter((t=>t.symbol===e)).sort(((e,t)=>e.date.valueOf()-t.date.valueOf())),assetPriceHistories:t};W([G[0],++G[1]]),q((e=>[...e,a]))}))})),()=>{Q=!0})),[F]);let X=!1;(0,s.useEffect)((()=>{if(!X){u().extend(z());let e=(a.finalValue||0)-(a.initialValue||0),t=a.initialValue?e/a.initialValue*100:0,s=(a.marketFinalValue||0)-(a.initialValue||0),i=a.initialValue?s/a.initialValue*100:0,n="1h"===a.timePeriod?k("{{hour}} dhours",{hour:u()(a.finishDate).diff(a.startDate,"h")}):k("{{day}} days",{day:u()(a.finishDate).diff(a.startDate,"d")}),o=u().duration(u()(a.completedDate).diff(u()(a.requestedDate))).asSeconds();w(e),S(t),C(i),E(n),R(o>1?k("{{doneInSec}} seconds",{doneInSec:o}):k("1 second"))}return()=>{X=!0}}),[]);const J=e=>V.filter((t=>!e||t.type===e)).length;return(0,Z.jsxs)(x.ZP,{stretch:!0,children:[(0,Z.jsxs)(x.Ol,{children:[(0,Z.jsxs)(x.oL,{icon:"Timeline",iconColor:"info",children:[(0,Z.jsx)(x.ll,{tag:"div",className:"h5",children:"".concat(a.name)}),(0,Z.jsxs)(x.md,{onClick:()=>h("../".concat(y.q_.portfolio.path,"/").concat(a.portfolioCode)),className:"cursor-pointer lh-sm",children:[k("Strategy"),": ",(0,Z.jsx)("b",{children:null===(t=a.algorithm)||void 0===t?void 0:t.name}),(0,Z.jsx)("br",{}),k("Portfolio"),": ",(0,Z.jsx)("b",{className:"text-decoration-underline",children:a.portfolioName})]})]}),(0,Z.jsx)(x.T$,{children:(0,Z.jsx)(i.Z,{color:"info",icon:"ArrowBack",isLink:!0,onClick:()=>{"function"===typeof m&&m(!0)},children:k("Back To List")})})]}),(0,Z.jsxs)(x.eW,{className:"px-0",children:[(0,Z.jsx)(x.ZP,{children:(0,Z.jsx)(x.eW,{children:(0,Z.jsxs)("div",{className:"row g-4 align-items-center",children:[(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:j>=0?"TrendingUp":"TrendingDown",size:"3x",color:j>=0?"success":"danger"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k(j<0?"Loss Amount":"Profit Amount")}),(0,Z.jsx)("div",{className:"fw-bold fs-3 mb-0",children:(0,l.XY)(j)}),(0,Z.jsxs)("div",{className:"text-muted mt-n2",children:[k("Over starting amount")," ",(0,Z.jsxs)("b",{children:["$",(0,l.xG)(a.initialValue||0,2)]})]})]})]})}),(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:j>=0?"TrendingUp":"TrendingDown",size:"3x",color:j>=0?"success":"danger"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k(j<0?"Loss Rating":"Profit Rating")}),(0,Z.jsxs)("div",{className:"fw-bold fs-3 mb-0",children:[N.toFixed(2),"%"]}),(0,Z.jsxs)("div",{className:"text-muted mt-n2",children:[k("Versus compound market change")," ",(0,Z.jsxs)("b",{children:[M.toFixed(2),"%"]})]})]})]})}),(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:"SwapHorizontalCircle",size:"3x",color:"success"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k("Buy Actions")}),(0,Z.jsx)("div",{className:"fw-bold fs-3 mb-0",children:J("buy")}),(0,Z.jsxs)("div",{className:"text-muted mt-n2 truncate-line-1",children:[k("In total")," ",J()," ",k("actions")]})]})]})}),(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:"SwapHorizontalCircle",size:"3x",color:"danger"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k("Sell Actions")}),(0,Z.jsx)("div",{className:"fw-bold fs-3 mb-0",children:J("sell")}),(0,Z.jsxs)("div",{className:"text-muted mt-n2 truncate-line-1",children:[k("In total")," ",J()," ",k("actions")]})]})]})}),(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:"CalendarToday",size:"3x",color:"secondary"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k("Backtesting Duration")}),(0,Z.jsx)("div",{className:"fw-bold fs-3 mb-0",children:T}),(0,Z.jsxs)("div",{className:"text-muted mt-n2",children:[k("Between")," ",u()(a.startDate).format("MMMM D, YYYY")," ",k("and")," ",u()(a.finishDate).format("MMMM D, YYYY")]})]})]})}),(0,Z.jsx)("div",{className:"col-xl-6",children:(0,Z.jsxs)("div",{className:"d-flex align-items-center bg-l".concat(v?"o25":"10","-primary rounded-2 p-3"),children:[(0,Z.jsx)("div",{className:"flex-shrink-0",children:(0,Z.jsx)(p.Z,{icon:"Timer",size:"3x",color:"secondary"})}),(0,Z.jsxs)("div",{className:"flex-grow-1 ms-3",children:[(0,Z.jsx)("div",{className:"text-muted mt-n2",children:k("Backtesting Status")}),(0,Z.jsx)("div",{className:"fw-bold fs-3 mb-0 text-capitalize",children:a.status}),(0,Z.jsx)("div",{className:"text-muted mt-n2",children:a.completedDate?k("On {{date}} in {{doneInSec}}",{date:u()(a.completedDate).format("LLL"),doneInSec:O}):""})]})]})})]})})}),G[0]==G[1]&&G[1]==$.length?(0,Z.jsxs)("div",{className:"row",children:[(0,Z.jsx)("div",{children:(0,Z.jsx)(B,{lineSeries:$,coinInitialValues:a.initialAmounts||[],valuationHistory:H})}),(0,Z.jsx)("div",{children:(0,Z.jsx)(P,{lineSeries:$})})]}):(0,Z.jsx)("div",{className:"position-relative",style:{height:300},children:(0,Z.jsx)(L.Z,{color:"primary",inButton:"onlyIcon",className:"position-absolute top-50 start-50"})}),(0,Z.jsx)(D,{transactions:V||[]},"bttr_".concat(a.code))]}
1),(0,Z.jsxs)(x.iR,{className:"position-relative",children:[(0,Z.jsx)(x.gn,{className:"position-absolute start-0",children:(0,Z.jsx)(i.Z,{color:"info",isLink:!0,onClick:()=>{"function"===typeof m&&m()},children:k("Cancel")})}),(0,Z.jsx)(x.M3,{className:"position-absolute end-0",children:(0,Z.jsx)(i.Z,{icon:"Delete",color:"danger",isOutline:!0,onClick:()=>{o.Od(a.code,f.token||"").then((e=>{e.Success?((0,_.Z)((0,Z.jsxs)("span",{className:"d-flex align-items-center",children:[(0,Z.jsx)(p.Z,{icon:"Info",size:"lg",className:"me-1"}),(0,Z.jsx)("span",{children:k("Removed successfully")})]}),k("Backtesting removed successfully"),"Success"),m(!0)):((0,_.Z)((0,Z.jsxs)("span",{className:"d-flex align-items-center",children:[(0,Z.jsx)(p.Z,{icon:"Info",size:"lg",className:"me-1"}),(0,Z.jsx)("span",{children:k("Something went wrong")})]}),k("Could not remove backtesting. Please try again."),"Danger"),console.log(e.Message))}))},children:k("Delete Backtesting")})})]}),(0,Z.jsxs)("div",{className:"text-end disclaimer-footer",children:[k("Charts by")," ",(0,Z.jsx)("a",{href:"https://www.tradingview.com/",target:"_blank",children:"TradingView"})]})]})}}}]); 2//# sourceMappingURL=233.c17c33ab.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.