⚡ En Vivo
Cargando precios...
Cripto
Alertas
esp · criptoalertas.es
📩 Suscribirse
Inicio
Bitcoin
Ethereum
DeFi
NFTs
Regulación
Mercados
Altcoins
⚙ Utilidades
📊 Market Tracker
Criptomonedas principales
Índices bursátiles
Acciones destacadas — Nasdaq & S&P 500
▌ Portada
▌ Últimas Noticias
Ver todas →
Escaneando fuentes cripto...
▌ Análisis & Señales
▌ Más Visto Hoy
▌ Miedo & Codicia
📡 Alertas Diarias
Las 5 señales más importantes del mercado cada mañana a las 8:00.
Activar Alertas →
✕
// ═══ UTILIDADES: MARKET TRACKER ═══ const FH_KEY = 'd6ni37hr01qodk5vtk70d6ni37hr01qodk5vtk7g'; const TR_CRYPTO = [ {id:'bitcoin',sym:'BTC',name:'Bitcoin'}, {id:'ethereum',sym:'ETH',name:'Ethereum'}, {id:'solana',sym:'SOL',name:'Solana'}, {id:'ripple',sym:'XRP',name:'XRP'}, {id:'binancecoin',sym:'BNB',name:'BNB'}, {id:'cardano',sym:'ADA',name:'Cardano'}, {id:'avalanche-2',sym:'AVAX',name:'Avalanche'}, {id:'chainlink',sym:'LINK',name:'Chainlink'}, ]; const TR_INDICES = [ {sym:'SPY', name:'S&P 500',label:'SPX'}, {sym:'QQQ', name:'Nasdaq 100',label:'NDX'}, {sym:'DIA', name:'Dow Jones',label:'DJI'}, {sym:'IWM', name:'Russell 2000',label:'RUT'}, ]; const TR_STOCKS = [ {sym:'AAPL',name:'Apple'}, {sym:'MSFT',name:'Microsoft'}, {sym:'NVDA',name:'NVIDIA'}, {sym:'GOOGL',name:'Alphabet'}, {sym:'AMZN',name:'Amazon'}, {sym:'META',name:'Meta'}, {sym:'TSLA',name:'Tesla'}, {sym:'MSTR',name:'MicroStrategy'}, {sym:'COIN',name:'Coinbase'}, {sym:'HOOD',name:'Robinhood'}, ]; function switchUtilTab(tab) { document.querySelectorAll('.util-tab').forEach(t => t.classList.toggle('active', t.dataset.tab === tab)); document.querySelectorAll('.util-panel').forEach(p => p.classList.toggle('active', p.id === 'util-' + tab)); } function skeletonCards(n) { return Array(n).fill('
').join(''); } async function loadTracker() { document.getElementById('trCrypto').innerHTML = skeletonCards(8); document.getElementById('trIndices').innerHTML = skeletonCards(4); document.getElementById('trStocks').innerHTML = skeletonCards(10); await loadTrCrypto(); updateMktStatus(); } async function loadTrCrypto() { // Now calls unified /api/tracker which returns {crypto, stocks} try { const r = await fetch('/api/tracker'); if (!r.ok) throw new Error('tracker ' + r.status); const data = await r.json(); // Render crypto if (data.crypto && data.crypto.length) { document.getElementById('trCrypto').innerHTML = data.crypto.map(function(c) { const chg = c.price_change_percentage_24h || 0; const up = chg >= 0; const sp = (c.sparkline_in_7d && c.sparkline_in_7d.price) || []; const mcap = c.market_cap >= 1e9 ? '$' + (c.market_cap/1e9).toFixed(1) + 'B' : '$' + (c.market_cap/1e6).toFixed(0) + 'M'; const pts = spPath(sp); return '
' + '
' + c.symbol.toUpperCase() + '
' + '
' + c.name + '
' + '
' + fmtC(c.current_price) + '
' + '
' + (up?'▲':'▼') + ' ' + Math.abs(chg).toFixed(2) + '%
' + '
Cap: ' + mcap + '
' + (pts ? '
' : '') + '
'; }).join(''); } // Render indices (first 4 stocks: SPY, QQQ, DIA, IWM) const indexSyms = ['SPY','QQQ','DIA','IWM']; const indexNames = {'SPY':'S&P 500','QQQ':'Nasdaq 100','DIA':'Dow Jones','IWM':'Russell 2000'}; const indexLabels = {'SPY':'SPX','QQQ':'NDX','DIA':'DJI','IWM':'RUT'}; const stockSyms = ['AAPL','MSFT','NVDA','GOOGL','AMZN','META','TSLA','MSTR','COIN','HOOD']; const stockNames = {'AAPL':'Apple','MSFT':'Microsoft','NVDA':'NVIDIA','GOOGL':'Alphabet','AMZN':'Amazon','META':'Meta','TSLA':'Tesla','MSTR':'MicroStrategy','COIN':'Coinbase','HOOD':'Robinhood'}; if (data.stocks && data.stocks.length) { const renderCard = function(item) { const price = item.c || 0, chg = item.dp || 0, up = chg >= 0; const label = indexLabels[item.sym] || item.sym; const name = indexNames[item.sym] || stockNames[item.sym] || item.sym; if (!price) return '
' + label + '
' + name + '
—
'; return '
' + '
' + label + '
' + '
' + name + '
' + '
' + fmtS(price) + '
' + '
' + (up?'▲':'▼') + ' ' + Math.abs(chg).toFixed(2) + '%
' + '
'; }; const indices = data.stocks.filter(function(s) { return indexSyms.includes(s.sym); }); const stocks = data.stocks.filter(function(s) { return stockSyms.includes(s.sym); }); document.getElementById('trIndices').innerHTML = indices.map(renderCard).join(''); document.getElementById('trStocks').innerHTML = stocks.map(renderCard).join(''); } } catch(e) { document.getElementById('trCrypto').innerHTML = '
Error cargando datos. Reintenta en unos segundos.
'; } } function fmtC(n) { if (!n) return '--'; if (n >= 1000) return '$' + n.toLocaleString('en-US', {maximumFractionDigits:0}); if (n >= 1) return '$' + n.toFixed(2); return '$' + n.toFixed(4); } function fmtS(n) { if (!n) return '--'; if (n >= 1000) return '$' + n.toLocaleString('en-US', {maximumFractionDigits:2}); return '$' + n.toFixed(2); } function spPath(prices) { if (!prices || prices.length < 2) return ''; const mn = Math.min.apply(null, prices), mx = Math.max.apply(null, prices), rng = mx - mn || 1; const step = 100 / (prices.length - 1); return prices.map(function(p, i) { return (i*step).toFixed(1) + ',' + (22 - ((p-mn)/rng)*20).toFixed(1); }).join(' '); } function updateMktStatus() { const now = new Date(); const day = now.getUTCDay(), h = now.getUTCHours(), m = now.getUTCMinutes(); const t = h * 60 + m; const open = day >= 1 && day <= 5 && t >= 870 && t < 1260; const dot = document.getElementById('mktDot'); const txt = document.getElementById('mktTxt'); if (dot) dot.className = 'mkt-dot' + (open ? ' open' : ''); if (txt) txt.textContent = open ? 'Bolsa abierta (NYSE / Nasdaq)' : 'Bolsa cerrada · Precios diferidos 15min'; } // ═══════════════════════════════════