AI-Powered Multi-Asset Portfolio Stress Testing Tool

AI-Powered Multi-Asset Portfolio Stress Testing Tool

Evaluate your portfolio's performance under severe market stress scenarios.

Portfolio Composition

Asset Name Asset Class Value ($)

Market Stress Scenario

Post-Stress Value

${formatCurrency(postStressValue)}

AI-Powered Recommendation

${recommendation}

Asset Class Performance

`; renderImpactChart(classTotals); } function renderImpactChart(classTotals) { const ctx = document.getElementById('impactChart')?.getContext('2d'); if (!ctx) return; if (chartInstance) chartInstance.destroy(); const labels = Object.keys(classTotals); const preData = labels.map(l => classTotals[l].pre); const postData = labels.map(l => classTotals[l].post); chartInstance = new Chart(ctx, { type: 'bar', data: { labels: labels, datasets: [ { label: 'Pre-Stress Value', data: preData, backgroundColor: '#9ca3af', // gray-400 }, { label: 'Post-Stress Value', data: postData, backgroundColor: '#3b82f6', // blue-500 } ] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: value => '$' + (value / 1000) + 'k' } } }, plugins: { title: { display: true, text: 'Asset Class Value: Pre- vs. Post-Stress' }, tooltip: { callbacks: { label: c => `${c.dataset.label}: $${c.raw.toLocaleString()}`}} } } }); } // --- PDF Download --- function downloadPDF() { const pdfElement = document.getElementById('pdf-output'); if (!pdfElement) return alert("Could not find content to download."); const originalBg = pdfElement.style.backgroundColor; pdfElement.style.backgroundColor = 'white'; const { jsPDF } = window.jspdf; html2canvas(pdfElement, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }) .then(canvas => { pdfElement.style.backgroundColor = originalBg; const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'px', format: [canvas.width, canvas.height] }); pdf.addImage(imgData, 'PNG', 0, 0, canvas.width, canvas.height); pdf.save('Portfolio-Stress-Test-Report.pdf'); }).catch(err => { pdfElement.style.backgroundColor = originalBg; console.error("PDF Generation Error:", err); alert("An error occurred while generating the PDF."); }); }
Scroll to Top