Investment Bias Detection System

Investment Bias Detection System

Paste any investment thesis, article, or commentary to analyze for common cognitive biases.

Awaiting Analysis

Enter some text and click "Detect Biases" to see the results.

Triggering Phrases:

"${bias.evidence.join('", "')}"

`; }); resultsHtml += '
'; resultsContainer.innerHTML = resultsHtml; } initialMessage.classList.add('hidden'); resultsContainer.classList.remove('hidden'); pdfButtonContainer.classList.remove('hidden'); }; analyzeBtn.addEventListener('click', () => { const text = textInput.value; if (text.trim()) { lastAnalysisData = analyzeBiases(text); displayAnalysis(lastAnalysisData); } }); downloadPdfBtn.addEventListener('click', () => { if (!lastAnalysisData) return; const { jsPDF } = window.jspdf; const { analyzedText, biases } = lastAnalysisData; const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pageW = doc.internal.pageSize.getWidth(); const margin = 50; let y = 0; // PDF Header doc.setFillColor('#f8fafc'); // slate-50 doc.rect(0, 0, pageW, 70, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(22); doc.setTextColor('#0f172a'); // slate-900 doc.text('Investment Bias Analysis Report', margin, 45); y = 100; // Analyzed Text Section doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.setTextColor('#334155'); // slate-700 doc.text('Analyzed Text', margin, y); y += 15; doc.setFont('helvetica', 'normal'); doc.setFontSize(10); doc.setTextColor('#475569'); // slate-600 doc.setFillColor('#f1f5f9'); // slate-100 const textLines = doc.splitTextToSize(analyzedText, pageW - margin * 2 - 20); doc.rect(margin, y, pageW - margin * 2, textLines.length * 12 + 20, 'F'); doc.text(textLines, margin + 10, y + 15); y += textLines.length * 12 + 40; // Bias Detection Results doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor('#1e293b'); // slate-800 doc.text('Bias Detection Summary', margin, y); y += 10; if (biases.length === 0) { doc.setFontSize(12); doc.setTextColor('#16a34a'); // green-600 doc.text('No strong indicators of common biases were detected.', margin, y + 15); } else { const tableBody = biases.map(b => [ b.name, b.risk, b.evidence.join(', ') ]); doc.autoTable({ startY: y, head: [['Cognitive Bias', 'Risk Level', 'Evidence']], body: tableBody, theme: 'striped', headStyles: { fillColor: '#0284c7' }, // sky-600 styles: { font: 'helvetica', fontSize: 10 }, didParseCell: function (data) { if (data.column.dataKey === 1) { // Risk Level column if (data.cell.raw === 'High') data.cell.styles.textColor = '#dc2626'; if (data.cell.raw === 'Moderate') data.cell.styles.textColor = '#f97316'; if (data.cell.raw === 'Low') data.cell.styles.textColor = '#f59e0b'; } } }); } // Footer const date = `Report Generated: ${new Date().toLocaleDateString('en-US')}`; doc.setFontSize(9); doc.setTextColor('#64748b'); // slate-500 doc.text(date, pageW / 2, doc.internal.pageSize.getHeight() - 20, { align: 'center' }); doc.save('Investment_Bias_Report.pdf'); }); });
Scroll to Top