Asset Drawdown Strategy Simulator
Asset Drawdown Simulation Results
Please complete the previous steps and click "Run Simulation" to see your results.
Important Assumptions & Notes:
- This is a simplified simulation. Actual investment returns, inflation, and fees can vary significantly year to year and may differ from your average assumptions.
- **Sequence of Returns Risk**: This model uses average returns and does not account for the critical impact of the sequence of good or bad returns, especially early in retirement. Negative returns early on can deplete a portfolio much faster than average return projections suggest.
- Withdrawals are assumed to occur at the end of each year, after investment growth and fees for that year are calculated.
- Taxes on withdrawals or investment gains are not considered in this simulation.
- This tool does not provide investment, financial planning, or tax advice. Consult with qualified professionals for personalized advice.
Funds remained after ${simulationPeriod} years.
`; summaryMsg += `Final Portfolio Value: ${formatCurrency(currentBalance)}
`; } summaryMsg += `Total Amount Withdrawn over ${fundsDepletedYear !== -1 && fundsDepletedYear < simulationPeriod ? fundsDepletedYear : simulationPeriod} years: ${formatCurrency(totalWithdrawn)}
`; simulationSummaryEl.innerHTML = summaryMsg; notesContainerEl.style.display = 'block'; downloadPdfBtn.style.display = 'block'; }); // PDF Download downloadPdfBtn?.addEventListener('click', function () { const { jsPDF } = window.jspdf; const pdfOutputArea = document.getElementById('dsPdfOutputArea'); if (!pdfOutputArea || simulationSummaryEl.innerHTML.includes("Please complete the previous steps")) { alert('Please run the simulation first before downloading PDF.'); return; } html2canvas(pdfOutputArea, { scale: 1.2, useCORS: true, backgroundColor: '#ffffff', windowWidth: pdfOutputArea.scrollWidth, windowHeight: pdfOutputArea.scrollHeight }) .then(canvas => { const imgData = canvas.toDataURL('image/jpeg', 0.85); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); // Changed to portrait A4 const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 30; let contentWidth = pdfWidth - 2 * margin; let contentHeight = pdfHeight - 2 * margin; const canvasWidth = canvas.width; const canvasHeight = canvas.height; // Calculate aspect ratio const imgRatio = canvasWidth / canvasHeight; const pdfRatio = contentWidth / contentHeight; let finalImgWidth, finalImgHeight; if (imgRatio > pdfRatio) { // Image is wider than target area finalImgWidth = contentWidth; finalImgHeight = finalImgWidth / imgRatio; } else { // Image is taller or same aspect ratio finalImgHeight = contentHeight; finalImgWidth = finalImgHeight * imgRatio; if (finalImgWidth > contentWidth) { // Recalc if too wide after height fit finalImgWidth = contentWidth; finalImgHeight = finalImgWidth / imgRatio; } } // Check if content is too small, then use its original size (but capped) if (canvasWidth < finalImgWidth && canvasHeight < finalImgHeight) { finalImgWidth = Math.min(canvasWidth, contentWidth); finalImgHeight = Math.min(canvasHeight, contentHeight); // Recalculate one dimension based on aspect ratio if one was capped if (finalImgWidth === contentWidth && (finalImgWidth / imgRatio < finalImgHeight) ) finalImgHeight = finalImgWidth / imgRatio; else if (finalImgHeight === contentHeight && (finalImgHeight * imgRatio < finalImgWidth)) finalImgWidth = finalImgHeight * imgRatio; } const x = (pdfWidth - finalImgWidth) / 2; let y = margin; // If image is still larger than one page, it will be clipped. // For truly multi-page, more complex logic for splitting canvas or multiple html2canvas calls needed. // This is a single-page capture. pdf.addImage(imgData, 'JPEG', x, y, finalImgWidth, finalImgHeight, undefined, 'MEDIUM'); pdf.save('Asset_Drawdown_Simulation.pdf'); }) .catch(err => { console.error("Error generating PDF:", err); alert("Error generating PDF. See console for details."); }); }); // Initial Setup switchTab('portfolioTab'); });