import { useState, useEffect } from 'react'; import { TrendingUp, Newspaper, Plus, BarChart2 } from 'lucide-react'; import Logo from './Logo'; import Sparkline from './Sparkline'; interface TrendingHubProps { onAddTicker: (ticker: string) => Promise; } export default function TrendingHub({ onAddTicker }: TrendingHubProps) { const [news, setNews] = useState([]); const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'; const [trendingAssets, setTrendingAssets] = useState([ { symbol: 'BTC-USD', name: 'Bitcoin', price: 60534.05, change: 1.82, category: 'Crypto' }, { symbol: 'ETH-USD', name: 'Ethereum', price: 3421.10, change: 0.54, category: 'Crypto' }, { symbol: 'NVDA', name: 'NVIDIA Corp.', price: 121.40, change: -1.25, category: 'Stock' }, { symbol: 'AAPL', name: 'Apple Inc.', price: 210.62, change: 0.95, category: 'Stock' }, { symbol: 'TSLA', name: 'Tesla Inc.', price: 187.30, change: 4.12, category: 'Stock' }, { symbol: 'SOL-USD', name: 'Solana', price: 142.15, change: 3.85, category: 'Crypto' }, ]); // Fetch trending assets from API and sort by magnitude of trend useEffect(() => { let active = true; const fetchTrending = async () => { try { const res = await fetch(`${API_URL}/api/v1/stocks/trending`); if (res.ok) { const data = await res.json(); if (data && data.length > 0 && active) { setTrendingAssets(data); } } } catch (err) { console.error('Failed to fetch trending assets:', err); } }; fetchTrending(); const interval = setInterval(fetchTrending, 60000); return () => { active = false; clearInterval(interval); }; }, []); const trendingNews = [ { id: 1, title: 'Federal Reserve Signals Potential Rate Cuts Later This Year', summary: 'Fed Chair Jerome Powell indicated inflation is returning to the 2% target path, hinting at upcoming rate adjustments that could fuel market momentum.', source: 'Bloomberg', time: '12m ago', category: 'Macroeconomics', link: 'https://www.bloomberg.com/markets' }, { id: 2, title: 'NVIDIA Demand Outstrips Supply as Tech Giants Expand AI Infrastructure', summary: 'Top cloud providers continue to place record-breaking chip orders. Financial firms hike price targets as AI hardware revenues reach unprecedented highs.', source: 'Reuters', time: '35m ago', category: 'Technology', link: 'https://www.reuters.com/technology' }, { id: 3, title: 'Bitcoin Solidifies Base Around $60K; On-Chain Accumulation Spikes', summary: 'Market intelligence data shows heavy whale wallet accumulation at current support levels, indicating solid long-term investor conviction.', source: 'CoinDesk', time: '1h ago', category: 'Crypto', link: 'https://www.coindesk.com' }, { id: 4, title: 'Global Tech Stock Indexes Experience Rotational Capital Inflows', summary: 'Defensive sector gains support stock index benchmarks as fund managers rebalance portfolios ahead of upcoming consumer price index (CPI) updates.', source: 'CNBC', time: '2h ago', category: 'Markets', link: 'https://www.cnbc.com/markets' }, { id: 5, title: 'Apple Vision Pro Drives New Wave of Spatial Computing Investments', summary: 'Institutional investors are increasing exposure to companies developing spatial computing platforms following Apple\'s growing developer ecosystem.', source: 'Wall Street Journal', time: '3h ago', category: 'Technology', link: 'https://www.wsj.com/tech' }, { id: 6, title: 'Tesla Q3 Deliveries Beat Expectations; Stock Surges Pre-Market', summary: 'Tesla reported record deliveries surpassing analyst forecasts, signaling strong demand recovery and boosting confidence in the EV market outlook.', source: 'MarketWatch', time: '5h ago', category: 'Stocks', link: 'https://www.marketwatch.com' } ]; useEffect(() => { let active = true; const fetchLiveNews = async () => { try { const res = await fetch(`${API_URL}/api/v1/stocks/news`); if (res.ok) { const data = await res.json(); if (data && data.length > 0 && active) { const parsed = data.map((item: any) => ({ id: item.id || Math.random().toString(), title: item.title, summary: item.summary || 'Market updates, corporate developments, and global analyst reporting.', source: item.source || 'Yahoo Finance', time: item.time || 'Recent', category: item.category || 'Markets', link: item.link || item.url || item.article_url || null })); setNews(parsed); return; } } } catch (err) { console.error('Failed to fetch live market news:', err); } if (active) { setNews(trendingNews); } }; fetchLiveNews(); return () => { active = false; }; }, []); // Market Movers state — pre-loaded with fallback so it never shows blank const [marketMovers, setMarketMovers] = useState<{ gainers: any[]; losers: any[]; most_active: any[]; }>({ gainers: [ { symbol: 'SLBT', name: 'SL Science Holding', price: 5.99, change: 1.54, changePercent: 34.61 }, { symbol: 'PLBL', name: 'Polibeli Group Ltd', price: 10.26, change: 1.58, changePercent: 18.20 }, { symbol: 'GPC', name: 'Genuine Parts Co.', price: 132.57, change: 15.17, changePercent: 12.92 }, { symbol: 'SLS', name: 'SELLAS Life Sciences', price: 14.98, change: 1.71, changePercent: 12.89 }, { symbol: 'CAR', name: 'Avis Budget Group', price: 163.44, change: 16.50, changePercent: 11.23 }, ], losers: [ { symbol: 'RGC', name: 'Regencell Bioscience', price: 6.37, change: -1.66, changePercent: -20.67 }, { symbol: 'VICR', name: 'Vicor Corporation', price: 282.95, change: -67.26, changePercent: -19.21 }, { symbol: 'ACLS', name: 'Axcelis Technologies', price: 144.50, change: -33.83, changePercent: -18.97 }, { symbol: 'VECO', name: 'Veeco Instruments', price: 57.49, change: -13.03, changePercent: -18.48 }, { symbol: 'BELFA', name: 'Bel Fuse Inc.', price: 230.16, change: -51.51, changePercent: -18.29 }, ], most_active: [ { symbol: 'AAL', name: 'American Airlines', price: 17.92, change: -0.23, changePercent: -1.27 }, { symbol: 'T', name: 'AT&T Inc.', price: 20.58, change: 0.10, changePercent: 0.49 }, { symbol: 'NVDA', name: 'NVIDIA Corporation', price: 194.83, change: -2.75, changePercent: -1.39 }, { symbol: 'INTC', name: 'Intel Corporation', price: 120.35, change: -6.67, changePercent: -5.25 }, { symbol: 'OPEN', name: 'Opendoor Technologies', price: 4.90, change: -0.04, changePercent: -0.81 }, ], }); useEffect(() => { let active = true; const fetchMovers = async () => { try { const res = await fetch(`${API_URL}/api/v1/stocks/market-movers`); if (res.ok) { const data = await res.json(); if (active) setMarketMovers(data); } } catch (err) { console.error('Failed to fetch market movers:', err); } }; fetchMovers(); const interval = setInterval(fetchMovers, 60000); return () => { active = false; clearInterval(interval); }; }, []); return (
{/* Background Neon Glowing Orbs */}
{/* Cyber Grid Pattern Background Overlay */}
{/* Massive centered Logo watermark behind cards */}
QuantIQ
{/* Welcome Banner with neon gradient border */}

QUANTIQ TERMINAL LIVE

Your watchlist is currently empty. Pin ticker symbols on the left panel to trigger charting and full-scale ReAct agent strategy workflows. Or click + Watch on any hot asset below to instantly spawn live analytics.

{/* Main Split Grid */}
{/* Left Column: Trending Assets */}

Trending Assets

{trendingAssets.map((asset) => { const isBull = asset.change >= 0; return (
{asset.category}

{asset.symbol}

{asset.name}
Price ${asset.price.toLocaleString()}
{isBull ? '+' : ''}{asset.change}%
); })}
{/* Right Column: Trending News */} {/* Market Movers — Horizontal 3-column section */}
{/* Section header */}

Market Movers

{/* Top Gainers */} {[ { key: 'gainers', label: 'Top Gainers', accent: '#10b981', bgAccent: 'rgba(16,185,129,0.07)', borderAccent: 'rgba(16,185,129,0.18)' }, { key: 'losers', label: 'Top Losers', accent: '#ef4444', bgAccent: 'rgba(239,68,68,0.07)', borderAccent: 'rgba(239,68,68,0.18)' }, { key: 'most_active', label: 'Most Active', accent: '#a78bfa', bgAccent: 'rgba(167,139,250,0.07)', borderAccent: 'rgba(167,139,250,0.18)' }, ].map(({ key, label, accent, bgAccent, borderAccent }) => { const items: any[] = (marketMovers as any)[key] || []; return (
{label}
{items.length === 0 ? (
Loading...
) : items.map((item, idx) => { const isBull = item.changePercent >= 0; return (
{/* Symbol + Name */}
{item.symbol}
{item.name}
{/* Sparkline */} {/* Price + Change */}
${item.price.toLocaleString()}
{isBull ? '+' : ''}{item.changePercent.toFixed(2)}%
); })}
); })}
); }