Merton Optimal API Reference¶
This module provides Merton's optimal consumption and portfolio choice formulas.
Core Functions¶
fundedness.merton.merton_optimal_allocation(market_model, utility_model)
¶
Calculate Merton optimal equity allocation.
The Merton formula gives the optimal fraction to invest in risky assets: k* = (mu - r) / (gamma * sigma^2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters including risk aversion |
required |
Returns:
| Type | Description |
|---|---|
float
|
Optimal equity allocation as decimal (can exceed 1.0 for leveraged) |
Source code in fundedness/merton.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
fundedness.merton.certainty_equivalent_return(market_model, utility_model, equity_allocation=None)
¶
Calculate certainty equivalent return for a portfolio.
The certainty equivalent return is the guaranteed return that provides the same expected utility as the risky portfolio: rce = r + k(mu - r) - gammak^2*sigma^2/2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters including risk aversion |
required |
equity_allocation
|
float | None
|
Equity allocation (uses optimal if None) |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Certainty equivalent return as decimal |
Source code in fundedness/merton.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
fundedness.merton.merton_optimal_spending_rate(market_model, utility_model, remaining_years=None)
¶
Calculate Merton optimal spending rate.
The optimal spending rate for an infinite horizon is: c* = rce - (rce - rtp) / gamma
For finite horizons, the rate is adjusted upward as horizon shortens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters including risk aversion and time preference |
required |
remaining_years
|
float | None
|
Years until planning horizon ends (None for infinite) |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Optimal spending rate as decimal (e.g., 0.03 = 3%) |
Source code in fundedness/merton.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
fundedness.merton.wealth_adjusted_optimal_allocation(wealth, market_model, utility_model, min_allocation=0.0, max_allocation=1.0)
¶
Calculate wealth-adjusted optimal equity allocation.
Near the subsistence floor, the optimal allocation approaches zero because the investor cannot afford to take risk. As wealth rises above the floor, allocation approaches the unconstrained Merton optimal.
The formula is: k_adjusted = k* * (W - F) / W
Where W is wealth and F is the subsistence floor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float
|
Current portfolio value |
required |
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters |
required |
min_allocation
|
float
|
Minimum equity allocation (floor) |
0.0
|
max_allocation
|
float
|
Maximum equity allocation (ceiling) |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
Adjusted equity allocation as decimal, bounded by min/max |
Source code in fundedness/merton.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 | |
fundedness.merton.calculate_merton_optimal(wealth, market_model, utility_model, remaining_years=None)
¶
Calculate all Merton optimal values for given wealth.
This is the main entry point for getting all optimal policy parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float
|
Current portfolio value |
required |
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters |
required |
remaining_years
|
float | None
|
Years until planning horizon ends |
None
|
Returns:
| Type | Description |
|---|---|
MertonOptimalResult
|
MertonOptimalResult with all optimal values |
Source code in fundedness/merton.py
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 | |
Helper Functions¶
fundedness.merton.optimal_spending_by_age(market_model, utility_model, starting_age, end_age=100)
¶
Calculate optimal spending rates for each age.
Spending rate increases with age as the remaining horizon shortens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters |
required |
starting_age
|
int
|
Current age |
required |
end_age
|
int
|
Assumed maximum age |
100
|
Returns:
| Type | Description |
|---|---|
dict[int, float]
|
Dictionary mapping age to optimal spending rate |
Source code in fundedness/merton.py
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 | |
fundedness.merton.optimal_allocation_by_wealth(market_model, utility_model, wealth_levels, min_allocation=0.0, max_allocation=1.0)
¶
Calculate optimal allocation for a range of wealth levels.
Useful for generating allocation curves showing how equity percentage should vary with distance from subsistence floor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_model
|
MarketModel
|
Market return and risk assumptions |
required |
utility_model
|
UtilityModel
|
Utility parameters |
required |
wealth_levels
|
ndarray
|
Array of wealth values to calculate for |
required |
min_allocation
|
float
|
Minimum equity allocation |
0.0
|
max_allocation
|
float
|
Maximum equity allocation |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of optimal allocations corresponding to wealth_levels |
Source code in fundedness/merton.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
Data Classes¶
fundedness.merton.MertonOptimalResult
dataclass
¶
Results from Merton optimal calculations.
Source code in fundedness/merton.py
24 25 26 27 28 29 30 31 32 33 | |
Spending Policies¶
fundedness.withdrawals.merton_optimal.MertonOptimalSpendingPolicy
dataclass
¶
Bases: BaseWithdrawalPolicy
Spending policy based on Merton optimal consumption theory.
This policy determines spending by applying the Merton optimal spending rate to current wealth, adjusted for the remaining time horizon.
Key characteristics: - Spending rate starts low (~2-3%) and rises with age - Rate depends on risk aversion, time preference, and market assumptions - Adapts to actual wealth (not locked to initial withdrawal amount) - Optional smoothing to reduce year-to-year volatility
Attributes:
| Name | Type | Description |
|---|---|---|
market_model |
MarketModel
|
Market return and risk assumptions |
utility_model |
UtilityModel
|
Utility parameters including risk aversion |
starting_age |
int
|
Age at retirement/simulation start |
end_age |
int
|
Assumed maximum age for planning |
smoothing_factor |
float
|
Blend current with previous spending (0-1, 0=no smoothing) |
min_spending_rate |
float
|
Minimum spending rate floor |
max_spending_rate |
float
|
Maximum spending rate ceiling |
Source code in fundedness/withdrawals/merton_optimal.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 | |
calculate_withdrawal(context)
¶
Calculate withdrawal using Merton optimal spending rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
WithdrawalContext
|
Current state information |
required |
Returns:
| Type | Description |
|---|---|
WithdrawalDecision
|
WithdrawalDecision with amount and metadata |
Source code in fundedness/withdrawals/merton_optimal.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
get_initial_withdrawal(initial_wealth)
¶
Calculate first year withdrawal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_wealth
|
float
|
Starting portfolio value |
required |
Returns:
| Type | Description |
|---|---|
float
|
First year withdrawal amount |
Source code in fundedness/withdrawals/merton_optimal.py
129 130 131 132 133 134 135 136 137 138 139 140 | |
get_optimal_rate(remaining_years)
¶
Get the optimal spending rate for given remaining years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remaining_years
|
float
|
Years until end of planning horizon |
required |
Returns:
| Type | Description |
|---|---|
float
|
Optimal spending rate as decimal |
Source code in fundedness/withdrawals/merton_optimal.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
get_spending(wealth, year, initial_wealth)
¶
Get spending for simulation (vectorized interface).
This method is used by the Monte Carlo simulation engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
ndarray
|
Current portfolio values (n_simulations,) |
required |
year
|
int
|
Current simulation year |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Spending amounts for each simulation path |
Source code in fundedness/withdrawals/merton_optimal.py
142 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 | |
fundedness.withdrawals.merton_optimal.SmoothedMertonPolicy
dataclass
¶
Bases: MertonOptimalSpendingPolicy
Merton optimal with aggressive smoothing for stable spending.
This variant applies stronger smoothing to reduce spending volatility, trading off some optimality for a more stable spending experience.
Source code in fundedness/withdrawals/merton_optimal.py
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 | |
get_spending(wealth, year, initial_wealth)
¶
Get smoothed spending for simulation.
Uses exponential smoothing of the optimal spending amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
ndarray
|
Current portfolio values |
required |
year
|
int
|
Current simulation year |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Smoothed spending amounts |
Source code in fundedness/withdrawals/merton_optimal.py
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 | |
fundedness.withdrawals.merton_optimal.FloorAdjustedMertonPolicy
dataclass
¶
Bases: MertonOptimalSpendingPolicy
Merton optimal that accounts for subsistence floor in spending.
This variant only applies the optimal rate to wealth above the floor-supporting level, ensuring floor spending is always protected.
Source code in fundedness/withdrawals/merton_optimal.py
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 279 280 281 282 283 284 285 286 | |
get_spending(wealth, year, initial_wealth)
¶
Get spending that protects floor for several years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
ndarray
|
Current portfolio values |
required |
year
|
int
|
Current simulation year |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Floor-protected spending amounts |
Source code in fundedness/withdrawals/merton_optimal.py
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 279 280 281 282 283 284 285 286 | |
Allocation Policies¶
fundedness.allocation.merton_optimal.MertonOptimalAllocationPolicy
dataclass
¶
Allocation policy based on Merton optimal portfolio theory.
This policy determines equity allocation using the Merton formula, with adjustments for wealth level relative to subsistence floor.
Key characteristics: - Base allocation from Merton: k* = (mu - r) / (gamma * sigma^2) - Allocation decreases as wealth approaches subsistence floor - Configurable bounds to prevent extreme positions
Attributes:
| Name | Type | Description |
|---|---|---|
market_model |
MarketModel
|
Market return and risk assumptions |
utility_model |
UtilityModel
|
Utility parameters including risk aversion |
min_equity |
float
|
Minimum equity allocation |
max_equity |
float
|
Maximum equity allocation |
use_wealth_adjustment |
bool
|
Whether to reduce allocation near floor |
Source code in fundedness/allocation/merton_optimal.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_allocation(wealth, year, initial_wealth)
¶
Get the optimal stock allocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float | ndarray
|
Current portfolio value(s) |
required |
year
|
int
|
Current year in simulation (not used but required by interface) |
required |
initial_wealth
|
float
|
Starting portfolio value (not used but required) |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Stock allocation as decimal (0-1), scalar or array matching wealth |
Source code in fundedness/allocation/merton_optimal.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_unconstrained_allocation()
¶
Get the unconstrained Merton optimal allocation.
Returns:
| Type | Description |
|---|---|
float
|
Optimal equity allocation (may exceed bounds) |
Source code in fundedness/allocation/merton_optimal.py
46 47 48 49 50 51 52 | |
fundedness.allocation.merton_optimal.WealthBasedAllocationPolicy
dataclass
¶
Allocation that varies with wealth relative to floor.
This is a simplified version that linearly interpolates between a minimum allocation at the floor and maximum at a target wealth.
More intuitive than full Merton but captures the key insight that risk capacity depends on distance from subsistence.
Attributes:
| Name | Type | Description |
|---|---|---|
floor_wealth |
float
|
Wealth level at which equity is at minimum |
target_wealth |
float
|
Wealth level at which equity reaches maximum |
min_equity |
float
|
Equity allocation at floor |
max_equity |
float
|
Equity allocation at target and above |
Source code in fundedness/allocation/merton_optimal.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_allocation(wealth, year, initial_wealth)
¶
Get allocation based on current wealth level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float | ndarray
|
Current portfolio value(s) |
required |
year
|
int
|
Current year (not used) |
required |
initial_wealth
|
float
|
Starting value (not used) |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Stock allocation interpolated by wealth |
Source code in fundedness/allocation/merton_optimal.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
fundedness.allocation.merton_optimal.FloorProtectionAllocationPolicy
dataclass
¶
Allocation that increases equity as wealth grows above floor.
Inspired by CPPI (Constant Proportion Portfolio Insurance), this policy allocates equity as a multiple of the "cushion" (wealth above the floor-protection level).
Attributes:
| Name | Type | Description |
|---|---|---|
utility_model |
UtilityModel
|
For subsistence floor value |
multiplier |
float
|
Equity = multiplier * (wealth - floor_reserve) / wealth |
floor_years |
int
|
Years of floor spending to protect |
min_equity |
float
|
Minimum equity allocation |
max_equity |
float
|
Maximum equity allocation |
Source code in fundedness/allocation/merton_optimal.py
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 | |
get_allocation(wealth, year, initial_wealth)
¶
Get allocation based on cushion above floor reserve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float | ndarray
|
Current portfolio value(s) |
required |
year
|
int
|
Current year (not used) |
required |
initial_wealth
|
float
|
Starting value (not used) |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Stock allocation based on cushion |
Source code in fundedness/allocation/merton_optimal.py
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 | |
get_floor_reserve()
¶
Get the wealth level that protects floor spending.
Returns:
| Type | Description |
|---|---|
float
|
Wealth needed to fund floor spending for floor_years |
Source code in fundedness/allocation/merton_optimal.py
179 180 181 182 183 184 185 | |
Policy Optimization¶
fundedness.optimize.PolicyParameterSpec
dataclass
¶
Specification for an optimizable policy parameter.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Parameter name (must match policy attribute) |
min_value |
float
|
Minimum allowed value |
max_value |
float
|
Maximum allowed value |
initial_value |
float | None
|
Starting value for optimization |
is_integer |
bool
|
Whether parameter should be rounded to integer |
Source code in fundedness/optimize.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
clip(value)
¶
Clip value to bounds and optionally round.
Source code in fundedness/optimize.py
43 44 45 46 47 48 | |
get_initial()
¶
Get initial value (midpoint if not specified).
Source code in fundedness/optimize.py
37 38 39 40 41 | |
fundedness.optimize.OptimizationResult
dataclass
¶
Results from policy optimization.
Attributes:
| Name | Type | Description |
|---|---|---|
optimal_params |
dict[str, float]
|
Dictionary of optimal parameter values |
optimal_utility |
float
|
Expected lifetime utility at optimum |
certainty_equivalent |
float
|
Certainty equivalent consumption at optimum |
success_rate |
float
|
Success rate at optimal parameters |
iterations |
int
|
Number of optimization iterations |
convergence_history |
list[float]
|
Utility values during optimization |
final_simulation |
Any
|
Full simulation result at optimum |
Source code in fundedness/optimize.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
fundedness.optimize.optimize_spending_policy(policy_class, param_specs, initial_wealth, allocation_policy, config, utility_model, base_params=None, spending_floor=None, method='nelder-mead', max_iterations=50)
¶
Optimize spending policy parameters to maximize utility.
Uses scipy.optimize to search over policy parameters, evaluating each candidate via Monte Carlo simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy_class
|
type
|
Spending policy class to optimize |
required |
param_specs
|
list[PolicyParameterSpec]
|
Parameters to optimize |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
allocation_policy
|
Any
|
Fixed allocation policy to use |
required |
config
|
SimulationConfig
|
Simulation configuration |
required |
utility_model
|
UtilityModel
|
Utility model for evaluation |
required |
base_params
|
dict | None
|
Fixed parameters for the policy |
None
|
spending_floor
|
float | None
|
Minimum spending floor |
None
|
method
|
str
|
Optimization method (nelder-mead, powell, etc.) |
'nelder-mead'
|
max_iterations
|
int
|
Maximum optimization iterations |
50
|
Returns:
| Type | Description |
|---|---|
OptimizationResult
|
OptimizationResult with optimal parameters and metrics |
Source code in fundedness/optimize.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 | |
fundedness.optimize.optimize_allocation_policy(policy_class, param_specs, initial_wealth, spending_policy, config, utility_model, base_params=None, spending_floor=None, method='nelder-mead', max_iterations=50)
¶
Optimize allocation policy parameters to maximize utility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy_class
|
type
|
Allocation policy class to optimize |
required |
param_specs
|
list[PolicyParameterSpec]
|
Parameters to optimize |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
spending_policy
|
Any
|
Fixed spending policy to use |
required |
config
|
SimulationConfig
|
Simulation configuration |
required |
utility_model
|
UtilityModel
|
Utility model for evaluation |
required |
base_params
|
dict | None
|
Fixed parameters for the policy |
None
|
spending_floor
|
float | None
|
Minimum spending floor |
None
|
method
|
str
|
Optimization method |
'nelder-mead'
|
max_iterations
|
int
|
Maximum iterations |
50
|
Returns:
| Type | Description |
|---|---|
OptimizationResult
|
OptimizationResult with optimal parameters and metrics |
Source code in fundedness/optimize.py
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 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
fundedness.optimize.optimize_combined_policy(spending_policy_class, allocation_policy_class, spending_param_specs, allocation_param_specs, initial_wealth, config, utility_model, spending_base_params=None, allocation_base_params=None, spending_floor=None, method='nelder-mead', max_iterations=100)
¶
Jointly optimize spending and allocation policy parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spending_policy_class
|
type
|
Spending policy class |
required |
allocation_policy_class
|
type
|
Allocation policy class |
required |
spending_param_specs
|
list[PolicyParameterSpec]
|
Spending parameters to optimize |
required |
allocation_param_specs
|
list[PolicyParameterSpec]
|
Allocation parameters to optimize |
required |
initial_wealth
|
float
|
Starting portfolio value |
required |
config
|
SimulationConfig
|
Simulation configuration |
required |
utility_model
|
UtilityModel
|
Utility model for evaluation |
required |
spending_base_params
|
dict | None
|
Fixed spending policy parameters |
None
|
allocation_base_params
|
dict | None
|
Fixed allocation policy parameters |
None
|
spending_floor
|
float | None
|
Minimum spending floor |
None
|
method
|
str
|
Optimization method |
'nelder-mead'
|
max_iterations
|
int
|
Maximum iterations |
100
|
Returns:
| Type | Description |
|---|---|
OptimizationResult
|
OptimizationResult with optimal parameters for both policies |
Source code in fundedness/optimize.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |