export default function handler(req, res) { const generateRandomPrice = (base, volatility = 0.02) => { return base * (1 + (Math.random() - 0.5) * volatility) } const generateChange = () => { return (Math.random() - 0.48) * 10 } const stocks = [ { symbol: 'AAPL', name: 'Apple Inc.', basePrice: 178.50 }, { symbol: 'MSFT', name: 'Microsoft', basePrice: 378.85 }, { symbol: 'GOOGL', name: 'Alphabet', basePrice: 139.62 }, { symbol: 'AMZN', name: 'Amazon', basePrice: 145.78 }, { symbol: 'META', name: 'Meta Platforms', basePrice: 312.45 }, { symbol: 'TSLA', name: 'Tesla', basePrice: 248.50 }, { symbol: 'NVDA', name: 'NVIDIA', basePrice: 485.09 }, { symbol: 'NFLX', name: 'Netflix', basePrice: 445.03 }, ] const stocksData = stocks.map(stock => { const price = generateRandomPrice(stock.basePrice) const change = generateChange() const changePercent = (change / stock.basePrice) * 100 return { ...stock, price: price.toFixed(2), change: change.toFixed(2), changePercent: changePercent.toFixed(2), volume: Math.floor(Math.random() * 100000000) + 10000000, marketCap: (price * 1000000000).toFixed(0), } }) const marketOverview = { sp500: { value: 4514.02, change: 15.36, changePercent: 0.34 }, nasdaq: { value: 14113.70, change: 123.45, changePercent: 0.88 }, dow: { value: 35430.42, change: -45.12, changePercent: -0.13 }, vix: { value: 14.82, change: -0.45, changePercent: -2.95 } } res.status(200).json({ stocks: stocksData, marketOverview, timestamp: new Date().toISOString() }) }