Changed around line 1
+ // Sample stock data (would be replaced with real API calls)
+ const stocks = [
+ { symbol: 'AAPL', price: 189.25, change: 1.45 },
+ { symbol: 'GOOGL', price: 138.45, change: -0.75 },
+ { symbol: 'TSLA', price: 260.02, change: 3.12 },
+ { symbol: 'AMZN', price: 134.95, change: 0.89 },
+ { symbol: 'MSFT', price: 340.54, change: -1.23 },
+ { symbol: 'NVDA', price: 467.19, change: 5.67 },
+ { symbol: 'META', price: 305.38, change: 2.34 },
+ { symbol: 'BRK.B', price: 360.75, change: -0.45 }
+ ];
+
+ const tickerTape = document.querySelector('.ticker-tape');
+
+ function createStockElement(stock) {
+ const div = document.createElement('div');
+ div.className = 'stock-item';
+
+ const symbol = document.createElement('span');
+ symbol.className = 'stock-symbol';
+ symbol.textContent = stock.symbol;
+
+ const price = document.createElement('span');
+ price.className = 'stock-price';
+ price.textContent = `$${stock.price.toFixed(2)}`;
+
+ const change = document.createElement('span');
+ change.className = 'stock-change ' + (stock.change >= 0 ? 'positive' : 'negative');
+ change.textContent = `${stock.change >= 0 ? '+' : ''}${stock.change.toFixed(2)}`;
+
+ div.append(symbol, price, change);
+ return div;
+ }
+
+ function updateTicker() {
+ // Clear existing content
+ tickerTape.innerHTML = '';
+
+ // Duplicate stocks for continuous scrolling
+ const duplicatedStocks = [...stocks, ...stocks];
+
+ // Create and append stock elements
+ duplicatedStocks.forEach(stock => {
+ tickerTape.appendChild(createStockElement(stock));
+ });
+ }
+
+ // Initial update
+ updateTicker();
+
+ // Update every 10 seconds
+ setInterval(updateTicker, 10000);