|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Monte Carlo Projection</title> |
| 7 | + <link rel="stylesheet" href="styles.css"> |
| 8 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.min.js"></script> |
| 9 | + <script> |
| 10 | + function switchTab(method) { |
| 11 | + // Update tab buttons |
| 12 | + const tabButtons = document.querySelectorAll('.tab-button'); |
| 13 | + tabButtons.forEach(btn => btn.classList.remove('active')); |
| 14 | + event.target.classList.add('active'); |
| 15 | + |
| 16 | + // Update tab panels |
| 17 | + const percentageTab = document.getElementById('percentageTab'); |
| 18 | + const fixedTab = document.getElementById('fixedTab'); |
| 19 | + |
| 20 | + if (method === 'percentage') { |
| 21 | + percentageTab.style.display = 'block'; |
| 22 | + fixedTab.style.display = 'none'; |
| 23 | + document.getElementById('percentageRadio').checked = true; |
| 24 | + } else { |
| 25 | + percentageTab.style.display = 'none'; |
| 26 | + fixedTab.style.display = 'block'; |
| 27 | + document.getElementById('fixedRadio').checked = true; |
| 28 | + } |
| 29 | + } |
| 30 | + </script> |
| 31 | +</head> |
| 32 | +<body> |
| 33 | + <div class="container"> |
| 34 | + <h1>Monte Carlo Projection</h1> |
| 35 | + <div class="subtitle">Investment Projection with 100,000 Simulations</div> |
| 36 | + |
| 37 | + <div class="controls"> |
| 38 | + <!-- Investment Parameters Section --> |
| 39 | + <h3>Investment Parameters</h3> |
| 40 | + <div class="investment-params"> |
| 41 | + <div class="params-row"> |
| 42 | + <div class="control-group"> |
| 43 | + <label for="initialInvestment">Initial Investment ($)</label> |
| 44 | + <input type="text" id="initialInvestment" value="1,000,000"> |
| 45 | + </div> |
| 46 | + <div class="control-group"> |
| 47 | + <label for="expectedReturn">Expected Annual Return (%)</label> |
| 48 | + <input type="number" id="expectedReturn" value="17" step="0.1" min="0"> |
| 49 | + </div> |
| 50 | + <div class="control-group"> |
| 51 | + <label for="volatility">Annual Volatility (σ) (%)</label> |
| 52 | + <input type="number" id="volatility" value="20" step="0.1" min="0"> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + <div class="params-row" style="margin-top: 20px;"> |
| 56 | + <div class="control-group"> |
| 57 | + <label for="yearsProjection">Years to Project</label> |
| 58 | + <input type="number" id="yearsProjection" value="30" min="1" max="50"> |
| 59 | + </div> |
| 60 | + <div class="control-group"> |
| 61 | + <label for="withdrawalStartYear">Withdraw from the end of __ years</label> |
| 62 | + <input type="number" id="withdrawalStartYear" value="6" min="1" max="50" title="Enter the year when withdrawals should start. Year 1 means withdrawals start at the end of the first year."> |
| 63 | + <small style="color: #636e72; font-size: 0.8em; margin-top: 2px;">Year 1 = end of first year</small> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + |
| 68 | + <!-- Withdrawal Method Tabs --> |
| 69 | + <div class="withdrawal-section"> |
| 70 | + <h3>Withdrawal Method</h3> |
| 71 | + <div class="tabs"> |
| 72 | + <button class="tab-button active" onclick="switchTab('percentage')">Percentage of Portfolio</button> |
| 73 | + <button class="tab-button" onclick="switchTab('fixed')">Fixed Amount with Inflation</button> |
| 74 | + </div> |
| 75 | + |
| 76 | + <!-- Hidden radio buttons for maintaining compatibility --> |
| 77 | + <div style="display: none;"> |
| 78 | + <input type="radio" name="withdrawalMethod" value="percentage" id="percentageRadio" checked> |
| 79 | + <input type="radio" name="withdrawalMethod" value="fixed" id="fixedRadio"> |
| 80 | + </div> |
| 81 | + |
| 82 | + <div class="tab-content"> |
| 83 | + <div id="percentageTab" class="tab-panel active"> |
| 84 | + <div class="control-group"> |
| 85 | + <label for="withdrawalRate">Annual Withdrawal Rate (%)</label> |
| 86 | + <input type="number" id="withdrawalRate" value="3" step="0.1" min="0" max="100"> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + |
| 90 | + <div id="fixedTab" class="tab-panel" style="display: none;"> |
| 91 | + <div class="control-group"> |
| 92 | + <label for="fixedWithdrawalAmount">Starting Annual Withdrawal ($)</label> |
| 93 | + <input type="text" id="fixedWithdrawalAmount" value="40,000"> |
| 94 | + </div> |
| 95 | + <div class="control-group"> |
| 96 | + <label for="inflationRate">Annual Inflation Rate (%)</label> |
| 97 | + <input type="number" id="inflationRate" value="2.5" step="0.1" min="0" max="20"> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + |
| 104 | + <div style="text-align: center; margin-top: 30px;"> |
| 105 | + <button onclick="runSimulation()">Run Simulation</button> |
| 106 | + </div> |
| 107 | + |
| 108 | + <div id="loading" class="loading" style="display: none;"> |
| 109 | + Running 100,000 simulations... Please wait... |
| 110 | + </div> |
| 111 | + |
| 112 | + <div id="results" style="display: none;"> |
| 113 | + <div class="results"> |
| 114 | + <div class="stat-card"> |
| 115 | + <div class="stat-label">Median Outcome (50th percentile)</div> |
| 116 | + <div class="stat-value" id="median">-</div> |
| 117 | + </div> |
| 118 | + <div class="stat-card"> |
| 119 | + <div class="stat-label">Mean Outcome</div> |
| 120 | + <div class="stat-value" id="mean">-</div> |
| 121 | + </div> |
| 122 | + <div class="stat-card"> |
| 123 | + <div class="stat-label">Best Case (95th percentile)</div> |
| 124 | + <div class="stat-value" id="best">-</div> |
| 125 | + </div> |
| 126 | + <div class="stat-card"> |
| 127 | + <div class="stat-label">Worst Case (5th percentile)</div> |
| 128 | + <div class="stat-value" id="worst">-</div> |
| 129 | + </div> |
| 130 | + <div class="stat-card"> |
| 131 | + <div class="stat-label">Withdrawal Strategy</div> |
| 132 | + <div class="stat-value" id="annualWithdrawalRate">-</div> |
| 133 | + </div> |
| 134 | + <div class="stat-card"> |
| 135 | + <div class="stat-label">Withdrawal Start Year</div> |
| 136 | + <div class="stat-value" id="withdrawalStartYearDisplay">-</div> |
| 137 | + </div> |
| 138 | + <div class="stat-card" style="grid-column: span 2;"> |
| 139 | + <div class="stat-label">Portfolio Depletion Rate</div> |
| 140 | + <div class="stat-value" id="depletionRate">-</div> |
| 141 | + </div> |
| 142 | + <div class="stat-card" style="grid-column: span 2;"> |
| 143 | + <div class="stat-label">Total Withdrawn (Median Case)</div> |
| 144 | + <div class="stat-value" id="totalWithdrawn">-</div> |
| 145 | + </div> |
| 146 | + </div> |
| 147 | + |
| 148 | + <div class="charts-container"> |
| 149 | + <div class="chart-wrapper"> |
| 150 | + <div class="chart-title">Distribution of Final Values</div> |
| 151 | + <canvas id="histogramChart"></canvas> |
| 152 | + </div> |
| 153 | + <div class="chart-wrapper"> |
| 154 | + <div class="chart-title">Sample Simulation Paths (100 paths)</div> |
| 155 | + <canvas id="pathsChart"></canvas> |
| 156 | + </div> |
| 157 | + </div> |
| 158 | + |
| 159 | + <div class="probability-table"> |
| 160 | + <div class="chart-title">Median Outcome Details</div> |
| 161 | + <table> |
| 162 | + <thead> |
| 163 | + <tr> |
| 164 | + <th>Year</th> |
| 165 | + <th>Value</th> |
| 166 | + <th>Return Rate</th> |
| 167 | + <th>Withdrawal Amount</th> |
| 168 | + <th>Actual Withdrawal Rate</th> |
| 169 | + <th>Total Withdrawn</th> |
| 170 | + </tr> |
| 171 | + </thead> |
| 172 | + <tbody id="medianTableBody"> |
| 173 | + </tbody> |
| 174 | + </table> |
| 175 | + </div> |
| 176 | + |
| 177 | + <div class="probability-table"> |
| 178 | + <div class="chart-title">Probability Analysis</div> |
| 179 | + <table> |
| 180 | + <thead> |
| 181 | + <tr> |
| 182 | + <th>Target Value</th> |
| 183 | + <th>Probability of Exceeding</th> |
| 184 | + <th>Multiple of Initial Investment</th> |
| 185 | + </tr> |
| 186 | + </thead> |
| 187 | + <tbody id="probabilityTableBody"> |
| 188 | + </tbody> |
| 189 | + </table> |
| 190 | + </div> |
| 191 | + </div> |
| 192 | + </div> |
| 193 | + |
| 194 | + <script src="script.js"></script> |
| 195 | +</body> |
| 196 | +</html> |
0 commit comments