Core Functions¶
The main calculation and simulation functions.
CEFR Calculation¶
fundedness.cefr.compute_cefr(household=None, balance_sheet=None, liabilities=None, tax_model=None, planning_horizon=None, real_discount_rate=0.02, base_inflation=0.025)
¶
Compute the Certainty-Equivalent Funded Ratio (CEFR).
CEFR = Σ(Asset × (1-τ) × λ × ρ) / PV(Liabilities)
Where
τ = tax rate λ = liquidity factor ρ = reliability factor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household
|
Household | None
|
Complete household model (alternative to separate components) |
None
|
balance_sheet
|
BalanceSheet | None
|
Asset holdings (if household not provided) |
None
|
liabilities
|
list[Liability] | None
|
Future spending obligations (if household not provided) |
None
|
tax_model
|
TaxModel | None
|
Tax rate assumptions (defaults to TaxModel()) |
None
|
planning_horizon
|
int | None
|
Years to plan for (defaults to household horizon or 30) |
None
|
real_discount_rate
|
float
|
Real discount rate for liability PV |
0.02
|
base_inflation
|
float
|
Base inflation assumption |
0.025
|
Returns:
| Type | Description |
|---|---|
CEFRResult
|
CEFRResult with complete breakdown |
Source code in fundedness/cefr.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
Monte Carlo Simulation¶
fundedness.simulate.run_simulation(initial_wealth, annual_spending, config, stock_weight=0.6, spending_floor=None, inflation_rate=0.025)
¶
Run Monte Carlo simulation of retirement portfolio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_wealth
|
float
|
Starting portfolio value |
required |
annual_spending
|
float | ndarray
|
Annual spending (constant or array by year) |
required |
config
|
SimulationConfig
|
Simulation configuration |
required |
stock_weight
|
float | ndarray
|
Allocation to stocks (constant or array by year) |
0.6
|
spending_floor
|
float | None
|
Minimum acceptable spending (for floor breach tracking) |
None
|
inflation_rate
|
float
|
Annual inflation rate for real spending |
0.025
|
Returns:
| Type | Description |
|---|---|
SimulationResult
|
SimulationResult with all paths and metrics |
Source code in fundedness/simulate.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
Strategy Comparison¶
fundedness.withdrawals.comparison.compare_strategies(policies, initial_wealth, config, stock_weight=0.6, starting_age=65, spending_floor=None)
¶
Compare multiple withdrawal strategies using the same random draws.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policies
|
list[WithdrawalPolicy]
|
List of withdrawal policies to compare |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
config
|
SimulationConfig
|
Simulation configuration |
required |
stock_weight
|
float
|
Asset allocation to stocks |
0.6
|
starting_age
|
int
|
Starting age for age-based strategies |
65
|
spending_floor
|
float | None
|
Minimum acceptable spending |
None
|
Returns:
| Type | Description |
|---|---|
StrategyComparisonResult
|
StrategyComparisonResult with all results and metrics |
Source code in fundedness/withdrawals/comparison.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |