1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7083],{27083:(e,s,t)=>{t.r(s),t.d(s,{default:()=>N});var l=t(85047),a=t(31615),n=t(73521),i=t(82520),r=t(21582),c=t(21410),d=t(21016),x=t(2962),o=t(7004),m=t(11787),h=t(94430),u=t(61414);let j=(0,t(46775).A)("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);var p=t(35617),f=t(87884),b=t(60996),g=t(91595);function N(){let{user:e,viewingUserId:s}=(0,n.A)(),[t,N]=(0,a.useState)("1y"),[y,k]=(0,a.useState)(null),[v,w]=(0,a.useState)(!1),[A,C]=(0,a.useState)(null),[Z,F]=(0,a.useState)(!1),R=s||e?.uid,S=(0,a.useCallback)(async()=>{if(R&&e){w(!0),C(null);try{let s=await e.getIdToken(),l=new URLSearchParams({period:t});R&&l.set("userId",R);let a=await fetch(`/api/portfolio/risk-analysis?${l.toString()}`,{headers:{Authorization:`Bearer ${s}`}}),n=await a.json();if(!a.ok)throw Error(n?.error?.message||"åæå¤±æ");k(n.data)}catch(e){C(e instanceof Error?e.message:"ç¡æ³åå¾é¢¨éªåæçµæ")}finally{w(!1)}}},[R,e,t]);(0,a.useEffect)(()=>{R&&e&&S()},[S,R,e]),(0,g.py)();let B=y?Object.keys(y.weights):[],W=B.length>20&&!Z?B.map(e=>({s:e,w:y.weights[e]})).sort((e,s)=>s.w-e.w).slice(0,20).map(e=>e.s):B,T=[];if(y)for(let e=0;e<W.length;e++)for(let s=0;s<W.length;s++){let t=y.correlationMatrix[W[e]]?.[W[s]]??0;T.push([s,e,Math.round(100*t)/100])}let L=[...y?.riskContribution??[]].sort((e,s)=>s.riskContributionPct-e.riskContributionPct).slice(0,15).map(e=>({name:e.name||e.symbol,y:e.riskContributionPct})),M=[...y?.riskContribution??[]].sort((e,s)=>s.riskContributionPct-e.riskContributionPct).slice(0,15),P=y?Object.entries(y.weights).map(([e,s])=>({name:e,y:Math.round(1e3*s)/10})):[],$=y&&W.length>0?{chart:{type:"heatmap",height:320,backgroundColor:"transparent"},title:{text:null},xAxis:{categories:W,title:null},yAxis:{categories:W,title:null},colorAxis:{min:-1,max:1,minColor:"#ef4444",maxColor:"#22c55e",startOnTick:!0,endOnTick:!0},series:[{type:"heatmap",name:"ç¸éæ§",data:T,dataLabels:{enabled:W.length<=10,format:"{point.value:.2f}"}}],tooltip:{formatter:function(){let e=W[this.x]??String(this.x),s=W[this.y]??String(this.y),t=this.value;return`<b>${e} \xd7 ${s}</b>: ${"number"==typeof t?t.toFixed(2):t}`}},credits:{enabled:!1}}:null,O=L.length>0?{chart:{type:"bar",height:320,backgroundColor:"transparent"},title:{text:null},xAxis:{categories:L.map(e=>e.name),title:null},yAxis:{title:{text:"風éªè²¢ç» (%)"}},series:[{type:"bar",name:"風éªè²¢ç»",data:L.map(e=>e.y)}],plotOptions:{bar:{dataLabels:{enabled:!0,format:"{y:.1f}%"}}},credits:{enabled:!1}}:null,V=P.length>0?{chart:{type:"pie",height:320,backgroundColor:"transparent"},title:{text:null},series:[{type:"pie",name:"æ¬é",data:P}],plotOptions:{pie:{dataLabels:{enabled:!0,format:"{point.percentage:.1f}%"}}},credits:{enabled:!1}}:null;return R?(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-sm text-muted-foreground",children:"åæåé"}),(0,l.jsxs)(r.l6,{value:t,onValueChange:e=>N(e),children:[(0,l.jsx)(r.bq,{className:"w-[120px]",children:(0,l.jsx)(r.yv,{})}),(0,l.jsxs)(r.gC,{children:[(0,l.jsx)(r.eb,{value:"1y",children:"1 å¹´"}),(0,l.jsx)(r.eb,{value:"2y",children:"2 å¹´"}),(0,l.jsx)(r.eb,{value:"3y",children:"3 å¹´"})]})]})]}),(0,l.jsx)(c.$,{onClick:S,disabled:v,size:"sm",children:v?(0,l.jsx)(m.A,{className:"h-4 w-4 animate-spin"}):"éæ°åæ"})]}),v&&!y&&(0,l.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,l.jsx)(m.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),A&&(0,l.jsxs)(d.Fc,{variant:"destructive",children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),(0,l.jsx)(d.XL,{children:"åæå¤±æ"}),(0,l.jsx)(d.TN,{children:A})]}),y&&y.portfolioValue>0&&(0,l.jsxs)("div",{className:v?"opacity-60 pointer-events-none relative":void 0,children:[v&&(0,l.jsx)("div",{className:"absolute inset-0 z-10 flex items-start justify-center pt-8",children:(0,l.jsx)(m.A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}
1),y.excludedSymbols.length>0&&(0,l.jsx)(d.Fc,{className:"mb-4",children:(0,l.jsxs)(d.TN,{children:["以䏿¨çå æ·å²è³æä¸è¶³å·²æé¤ï¼",y.excludedSymbols.join(", ")]})}),(0,l.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"æè³çµåå¹å¼"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsx)("p",{className:"text-2xl font-bold tabular-nums",children:(0,p.C)(y.portfolioValue)}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"ç®åç´å
¥åæçå°è¡ç¸½å¸å¼"})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"å¹´åå ±é
¬"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsxs)("p",{className:"text-2xl font-bold tabular-nums",children:[(100*y.portfolioReturn).toFixed(2),"%"]}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"便¥å ±é
¬åå¼ \xd7 252 ä¼°ç®"})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"å¹´åæ³¢åç"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsxs)("p",{className:"text-2xl font-bold tabular-nums",children:[(100*y.portfolioVolatility).toFixed(2),"%"]}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"广 ¼èµ·ä¼å¹
åº¦ï¼æé«ä»£è¡¨æ³¢åæå¤§ãé¢¨éªæé«"})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"夿®æ¯ç"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsx)("p",{className:"text-2xl font-bold tabular-nums",children:y.sharpeRatio.toFixed(2)}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"èé風éªå¾çå ±é
¬æçï¼æé«æå¥½ï¼é常 > 1 è¼ä½³ï¼"})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"ç´¢æè«¾æ¯ç"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsx)("p",{className:"text-2xl font-bold tabular-nums",children:y.sortinoRatio.toFixed(2)}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"åªèæ
®ä¸è·æ³¢åçå ±é
¬æçï¼æé«æå¥½"})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"VaR 95%ï¼æ·å²ï¼"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsx)("p",{className:"text-2xl font-bold tabular-nums",children:(0,p.C)(y.var95Amount)}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"æ·å²ç´ 5% æ©ç宿¥æå¤±è¶
鿤éé¡"}),(0,l.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(100*y.var95Ratio).toFixed(2),"% æ¥æå¤±"]})]})]}),(0,l.jsxs)(i.Zp,{children:[(0,l.jsx)(i.aR,{className:"pb-2",children:(0,l.jsx)(i.ZB,{className:"text-sm font-medium",children:"æå¤§åæ¤"})}),(0,l.jsxs)(i.Wu,{children:[(0,l.jsxs)("p",{className:"text-2xl font-bold tabular-nums",children:[(100*y.maxDrawdown).toFixed(2),"%"]}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"å¾é«é»å°æä½é»æ¾åºç¾çæå¤§è·å¹
ç¾åæ¯"})]})]})]}),(0,l.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ç¡é¢¨éªå©çï¼",(100*y.riskFreeRate).toFixed(2),"% | åºæºï¼","0050"===y.benchmarkSymbol?"0050 å°ç£50":y.benchmarkSymbol,"unavailable"===y.benchmarkStatus&&"ï¼è³ææ«ä¸å¯ç¨ï¼"]}),y.riskContribution.length>0&&(0,l.jsxs)(i.Zp,{children:[(0,l.jsxs)(i.aR,{children:[(0,l.jsxs)(i.ZB,{className:"flex items-center gap-2",children:[(0,l.jsx)(h.A,{className:"h-5 w-5"}),"風éªè²¢ç»"]}),(0,l.jsx)("p",{className:"text-sm text-muted-foreground font-normal mt-1",children:"忍çå°æ´é«çµå風éªçè²¢ç»å æ¯ï¼æé·ä»£è¡¨è©²æ¨çææé«æ´é«æ³¢å"})]}),(0,l.jsxs)(i.Wu,{children:[O&&(0,l.jsx)(b.A,{highcharts:f.A,options:O,immutable:!1}),(0,l.jsxs)(x.XI,{className:"mt-4",children:[(0,l.jsx)(x.A0,{children:(0,l.jsxs)(x.Hj,{children:[(0,l.jsx)(x.nd,{children:"æ¨ç"}),(0,l.jsx)(x.nd,{children:"æ¬é"}),(0,l.jsx)(x.nd,{children:"æ³¢åç"}),(0,l.jsx)(x.nd,{children:"風éªè²¢ç»"})]})}),(0,l.jsx)(x.BF,{children:M.map(e=>(0,l.jsxs)(x.Hj,{children:[(0,l.jsx)(x.nA,{children:e.name||e.symbol}),(0,l.jsxs)(x.nA,{children:[(100*e.weight).toFixed(1),"%"]}),(0,l.jsxs)(x.nA,{children:[(100*e.volatility).toFixed(2),"%"]}),(0,l.jsxs)(x.nA,{children:[e.riskContributionPct.toFixed(1),"%"]})]},e.symbol))})]})]})]}),P.length>0&&(0,l.jsxs)(i.Zp,{children:[(0,l.jsxs)(i.aR,{children:[(0,l.jsxs)(i.ZB,{className:"flex items-center gap-2",children:[(0,l.jsx)(u.A,{className:"h-5 w-5"}),"éä¸åº¦"]}),(0,l.jsx)("p",{className:"text-sm text-muted-foreground font-normal mt-1",children:"忍çå çµåæ¬éæ¯ä¾ï¼å®ä¸æ¨çæ¬ééé«ä»£è¡¨éä¸é¢¨éªè¼å¤§"}),(0,l.jsxs)("p",{className:"text-sm text-muted-foreground",children:["å®ä¸æ¨çæå¤§æ¬éï¼",(100*y.concentration.maxSingleWeight).toFixed(1),"%"]})]}),(0,l.jsx)(i.Wu,{children:V&&(0,l.jsx)(b.A,{highcharts:f.A,options:V,immutable:!1})})]}),W.length>0&&(0,l.jsxs)(i.Zp,{children:[(0,l.jsxs)(i.aR,{children:[(0,l.jsxs)(i.ZB,{className:"flex items-center gap-2",children:[(0,l.jsx)(j,{className:"h-5 w-5"}),"ç¸éæ§ç©é£"]}),(0,l.jsx)("p",{className:"text-sm text-muted-foreground font-normal mt-1",children:"å
©å
©æ¨çå ±é
¬èµ°å¢çç¸éç¨åº¦ï¼-1ï½1ï¼ï¼ææ¥è¿ 1 æååãåæ£æææå·®"}),B.length>20&&(0,l.jsx)(c.$,{variant:"outline",size:"sm",onClick:()=>F(e=>!e),children:Z?"顯示 Top 20":"顯示å
¨é¨"})]}),(0,l.jsx)(i.Wu,{children:$?(0,l.jsx)(b.A,{highcharts:f.A,options:$,immutable:!1}):(0,l.jsx)("p",{className:"text-muted-foreground",children:"ç¡è¶³å¤ è³æé¡¯ç¤ºç¸éæ§ç©é£"})})]})]}),!v&&(!y||0===y.portfolioValue)&&!A&&R&&(0,l.jsxs)(d.Fc,{children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),(0,l.jsx)(d.XL,{children:"å°ç¡å¯åæä¹å°è¡é¨ä½"}),(0,l.jsx)(d.TN,{children:"è«å
æ°å¢å°è¡æè³æ¨çï¼ç³»çµ±å°ä¾æ·å²å¹æ ¼è¨ç®æè³çµåé¢¨éªææ¨ã"})]})]}):(0,l.jsxs)(d.Fc,{children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),(0,l.jsx)(d.XL,{children:"è«å
ç»å
¥"}),(0,l.jsx)(d.TN,{children:"éè¦ç»å
¥æè½ä½¿ç¨é¢¨éªåæåè½ã"})]})}}}]);
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.