Simulated AI Stock Screener

Simulated AI Stock Screener

Filter stocks based on financial and simulated AI metrics.

Simulated AI Filters

Apply filters to see simulated results.

No stocks match your criteria.

'; downloadPdfBtn.classList.add('hidden'); return; } downloadPdfBtn.classList.remove('hidden'); const table = document.createElement('table'); table.className = 'results-table w-full'; const thead = table.createTHead(); const headerRow = thead.insertRow(); const headers = ['Symbol', 'Company Name', 'Sector', 'Exchange', 'Market Cap ($B)', 'P/E Ratio', 'AI Growth', 'AI Sentiment', 'AI Risk']; headers.forEach(text => { const th = document.createElement('th'); th.textContent = text; headerRow.appendChild(th); }); const tbody = table.createTBody(); results.forEach(stock => { const row = tbody.insertRow(); row.insertCell().textContent = stock.symbol; row.insertCell().textContent = stock.name; row.insertCell().textContent = stock.sector; row.insertCell().textContent = stock.exchange; row.insertCell().textContent = stock.marketCap.toFixed(1); row.insertCell().textContent = stock.peRatio.toFixed(1); row.insertCell().textContent = stock.aiGrowthScore; row.insertCell().textContent = stock.aiSentiment; row.insertCell().textContent = stock.aiRisk; }); resultsOutput.appendChild(table); } modifyCriteriaBtn.addEventListener('click', () => { hideMessage(); switchTab('screeningCriteria'); }); downloadPdfBtn.addEventListener('click', () => { if (currentFilteredResults.length === 0) { showMessage("No results to download.", "info"); return; } hideMessage(); if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { console.error('jsPDF library is not loaded.'); showMessage("Error: PDF library (jsPDF) could not be loaded.", "error"); return; } const { jsPDF: JSPDFConstructor } = window.jspdf; const doc = new JSPDFConstructor({ orientation: 'landscape', unit: 'pt', format: 'a4' }); if (typeof doc.autoTable !== 'function') { console.error('CRITICAL: doc.autoTable is NOT a function. The jspdf-autotable plugin likely failed to initialize or attach to jsPDF instances.'); console.log('--- Dignostic Information ---'); console.log(`1. typeof window.jspdf: ${typeof window.jspdf}`); if (window.jspdf) { console.log(`2. typeof window.jspdf.jsPDF (constructor): ${typeof window.jspdf.jsPDF}`); if (window.jspdf.jsPDF && window.jspdf.jsPDF.API) { console.log(`3. typeof window.jspdf.jsPDF.API (prototype alias): ${typeof window.jspdf.jsPDF.API}`); console.log(`4. typeof window.jspdf.jsPDF.API.autoTable (expected plugin location): ${typeof window.jspdf.jsPDF.API.autoTable}`); } else if (window.jspdf.jsPDF) { console.log(`3. window.jspdf.jsPDF.API is not defined.`); } } console.log(`5. typeof window.jspdfAutoTable (alternate global): ${typeof window.jspdfAutoTable}`); // This was a typo in previous logs, should be jspdfAutoTable if it exists if(typeof window.jspdfAutoTable === 'object' && window.jspdfAutoTable !== null) { // Checking the typo version console.log(`6. typeof window.jspdfAutoTable.autoTable (if global is an object): ${typeof window.jspdfAutoTable.autoTable}`); console.log(`7. typeof window.jspdfAutoTable.default (if global is object with default export): ${typeof window.jspdfAutoTable.default}`); } // Also check specifically for window.autoTable as some plugins might use that console.log(`8. typeof window.autoTable (direct global): ${typeof window.autoTable}`); console.log('--- End Dignostic Information ---'); showMessage("Error: PDF generation failed because the autoTable function is not available. Please check the browser console for details.", "error"); return; } const title = "Simulated AI Stock Screener Results"; const timestamp = `Generated: ${new Date().toLocaleString()}`; doc.setFontSize(18); doc.text(title, doc.internal.pageSize.getWidth() / 2, 40, { align: 'center' }); doc.setFontSize(10); doc.text(timestamp, doc.internal.pageSize.getWidth() / 2, 60, { align: 'center' }); const tableHeaders = [['Symbol', 'Company Name', 'Sector', 'Exchange', 'Market Cap ($B)', 'P/E Ratio', 'AI Growth', 'AI Sentiment', 'AI Risk']]; const tableBody = currentFilteredResults.map(stock => [ stock.symbol, stock.name, stock.sector, stock.exchange, stock.marketCap.toFixed(1), stock.peRatio.toFixed(1), stock.aiGrowthScore, stock.aiSentiment, stock.aiRisk ]); const autoTableOptions = { head: tableHeaders, body: tableBody, startY: 80, theme: 'striped', headStyles: { fillColor: [22, 160, 133], textColor: [255,255,255], fontStyle: 'bold' }, styles: { fontSize: 8, cellPadding: 4 }, alternateRowStyles: { fillColor: [240, 240, 240] }, }; try { doc.autoTable(autoTableOptions); doc.save('simulated_ai_stock_screener_results.pdf'); showMessage("PDF download initiated.", "success"); } catch (e) { console.error("Error during PDF generation or save: ", e); showMessage("Failed to generate or save PDF. See console for details.", "error"); } }); const initialActiveTab = document.querySelector('.tab-nav-item.active'); if (initialActiveTab) { const initialTabContentId = initialActiveTab.dataset.tab + 'Content'; const initialTabContent = document.getElementById(initialTabContentId); if (initialTabContent) initialTabContent.classList.add('active'); } else { const firstTabNav = document.querySelector('.tab-nav-item'); const firstTabContent = document.querySelector('.tab-content'); if (firstTabNav && firstTabContent) { firstTabNav.classList.add('active'); firstTabContent.classList.add('active'); } } });
Scroll to Top