/* Company Stock Price — US ETFs & mutual funds via Finnhub (live API only). */ function RetCell({ v }) { if (v == null) return —; return = 0 ? 'var(--up)' : 'var(--down)' }}>{fmt.pct(v)}; } function FundsScreen() { const L = useLive(); const MD = useMarketData(); const [cat, setCat] = useState('All'); const [sort, setSort] = useState('nav'); const [region, setRegion] = useState('US'); const [globalFunds, setGlobalFunds] = useState([]); const [loading, setLoading] = useState(false); const [err, setErr] = useState(''); const [sel, setSel] = useState(null); const [detail, setDetail] = useState(null); const [detailBusy, setDetailBusy] = useState(false); const funds = region === 'US' ? globalFunds : []; const categories = ['All', ...[...new Set(globalFunds.map((f) => f.category))].sort()]; async function loadGlobal() { if (!L.hasKey) return; setLoading(true); setErr(''); try { setGlobalFunds(await L.market.getGlobalFunds()); L.refreshRateLimit(); } catch (e) { setErr(apiErrorMessage(e)); setGlobalFunds([]); } finally { setLoading(false); } } useEffect(() => { if (region === 'US' && L.hasKey) loadGlobal(); }, [region, L.hasKey]); async function openFund(f) { if (!f.live || !L.hasKey) { setSel(f); setDetail(null); return; } setSel(f); setDetailBusy(true); try { setDetail(await L.market.getFundDetails(f.symbol)); } catch (e) { setDetail(null); } finally { setDetailBusy(false); } } if (region === 'IN') { return (
| Fund | Category | {region === 'US' ? 'Price ($)' : 'NAV (₹)'} | 1D | {region === 'IN' && <>1Y | 3Y | >}AUM | Expense | {region === 'IN' ? 'Rating' : 'Risk'} |
|---|---|---|---|---|---|---|---|---|
|
{f.initials}
{f.name}
{f.house}{f.symbol ? ' · ' + f.symbol : ''}
|
{f.category} | {region === 'US' ? '$' : '₹'}{fmt.price(f.nav)} | {f.aum != null ? (region === 'US' ? '$' + (f.aum >= 1e9 ? (f.aum / 1e9).toFixed(1) + 'B' : (f.aum / 1e6).toFixed(0) + 'M') : f.aum.toLocaleString('en-IN')) : '—'} | {f.expense != null ? f.expense + '%' : '—'} | {region === 'IN' ? (f.rating ? '★'.repeat(f.rating) : '—') : (f.risk || '—')} |
{sel.description}
} {detailBusy ?