1/*! For license information please see 712.df2067af.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[712],{73062(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]])},76245(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},80712(e,t,s){s.r(t),s.d(t,{default:()=>A});var a=s(65043),l=s(45685),n=s(69284),i=s(79722),c=s(27033),r=s(76245),d=s(22024),o=s(34537),x=s(65469),m=s(73062),h=s(50516),p=s(23165),u=s(63507),g=s(20073),b=s(13390),j=s(70579);function v(e){if(!e)return"";return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function N(e){if(!e)return"";return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function f(e){let{label:t,value:s,sub:a,icon:l,color:n="text-white"}=e;return(0,j.jsxs)("div",{className:"bg-slate-900/70 border border-white/10 rounded-xl p-4","data-testid":"metric-".concat(t.toLowerCase().replace(/\s/g,"-")),children:[(0,j.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[l&&(0,j.jsx)(l,{className:"w-4 h-4 ".concat(n)}),(0,j.jsx)("span",{className:"text-xs text-slate-500 uppercase tracking-wider",children:t})]}),(0,j.jsx)("p",{className:"text-xl font-mono font-bold ".concat(n),children:s}),a&&(0,j.jsx)("p",{className:"text-xs text-slate-500 mt-0.5",children:a})]})}function y(e){let{data:t}=e;if(!t||0===t.length)return(0,j.jsx)("p",{className:"text-sm text-slate-500",children:"No P&L history yet"});const s=Math.max(...t.map(e=>Math.abs(e.pnl)),.01);return(0,j.jsx)("div",{className:"flex items-end gap-1 h-32",children:t.slice(-30).map((e,t)=>{const a=Math.max(4,Math.abs(e.pnl)/s*100),l=e.pnl>=0;return(0,j.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-end h-full group relative",children:[(0,j.jsxs)("div",{className:"hidden group-hover:block absolute -top-8 bg-slate-800 text-xs text-white px-2 py-1 rounded z-10 whitespace-nowrap",children:[e.date,": $",e.pnl>0?"+":"",e.pnl.toFixed(2)]}),(0,j.jsx)("div",{className:"w-full rounded-sm transition-all ".concat(l?"bg-emerald-500/80":"bg-red-500/80"),style:{height:"".concat(a,"%")}})]},t)})})}function w(e){return e.closed?{label:"CLOSED",color:"text-slate-400 bg-slate-700/50"}:"buy"===e.side||"BUY"===e.side?(e.avg_down_count||0)>=5?{label:"MAXED",color:"text-amber-400 bg-amber-500/20"}:(e.avg_down_count||0)>0?{label:"AVG DOWN",color:"text-blue-400 bg-blue-500/20"}:{label:"OPEN",color:"text-cyan-400 bg-cyan-500/20"}:"sell"===e.side||"SELL"===e.side?null!=e.pnl&&0!==e.pnl?{label:"CLOSED",color:"text-slate-400 bg-slate-700/50"}:{label:"OPEN",color:"text-cyan-400 bg-cyan-500/20"}:{label:"PENDING",color:"text-slate-400 bg-slate-700/50"}}function _(e){return e.per_trade_amount||(e.avg_down_count>0?e.trade_amount/(e.avg_down_count+1):e.trade_amount)}function A(){var e;const{botId:t}=(0,l.g)(),s=(0,l.Zp)(),[A,k]=(0,a.useState)(null),[L,S]=(0,a.useState)(!0),[D,P]=(0,a.useState)(null),C=localStorage.getItem("token"),E=(0,a.useCallback)(async()=>{try{const e=await i.A.get("".concat(n.nC,"/bots/").concat(t,"/performance"),{headers:{Authorization:"Bearer ".concat(C)}});k(e.data),P(null)}catch(a){var e,s;P((null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to load bot performance")}finally{S(!1)}},[t,C]);if((0,a.useEffect)(()=>{E()},[E]),L)return(0,j.jsx)("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center",children:(0,j.jsx)(d.A,{className:"w-8 h-8 animate-spin text-cyan-400"})});if(D||!A)return(0,j.jsxs)("div",{className:"min-h-screen bg-slate-950 flex flex-col items-center justify-center gap-3",children:[(0,j.jsx)(r.A,{className:"w-10 h-10 text-red-400"}),(0,j.jsx)("p",{className:"text-slate-400",children:D||"Bot not found"}),(0,j.jsx)(b.$,{variant:"outline",onClick:()=>s(-1),children:"Go Back"})]});const{bot:F,metrics:$,pnl_history:T,recent_trades:B,recent_decisions:O}=A,U=null===F||void 0===F?void 0:F.is_active,I=(B||[]).filter(e=>!e.closed&&("buy"===e.side||"BUY"===e.side));(B||[]).filter(e=>e.closed||"sell"===e.side||"SELL"===e.side);return(0,j.jsx)("div",{className:"min-h-screen bg-slate-950 p-4 md:p-6","data-testid":"bot-detail-page",children:(0,j.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,j.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,j.jsxs)("div",{className:"flex items-center gap-3",children:[(0,j.jsx)(b.$,{variant:"ghost",size:"icon",onClick:()=>s(-1),className:"text-slate-400",children:(0,j.jsx)(x.A,{className:"w-5 h-5"})}),(0,j.jsxs)("div",{children:[(0,j.jsx)("h1",{className:"text-xl font-bold text-white",children:(null===F||void 0===F?void 0:F.name)||"Bot"}),(0,j.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,j.jsx)("span",{className:"text-slate-400 font-mono",children:null===F||void 0===F?void 0:F.trading_pair}),(0,j.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold ".concat(U?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"),children:U?"ACTIVE":"PAUSED"}),(0,j.jsx)("span",{className:"text-[10px] text-slate-600 px-1.5 py-0.5 bg-slate-800 rounded",children:null===F||void 0===F||null===(e=F.bot_type)||void 0===e?void 0:e.toUpperCase()})]})]})]}),(0,j.jsxs)(b.$,{variant:"outline",size:"sm",onClick:E,className:"text-slate-400",children:[(0,j.jsx)(h.A,{className:"w-4 h-4 mr-1"})," Refresh"]})]}),(0,j.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 mb-6",children:[(0,j.jsx)(f,{label:"Total P&L",value:"$".concat($.total_pnl>0?"+":"").concat($.total_pnl),icon:m.A,color:$.total_pnl>=0?"text-emerald-400":"text-red-400"}),(0,j.jsx)(f,{label:"Win Rate",value:"".concat($.win_rate,"%"),icon:p.A,color:$.win_rate>=50?"text-emerald-400":"text-amber-400"}),(0,j.jsx)(f,{label:"Total Trades",value:$.total_trades,icon:o.A,sub:"".concat($.winning_trades||0,"W / ").concat($.losing_trades||0,"L / ").concat($.open_positions||I.length||0," open")}),(0,j.jsx)(f,{label:"Open Positions",value:I.length,icon:u.A,color:"text-cyan-400",sub:"Awaiting profit"}),(0,j.jsx)(f,{label:"Wins / Losses",value:"".concat($.winning_trades," / ").concat($.losing_trades),icon:c.A,color:"text-emerald-400"}),(0,j.jsx)(f,{label:"Avg Confidence",value:"".concat($.avg_confidence,"%"),icon:g.A})]}),(0,j.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-4 mb-6",children:[(0,j.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,j.jsx)("h3",{className:"text-sm font-semibold text-white",children:"Daily P&L"}),(0,j.jsxs)("span",{className:"text-xs text-slate-500",children:[(null===T||void 0===T?void 0:T.length)||0," days"]})]}),(0,j.jsx)(y,{data:T})]}),I.length>0&&(0,j.jsxs)("div",{className:"bg-gradient-to-r from-cyan-950/30 to-slate-900/60 border border-cyan-500/20 rounded-xl overflow-hidden mb-6","data-testid":"open-positions-section",children:[(0,j.jsxs)("div",{className:"px-4 py-3 border-b border-cyan-500/20 flex items-center gap-2",children:[(0,j.jsx)(u.A,{className:"w-4 h-4 text-cyan-400"}),(0,j.jsx)("h3",{className:"text-sm font-semibold text-cyan-400",children:"Open Positions \u2014 Awaiting Profit"}),(0,j.jsxs)("span",{className:"text-xs bg-cyan-500/20 text-cyan-300 px-2 py-0.5 rounded-full ml-auto",children:[I.length," open"]})]}),(0,j.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:(0,j.jsxs)("table",{className:"w-full text-xs",children:[(0,j.jsx)("thead",{className:"bg-slate-800/50 sticky top-0",children:(0,j.jsxs)("tr",{className:"text-slate-500 uppercase",children:[(0,j.jsx)("th",{className:"text-left px-3 py-2",children:"Status"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Entry Price"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Per Trade"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Total Invested"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Avg Downs"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Opened"})]})}),(0,j.jsx)("tbody",{children:I.map((e,t)=>{var s;const a=w(e),l=_(e),n=e.trade_amount||l;return(0,j.jsxs)("tr",{className:"border-b border-white/5 hover:bg-cyan-900/10","data-testid":"open-position-".concat(t),children:[(0,j.jsx)("td",{className:"px-3 py-2.5",children:(0,j.jsxs)("div",{className:"flex items-center gap-2",children:[(0,j.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold ".concat(a.color),children:a.label}),(e.avg_down_count||0)>=5&&(0,j.jsx)("span",{className:"text-[9px] text-amber-400",children:"Breakeven exit pending"})]})}),(0,j.jsxs)("td",{className:"text-right px-3 py-2.5 text-white font-mono",children:["$",null===(s=e.price)||void 0===s?void 0:s.toLocaleStr
2ing(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),(0,j.jsxs)("td",{className:"text-right px-3 py-2.5 text-slate-400 font-mono",children:["$",null===l||void 0===l?void 0:l.toFixed(0)]}),(0,j.jsxs)("td",{className:"text-right px-3 py-2.5 text-white font-mono",children:["$",null===n||void 0===n?void 0:n.toFixed(0)]}),(0,j.jsx)("td",{className:"text-right px-3 py-2.5",children:(0,j.jsxs)("span",{className:"font-mono ".concat((e.avg_down_count||0)>=5?"text-amber-400":(e.avg_down_count||0)>0?"text-blue-400":"text-slate-400"),children:[e.avg_down_count||0,"/5"]})}),(0,j.jsxs)("td",{className:"text-right px-3 py-2.5 text-slate-500",children:[v(e.created_at)," ",N(e.created_at)]})]},t)})})]})})]}),(0,j.jsxs)("div",{className:"grid lg:grid-cols-2 gap-6",children:[(0,j.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl overflow-hidden",children:[(0,j.jsxs)("div",{className:"px-4 py-3 border-b border-white/10 flex items-center justify-between",children:[(0,j.jsx)("h3",{className:"text-sm font-semibold text-white",children:"Trade History"}),(0,j.jsxs)("span",{className:"text-xs text-slate-500",children:[(B||[]).length," trades"]})]}),(0,j.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:(null===B||void 0===B?void 0:B.length)>0?(0,j.jsxs)("table",{className:"w-full text-xs",children:[(0,j.jsx)("thead",{className:"bg-slate-800/50 sticky top-0",children:(0,j.jsxs)("tr",{className:"text-slate-500 uppercase",children:[(0,j.jsx)("th",{className:"text-left px-3 py-2",children:"Side"}),(0,j.jsx)("th",{className:"text-left px-3 py-2",children:"Status"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Price"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Amount"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"P&L"}),(0,j.jsx)("th",{className:"text-right px-3 py-2",children:"Time"})]})}),(0,j.jsx)("tbody",{children:B.map((e,t)=>{var s,a;const l=w(e),n=_(e);return(0,j.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5","data-testid":"trade-row-".concat(t),children:[(0,j.jsx)("td",{className:"px-3 py-2",children:(0,j.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold ".concat("buy"===e.side||"BUY"===e.side?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"),children:null===(s=e.side)||void 0===s?void 0:s.toUpperCase()})}),(0,j.jsx)("td",{className:"px-3 py-2",children:(0,j.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold ".concat(l.color),children:l.label})}),(0,j.jsxs)("td",{className:"text-right px-3 py-2 text-white font-mono",children:["$",null===(a=e.price)||void 0===a?void 0:a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),(0,j.jsxs)("td",{className:"text-right px-3 py-2 text-slate-400 font-mono",children:["$",null===n||void 0===n?void 0:n.toFixed(0)]}),(0,j.jsx)("td",{className:"text-right px-3 py-2 font-mono font-semibold ".concat((e.pnl||0)>0?"text-emerald-400":(e.pnl||0)<0?"text-red-400":"text-slate-500"),children:e.closed&&null!=e.pnl&&0!==e.pnl?"$".concat(e.pnl>0?"+":"").concat(e.pnl.toFixed(2)):e.closed?"\u2014":"Pending"}),(0,j.jsxs)("td",{className:"text-right px-3 py-2 text-slate-500",children:[v(e.created_at)," ",N(e.created_at)]})]},t)})})]}):(0,j.jsx)("p",{className:"text-sm text-slate-500 p-4 text-center",children:"No trades yet"})})]}),(0,j.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl overflow-hidden",children:[(0,j.jsx)("div",{className:"px-4 py-3 border-b border-white/10",children:(0,j.jsx)("h3",{className:"text-sm font-semibold text-white",children:"AI Decisions Log"})}),(0,j.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:(null===O||void 0===O?void 0:O.length)>0?(0,j.jsx)("div",{className:"divide-y divide-white/5",children:O.map((e,t)=>{var s;return(0,j.jsxs)("div",{className:"px-3 py-2 hover:bg-white/5 text-xs","data-testid":"decision-row-".concat(t),children:[(0,j.jsxs)("div",{className:"flex items-center gap-2",children:[(0,j.jsx)("span",{className:"px-1.5 py-0.5 rounded font-bold ".concat("BUY"===e.action?"bg-emerald-500/20 text-emerald-400":"SELL"===e.action?"bg-red-500/20 text-red-400":"bg-slate-700 text-slate-400"),children:e.action}),(0,j.jsxs)("span",{className:"text-slate-400 font-mono",children:[(100*(e.confidence||0)).toFixed(0),"%"]}),(0,j.jsxs)("span",{className:"text-slate-500 ml-auto",children:[v(e.created_at)," ",N(e.created_at)]})]}),(0,j.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,j.jsx)("span",{className:"text-slate-500",children:"Regime:"}),(0,j.jsx)("span",{className:"text-cyan-400 font-mono",children:e.mcas_regime||"\u2014"}),e.profit_taking&&(0,j.jsx)("span",{className:"text-amber-400 font-mono ml-1",children:"PROFIT-TAKE"}),(0,j.jsxs)("span",{className:"text-slate-600 ml-auto",children:["$",null===(s=e.market_price)||void 0===s?void 0:s.toLocaleStr
2ing()]})]})]},t)})}):(0,j.jsx)("p",{className:"text-sm text-slate-500 p-4 text-center",children:"No decisions logged yet"})})]})]})]})})}}}]); 3//# sourceMappingURL=712.df2067af.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.