AI-Powered Earnings Surprise & Stock Movement Predictor AI-Powered Earnings Surprise & Stock Movement Predictor Leverage AI to analyze market sentiment and predict post-earnings stock reactions. 1. Earnings Data 2. Market Context 3. AI Prediction Company & Earnings Data Market & Company Context Company's Forward Guidance: Raised / Positive In-line / Neutral Lowered / Negative Broader Market Sentiment: Bullish Neutral / Mixed Bearish Sector Trend: Outperforming Market In-line with Market Underperforming Market AI Prediction Report Download Report as PDF Previous Next ${surprisePercent.toFixed(2)}% (${surprise >= 0 ? 'Beat' : 'Miss'} by $${Math.abs(surprise).toFixed(2)}) Calculated AI Score ${totalScore.toFixed(2)} Based on all context factors AI Rationale: ${reasons.map(reason => `${reason}`).join('')} `; }; /** * Handles PDF download functionality. */ window.downloadPDF = async () => { if (typeof window.jspdf === 'undefined' || typeof window.html2canvas === 'undefined') { console.error("PDF generation library not loaded."); alert('PDF generation library not loaded. Please try again later.'); return; } if (!elements.pdfContent) { console.error("PDF content container not found."); return; } const { jsPDF } = window.jspdf; try { const canvas = await html2canvas(elements.pdfContent, { scale: 2, backgroundColor: null }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgWidth / imgHeight; const finalImgWidth = pdfWidth - 20; // A4 width with 10mm margins const finalImgHeight = finalImgWidth / ratio; pdf.addImage(imgData, 'PNG', 10, 10, finalImgWidth, finalImgHeight); pdf.save(`AI_Prediction_Report_${elements.ticker.value.toUpperCase() || 'STOCK'}.pdf`); } catch (error) { console.error('Error generating PDF:', error); alert('An error occurred while generating the PDF.'); } }; // --- EVENT LISTENERS --- elements.prevButton.addEventListener('click', () => navigateTabs(-1)); elements.nextButton.addEventListener('click', () => navigateTabs(1)); // --- INITIALIZATION --- changeTab(1); });