PageSourceSearch

https://falpha.ai/static/js/9457.9fdfc069.chunk.js

js falpha.ai collected 2026-10-05 12:00:20 UTC 16,467 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkbam_mern_app_client=self.webpackChunkbam_mern_app_client||[]).push([[9457],{59457:(e,t,i)=>{i.r(t),i.d(t,{default:()=>A});var s=i(89379),l=i(9950),a=i(28429),n=i(44616),c=i(50847),r=i.n(c),o=i(15769),d=i(34075),h=i(21671),u=i(69780),m=i(9213),w=i(1108),p=(i(42127),i(44414));const g="/api",v=/^[A-Z][A-Z0-9.-]{0,9}$/,j=["neutral","bear","bull"];function b(e){const t=String(e||"").replace(/(\d),(?=\d)/g,"$1").split(/[,\s;]+/).map((e=>e.trim())).filter(Boolean).slice(0,1200),i=[],s=[],l=new Set;let a=!1,n=!1;for(const r of t){const e=r.toUpperCase(),t=e.match(/^(\$)?(\d+(?:\.\d+)?)(%)?$/);if(t&&i.length){const e=i[i.length-1];if(null==e.weight){const i=Boolean(t[1]);i?n=!0:a=!0,e.weight={usd:i,value:Number(t[2])};continue}}l.has(e)||(v.test(e)?(l.add(e),i.push({ticker:e,weight:null})):s.push(e))}if(a&&n)return{entries:[],rejected:s,error:"Mixed % and $ amounts. Use one or the other."};const c={};if(n){const e=i.reduce(((e,t)=>e+(t.weight?t.weight.value:0)),0);e>0&&i.forEach((t=>{t.weight&&t.weight.value>0&&(c[t.ticker]=Math.round(t.weight.value/e*1e4)/100)}))}else i.forEach((e=>{e.weight&&e.weight.value>0&&(c[e.ticker]=Math.round(100*e.weight.value)/100)}));return{entries:i,tickers:i.map((e=>e.ticker)),weights:c,rejected:s,error:null}}async function x(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=await fetch("".concat(g).concat(e),(0,s.A)((0,s.A)({credentials:"include",headers:t.body?{"Content-Type":"application/json"}:void 0},t),{},{body:t.body?JSON.stringify(t.body):void 0})),l=await i.json().catch((()=>({})));if(!i.ok){var a;const e=[null===l||void 0===l||null===(a=l.detail)||void 0===a?void 0:a.message,null===l||void 0===l?void 0:l.detail,null===l||void 0===l?void 0:l.message,null===l||void 0===l?void 0:l.error].find((e=>"string"===typeof e&&e));throw new Error(e||"Request failed (".concat(i.status,")"))}return l}function f(e){let{direction:t}=e;return t?(0,p.jsx)("span",{className:"wl-chip wl-chip--".concat(t),children:t}):(0,p.jsx)("span",{className:"wl-chip wl-chip--na",children:"no signal"})}function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return null===e||void 0===e?"\u2014":Number(e).toFixed(t)}function y(e){return null===e||void 0===e?"\u2014":"".concat(Number(e).toFixed(2).replace(/\.?0+$/,""),"%")}function N(e){let{portfolio:t}=e;if(!t)return null;if("ok"!==t.status)return(0,p.jsx)("span",{className:"wl-stamp",title:t.message||"Portfolio risk unavailable.",children:"Sharpe \u2014"});const i=t.portfolio_sharpe,s=t.window||{},l=[null===i||void 0===i?"Portfolio Sharpe unavailable.":"Portfolio Sharpe ".concat(Number(i).toFixed(2),": realized, of the whole weighted book (diversification included). Not the average of per-ticker Sharpes."),null!=t.annualized_volatility?"Annualized volatility ".concat((100*t.annualized_volatility).toFixed(1),"%."):null,null!=t.max_drawdown?"Max drawdown ".concat((100*Math.abs(t.max_drawdown)).toFixed(1),"%."):null,s.rows?"".concat(s.rows," trading days to ").concat(s.end,"."):null,...t.notes||[]].filter(Boolean).join(" ");return(0,p.jsxs)("span",{className:"wl-stamp".concat(null!=i&&i>0?" wl-stamp--good":""),title:l,children:["Sharpe ",null==i?"\u2014":Number(i).toFixed(2)]})}function A(){const e=(0,a.Zp)(),{scope:t}=(0,n.iV)(),[i,c]=(0,l.useState)([]),[g,v]=(0,l.useState)(null),[A,S]=(0,l.useState)({}),[C,_]=(0,l.useState)(null),[E,P]=(0,l.useState)("neutral"),[O,M]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!0),[L,$]=(0,l.useState)(null),[F,z]=(0,l.useState)(null),[V,W]=(0,l.useState)(""),[R,B]=(0,l.useState)(!1),[I,U]=(0,l.useState)(""),[Z,q]=(0,l.useState)(!1),[H,J]=(0,l.useState)("pct"),[K,X]=(0,l.useState)({}),Y=(0,l.useRef)(null),G=(0,l.useCallback)((async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:E;const t=await x("/agent/watchlists?with_signals=true&with_portfolio=true&regime=".concat(e));c(t.items||[]),v(t.signals||null),S(t.portfolios||{}),_((e=>{if(e&&(t.items||[]).some((t=>t.watchlist_id===e)))return e;const i=(t.items||[]).find((e=>e.is_default))||(t.items||[])[0];return i?i.watchlist_id:null}))}),[E]);(0,l.useEffect)((()=>{G().catch((e=>z(e.message))).finally((()=>D(!1)))}),[]);const Q=(0,l.useMemo)((()=>i.find((e=>e.watchlist_id===C))||null),[i,C]),ee=(0,l.useMemo)((()=>{const e=new Map(((null===g||void 0===g?void 0:g.rows)||[]).map((e=>[e.ticker,e])));return((null===Q||void 0===Q?void 0:Q.tickers)||[]).map((t=>e.get(t)||{ticker:t,ei:null,direction:null,horizon:null,horizon_label:null,drivers:[]}))}),[Q,g]),te=C?A[C]:null,ie=(0,l.useMemo)((()=>{const e=(null===Q||void 0===Q?void 0:Q.weights)||{};return Object.values(e).reduce(((e,t)=>e+Number(t||0)),0)}),[Q]),se=async(e,t)=>{M(!0),z(null);try{var i,s;const l=await e(),a=[];return t&&a.push(t),null!==l&&void 0!==l&&null!==(i=l.invalid)&&void 0!==i&&i.length&&a.push("not in fAlpha coverage: ".concat(l.invalid.join(", "))),null!==l&&void 0!==l&&null!==(s=l.duplicates)&&void 0!==s&&s.length&&a.push("already present: ".concat(l.duplicates.join(", "))),$(a.join("; ")||null),await G(),l}catch(l){return z(l.message),null}finally{M(!1)}},le=()=>{const e=V.trim();e&&(se((()=>x("/agent/watchlists",{method:"POST",body:{name:e,tickers:[]}})),"Created \u201c".concat(e,"\u201d")).then((e=>{var t;const i=null===e||void 0===e||null===(t=e.watchlist)||void 0===t?void 0:t.watchlist_id;i&&_(i)})),W(""))},ae=(e,t)=>{Q&&(e.error?z(e.error):e.tickers.length?se((async()=>{var t;const i=await x("/agent/watchlists/".concat(Q.watchlist_id,"/tickers"),{method:"POST",body:{add:e.tickers,remove:[]}}),l=new Set((null===i||void 0===i||null===(t=i.watchlist)||void 0===t?void 0:t.t
1ickers)||[]),a=Object.fromEntries(Object.entries(e.weights||{}).filter((e=>{let[t]=e;return l.has(t)})));if(Object.keys(a).length){var n;const e=(0,s.A)((0,s.A)({},(null===i||void 0===i||null===(n=i.watchlist)||void 0===n?void 0:n.weights)||{}),a),t=await x("/agent/watchlists/".concat(Q.watchlist_id),{method:"PUT",body:{weights:e}});return(0,s.A)((0,s.A)({},t),{},{invalid:null===i||void 0===i?void 0:i.invalid,duplicates:null===i||void 0===i?void 0:i.duplicates})}return i}),e.rejected.length?"Skipped (not ticker-shaped): ".concat(e.rejected.join(", ")):"Imported from ".concat(t)):z("No valid tickers found in the ".concat(t,".")))},ne=(0,l.useMemo)((()=>{const e={};let t=!1;return Object.entries(K).forEach((i=>{let[s,l]=i;const a=String(null!==l&&void 0!==l?l:"").trim();if(!a)return;const n=Number(a);!Number.isFinite(n)||n<0?t=!0:0!==n&&(e[s]=n)})),{vals:e,bad:t}}),[K]),ce=(0,l.useMemo)((()=>{const{vals:e}=ne,t=Object.entries(e);if(!t.length)return{};if("usd"===H){const e=t.reduce(((e,t)=>{let[,i]=t;return e+i}),0);return e?Object.fromEntries(t.map((t=>{let[i,s]=t;return[i,Math.round(s/e*1e4)/100]}))):{}}return Object.fromEntries(t.map((e=>{let[t,i]=e;return[t,Math.round(100*i)/100]})))}),[ne,H]),re=Object.values(ce).reduce(((e,t)=>e+t),0),oe="pct"===H&&re>100.005,de=ne.bad||oe,he=ne.bad?"Weights must be 0 or positive numbers (0 or blank = watch-only).":oe?"Over-allocated by ".concat((re-100).toFixed(2),"%. Reduce a weight or set one to 0."):null;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"agent-particle-background",children:(0,p.jsx)(w.B9,{id:"watchlist-particles",interactive:!1})}),(0,p.jsx)(w.g0,{}),(0,p.jsx)("main",{className:"agent-workspace-page truecolor watchlist-page",children:(0,p.jsxs)("div",{className:"watchlist-grid",children:[(0,p.jsxs)("aside",{className:"watchlist-sidebar",children:[(0,p.jsx)("div",{className:"watchlist-side-title",children:"Watchlists"}),i.map((e=>(0,p.jsxs)("button",{type:"button",className:"watchlist-item".concat(e.watchlist_id===C?" watchlist-item--active":""),onClick:()=>_(e.watchlist_id),children:[(0,p.jsx)("span",{className:"watchlist-item-name",children:e.name}),(0,p.jsxs)("span",{className:"watchlist-item-meta",children:[e.tickers.length,e.is_default?" \xb7 default":""]})]},e.watchlist_id))),!i.length&&(0,p.jsx)("p",{className:"watchlist-empty",children:"No watchlists yet. Create one below."}),(0,p.jsxs)("div",{className:"watchlist-create",children:[(0,p.jsx)("input",{value:V,onChange:e=>W(e.target.value),onKeyDown:e=>"Enter"===e.key&&le(),placeholder:"List name\u2026",maxLength:60}),(0,p.jsx)("button",{type:"button",onClick:le,disabled:O||!V.trim(),children:"Create"})]})]}),(0,p.jsxs)("section",{className:"watchlist-main",children:[L&&(0,p.jsx)("div",{className:"watchlist-notice",children:L}),F&&(0,p.jsx)("div",{className:"watchlist-error",children:F}),T?(0,p.jsx)("p",{className:"watchlist-empty",children:"Loading your watchlists\u2026"}):Q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"watchlist-head",children:[(0,p.jsx)("h2",{children:Q.name}),(0,p.jsxs)("div",{className:"watchlist-head-meta",children:[(0,p.jsx)("span",{className:"wl-stamp",children:null!==g&&void 0!==g&&g.as_of_date?"signals ".concat(g.as_of_date):"signals unavailable"}),ie>0&&(0,p.jsxs)("span",{className:"wl-stamp",title:"Allocated portfolio weight across this list.",children:["\u03a3 ",y(ie)]}),te&&(0,p.jsx)(N,{portfolio:te}),(0,p.jsx)("select",{value:E,onChange:e=>{return t=e.target.value,P(t),void G(t).catch((e=>z(e.message)));var t},"aria-label":"Regime",children:j.map((e=>(0,p.jsx)("option",{value:e,children:e},e)))})]}),(0,p.jsxs)("div",{className:"watchlist-actions",children:[(0,p.jsx)("button",{type:"button",onClick:()=>B((e=>!e)),disabled:O,children:"Paste tickers"}),(0,p.jsx)("button",{type:"button",onClick:()=>Y.current&&Y.current.click(),disabled:O,children:"Import CSV"}),(0,p.jsx)("input",{ref:Y,type:"file",accept:".csv,text/csv",onChange:e=>{const t=e.target.files&&e.target.files[0];if(e.target.value="",!t)return;const i=new FileReader;i.onload=()=>{let e=r().parse(String(i.result||""),{skipEmptyLines:!0}).data||[];(Array.isArray(e[0])?e[0]:[e[0]]).map((e=>String(e||"").trim().toLowerCase())).some((e=>["ticker","tickers","symbol","symbols","weight","weights","allocation","%","amount"].includes(e)))&&(e=e.slice(1));const s=e.map((e=>Array.isArray(e)?e.join(" "):String(e))).join("\n");ae(b(s),t.name)}
1,i.readAsText(t)},style:{display:"none"}}),(0,p.jsx)("button",{type:"button",onClick:()=>Z?q(!1):(()=>{const e={};((null===Q||void 0===Q?void 0:Q.tickers)||[]).forEach((t=>{var i;const s=null===Q||void 0===Q||null===(i=Q.weights)||void 0===i?void 0:i[t];e[t]=void 0===s||null===s?"":String(s)})),X(e),J("pct"),q(!0)})(),disabled:O||!Q.tickers.length,children:"Weights"}),(0,p.jsx)("button",{type:"button",className:"watchlist-danger",onClick:()=>{Q&&window.confirm("Delete watchlist \u201c".concat(Q.name,"\u201d?"))&&se((()=>x("/agent/watchlists/".concat(Q.watchlist_id),{method:"DELETE"})),"Deleted \u201c".concat(Q.name,"\u201d"))},disabled:O,children:"Delete list"})]})]}),R&&(0,p.jsxs)("div",{className:"watchlist-paste",children:[(0,p.jsx)("textarea",{rows:3,value:I,onChange:e=>U(e.target.value),placeholder:"Tickers, with optional weights. One style per paste:\nNVDA 40, AAPL 35, TSLA 25   \xb7   NVDA $12000 AAPL $8000   \xb7   or just NVDA, AAPL"}),(0,p.jsxs)("button",{type:"button",onClick:()=>{const e=b(I);e.error?z(e.error):(B(!1),U(""),ae(e,"pasted list"))},disabled:O||!I.trim(),children:["Add to \u201c",Q.name,"\u201d"]})]}),Z&&(0,p.jsxs)("div",{className:"watchlist-weights",children:[(0,p.jsxs)("div",{className:"watchlist-weights-head",children:[(0,p.jsx)("span",{className:"watchlist-weights-title",children:"Portfolio weights"}),(0,p.jsxs)("div",{className:"wl-mode",role:"tablist","aria-label":"Weight input mode",children:[(0,p.jsx)("button",{type:"button",className:"pct"===H?"wl-mode--on":"",onClick:()=>J("pct"),children:"%"}),(0,p.jsx)("button",{type:"button",className:"usd"===H?"wl-mode--on":"",onClick:()=>J("usd"),children:"$"})]}),(0,p.jsxs)("span",{className:"wl-sum".concat(de?" wl-sum--bad":""),children:["\u03a3 ",y(Math.round(100*re)/100),"usd"===H?" (from $ amounts)":""]})]}),(0,p.jsx)("div",{className:"watchlist-weights-grid",children:(Q.tickers||[]).map((e=>{var t;return(0,p.jsxs)("label",{className:"wl-weight-row",children:[(0,p.jsx)("span",{className:"wl-weight-ticker",children:e}),(0,p.jsx)("input",{inputMode:"decimal",placeholder:"usd"===H?"$":"%",value:null!==(t=K[e])&&void 0!==t?t:"",onChange:t=>X((i=>(0,s.A)((0,s.A)({},i),{},{[e]:t.target.value})))}),"usd"===H&&void 0!==ce[e]&&(0,p.jsx)("span",{className:"wl-weight-preview",children:y(ce[e])})]},e)}))}),(0,p.jsxs)("div",{className:"watchlist-weights-foot",children:[(0,p.jsx)("span",{className:"watchlist-weights-hint".concat(he?" watchlist-weights-hint--bad":""),children:he||("usd"===H?"Dollar amounts are converted to % of the entered total. Blank or 0 = watch-only.":"Blank or 0 = watch-only (no allocation). \u03a3 may be under 100 (cash is a position), never over.")}),(0,p.jsx)("button",{type:"button",onClick:()=>{se((()=>x("/agent/watchlists/".concat(Q.watchlist_id),{method:"PUT",body:{weights:{}}})),"Weights cleared").then((e=>e&&q(!1)))},disabled:O,children:"Clear"}),(0,p.jsx)("button",{type:"button",onClick:()=>q(!1),disabled:O,children:"Cancel"}),(0,p.jsx)("button",{type:"button",onClick:()=>{se((()=>x("/agent/watchlists/".concat(Q.watchlist_id),{method:"PUT",body:{weights:ce}})),"Weights saved").then((e=>e&&q(!1)))},disabled:O||de,children:"Save weights"})]})]}),(0,p.jsxs)(o.A,{size:"small",className:"watchlist-table",children:[(0,p.jsx)(u.A,{children:(0,p.jsxs)(m.A,{children:[(0,p.jsx)(h.A,{align:"right",title:"Your portfolio weight for this ticker. Set via the Weights editor, or paste \u201cNVDA 40\u201d / \u201cNVDA $12000\u201d.",children:"Weight"}),(0,p.jsx)(h.A,{children:"Ticker"}),(0,p.jsx)(h.A,{title:"Long or short: the side the model leans at the chosen holding period, from the sign of EI.",children:"Direction"}),(0,p.jsx)(h.A,{align:"right",title:"Equity indicator at the chosen holding period. Positive leans long, negative leans short.",children:"EI"}),(0,p.jsx)(h.A,{title:"The holding period with the model's strongest signal for this ticker: the one where it leans hardest, long or short (largest |EI|).",children:"Holding period"}),(0,p.jsx)(h.A,{title:"The regime this read assumes (switch it above).",children:"Regime"}),(0,p.jsx)(h.A,{title:"Top drivers behind the model's signal at this holding period, from XAI attribution.",children:"Drivers"}),(0,p.jsx)(h.A,{})]})}),(0,p.jsxs)(d.A,{children:[ee.map((i=>{var s,l;return(0,p.jsxs)(m.A,{hover:!0,children:[(0,p.jsx)(h.A,{align:"right",className:"wl-num wl-weight",title:null!==(s=Q.weights)&&void 0!==s&&s[i.ticker]?"".concat(y(Q.weights[i.ticker])," of the portfolio"):"Watch-only: on the list to monitor, no allocation",children:y(null===(l=Q.weights)||void 0===l?void 0:l[i.ticker])}),(0,p.jsx)(h.A,{children:(0,p.jsx)(n.kx,{ticker:i.ticker,scope:t,className:"watchlist-ticker-lock",label:i.ticker,children:(0,p.jsx)("button",{type:"button",className:"watchlist-ticker",onClick:()=>e("/tradingpulse/company/".concat(i.ticker)),title:"Open ".concat(i.ticker," (the fAlpha agent launcher lives there)"),children:i.ticker})})}),(0,p.jsx)(h.A,{children:(0,p.jsx)(f,{direction:i.direction})}),(0,p.jsx)(h.A,{align:"right",className:"wl-num",children:k(i.ei)}),(0,p.jsx)(h.A,{className:"wl-hz",children:i.horizon_label||"\u2014"}),(0,p.jsx)(h.A,{className:"wl-hz",children:i.direction?E:"\u2014"}),(0,p.jsx)(h.A,{children:i.drivers&&i.drivers.length?(0,p.jsx)("span",{className:"wl-drivers",children:i.drivers.map((e=>(0,p.jsxs)("span",{className:"wl-driver",title:"".concat(e.name,": ").concat(e.pct,"% of the model's attribution"),children:[e.name," ",(0,p.jsxs)("em",{children:[e.pct,"%"]})]},e.name)))}):(0,p.jsx)("span",{className:"wl-drivers wl-drivers--na",children:"\u2014"})}),(0,p.jsx)(h.A,{align:"right",children:(0,p.jsx)("button",{type:"button",className:"watchlist-remove",onClick:()=>{return e=i.ticker,void(Q&&se((()=>x("/agent/watchlists/".concat(Q.watchlist_id,"/tickers"),{method:"POST",body:{add:[],remove:[e]}})),"Removed ".concat(e)));var e},disabled:O,children:"remove"})})]},i.ticker)})),!ee.length&&(0,p.jsx)(m.A,{children:(0,p.jsx)(h.A,{colSpan:8,className:"watchlist-empty",children:"Empty list. Paste tickers (optionally with weights: \u201cNVDA 40, AAPL 60\u201d) or import a CSV above."})})]})]})]}):(0,p.jsx)("p",{className:"watchlist-empty",children:"Name a list on the left and hit Create, then paste tickers or import a CSV. Every ticker is checked against fAlpha coverage before it is saved."})]})]})})]})}}}]);

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.