Portfolio Hedging Tool

Portfolio Hedging Tool

Simulate the impact of a hedging asset on your portfolio's risk and return profile.

Configure your portfolio and hedging strategy, then run the calculation to see the results.

Hedged

${formatter(hedgedVal)}

`; }; dashboardResultsContainer.innerHTML = `
${createMetricCard('Annual Return', results.original.return, results.hedged.return, formatPercent, true)} ${createMetricCard('Annual Volatility', results.original.volatility, results.hedged.volatility, formatPercent, false)} ${createMetricCard('Sharpe Ratio', results.original.sharpe, results.hedged.sharpe, formatDecimal, true)} ${createMetricCard('Max Drawdown', results.original.maxDrawdown, results.hedged.maxDrawdown, formatPercent, false)}
`; // Render chart if (comparisonChart) comparisonChart.destroy(); const ctx = document.getElementById('comparison-chart').getContext('2d'); comparisonChart = new Chart(ctx, { type: 'line', data: { labels: Array.from({ length: results.original.path.length }, (_, i) => i), datasets: [ { label: 'Original Portfolio', data: results.original.path, borderColor: '#F59E0B', // amber-500 backgroundColor: 'transparent', pointRadius: 0, tension: 0.1 }, { label: 'Hedged Portfolio', data: results.hedged.path, borderColor: '#3B82F6', // blue-500 backgroundColor: 'transparent', pointRadius: 0, tension: 0.1 } ] }, options: { responsive: true, maintainAspectRatio: true, plugins: { title: { display: true, text: 'Simulated Portfolio Growth (1 Year)' } }, scales: { x: { display: false }, y: { ticks: { callback: v => `$${(v/1000).toFixed(0)}k` } } } } }); downloadPdfBtn.disabled = false; }; // --- PDF DOWNLOAD --- const handlePdfDownload = () => { const pdfContent = document.getElementById('pdf-content'); html2canvas(pdfContent, { scale: 2, backgroundColor: '#ffffff' }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'landscape', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const margin = 40; const contentWidth = pdfWidth - margin * 2; const canvasAspectRatio = canvas.width / canvas.height; const contentHeight = contentWidth / canvasAspectRatio; pdf.setFontSize(20); pdf.text("Portfolio Hedging Analysis Report", margin, margin); pdf.addImage(imgData, 'PNG', margin, margin + 20, contentWidth, contentHeight); pdf.save('Portfolio-Hedging-Report.pdf'); }); }; // --- EVENT LISTENERS --- window.switchTab = switchTab; window.navigateTabs = navigateTabs; calculateBtn.addEventListener('click', handleCalculation); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- INITIALIZATION --- updateNavButtons(); switchTab('dashboard'); });
Scroll to Top