top of page

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Upcoming Confirmed Earnings Reports</title> <style> body { font-family: Arial, sans-serif; margin: 20px; text-align: center; } table { width: 90%; margin: 20px auto; border-collapse: collapse; background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } th, td { border: 1px solid #ddd; padding: 12px; text-align: center; } th { background-color: #0C2A43; color: #fff; cursor: pointer; /* Add cursor pointer for sortable headers */ } tr:nth-child(even) { background-color: #f9f9f9; } tr:hover { background-color: #f1f1f1; } th:nth-child(2), td:nth-child(2) { width: 120px; /* Adjust the width for Date column */ } th:nth-child(4), td:nth-child(4) { width: 200px; /* Adjust the width for Revenue column */ } th:nth-child(5), td:nth-child(5) { width: 150px; /* Adjust the width for Revenue Estimated column */ } input[type="text"] { width: 80%; padding: 8px; margin: 10px 0; font-size: 16px; } </style> </head> <body> <h1>Upcoming Earnings</h1> <input type="text" id="searchBox" placeholder="Search by symbol..." oninput="filterTable()"> <table id="dataTable"> <thead> <tr> <th onclick="sortTable(0)">Symbol</th> <th onclick="sortTable(1)">Date</th> <th onclick="sortTable(2)">Time</th> <th onclick="sortTable(3)">Revenue</th> <th onclick="sortTable(4)">Revenue Estimated</th> </tr> </thead> <tbody> <!-- Data rows will be added dynamically --> </tbody> </table> <script> const apiKey = 'AZGulBs5IFFNyuakSIKTQ1Ze7jxFr8tC'; // Replace with your actual API key const popularExchanges = ['NASDAQ', 'NYSE']; // Define popular exchanges const fetchStockList = async () => { const stockListUrl = `https://financialmodelingprep.com/api/v3/stock/list?apikey=${apiKey}`; const response = await fetch(stockListUrl); const stockList = await response.json(); return stockList.filter(stock => popularExchanges.includes(stock.exchangeShortName)); }; const fetchEarningsData = async (filteredSymbols) => { const today = new Date(); const endDate = new Date(today); endDate.setDate(today.getDate() + 7); const formatDate = (date) => { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; }; const earningsUrl = `https://financialmodelingprep.com/api/v3/earning_calendar?from=${formatDate(today)}&to=${formatDate(endDate)}&apikey=${apiKey}`; const response = await fetch(earningsUrl); const earningsData = await response.json(); return earningsData.filter(entry => filteredSymbols.includes(entry.symbol)); }; const updateTable = async () => { const stockList = await fetchStockList(); const filteredSymbols = stockList.map(stock => stock.symbol); const earningsData = await fetchEarningsData(filteredSymbols); const tableBody = document.getElementById('dataTable').getElementsByTagName('tbody')[0]; earningsData.forEach(entry => { const row = tableBody.insertRow(); row.insertCell(0).textContent = entry.symbol || 'N/A'; row.insertCell(1).textContent = entry.date || 'N/A'; row.insertCell(2).textContent = entry.time || 'N/A'; row.insertCell(3).textContent = entry.revenue || 'N/A'; row.insertCell(4).textContent = entry.revenueEstimated || 'N/A'; }); }; const filterTable = () => { const searchBox = document.getElementById('searchBox'); const filter = searchBox.value.toLowerCase(); const table = document.getElementById('dataTable'); const rows = table.getElementsByTagName('tr'); for (let i = 1; i < rows.length; i++) { const cells = rows[i].getElementsByTagName('td'); const symbol = cells[0].textContent.toLowerCase(); if (symbol.includes(filter)) { rows[i].style.display = ''; } else { rows[i].style.display = 'none'; } } }; const sortTable = (n) => { const table = document.getElementById('dataTable'); let rows, switching, i, x, y, shouldSwitch, dir, switchCount = 0; switching = true; dir = "asc"; // Set sorting direction to ascending while (switching) { switching = false; rows = table.rows; for (i = 1; i < (rows.length - 1); i++) { shouldSwitch = false; x = rows[i].getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n]; if (dir === "asc") { if (x.textContent.toLowerCase() > y.textContent.toLowerCase()) { shouldSwitch = true; break; } } else if (dir === "desc") { if (x.textContent.toLowerCase() < y.textContent.toLowerCase()) { shouldSwitch = true; break; } } } if (shouldSwitch) { rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); switching = true; switchCount++; } else { if (switchCount === 0 && dir === "asc") { dir = "desc"; switching = true; } } } }; // Initialize the table with data updateTable(); </script> </body> </html>

bottom of page