Data Models¶
Pydantic models for representing financial data.
Assets¶
fundedness.models.assets.Asset
¶
Bases: BaseModel
A single asset holding.
Source code in fundedness/models/assets.py
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 | |
unrealized_gain
property
¶
Calculate unrealized gain/loss if cost basis is known.
validate_cost_basis(v, info)
classmethod
¶
Warn if cost basis exceeds value (unrealized loss).
Source code in fundedness/models/assets.py
84 85 86 87 88 | |
fundedness.models.assets.AccountType
¶
Bases: str, Enum
Tax treatment of an account.
Source code in fundedness/models/assets.py
9 10 11 12 13 14 15 | |
fundedness.models.assets.LiquidityClass
¶
Bases: str, Enum
Liquidity classification for assets.
Source code in fundedness/models/assets.py
28 29 30 31 32 33 34 35 36 | |
fundedness.models.assets.ConcentrationLevel
¶
Bases: str, Enum
Concentration/diversification level.
Source code in fundedness/models/assets.py
39 40 41 42 43 44 45 | |
Balance Sheet¶
fundedness.models.assets.BalanceSheet
¶
Bases: BaseModel
Collection of assets representing a household's balance sheet.
Source code in fundedness/models/assets.py
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 | |
by_account_type
property
¶
Total value by account type.
by_asset_class
property
¶
Total value by asset class.
by_liquidity_class
property
¶
Total value by liquidity class.
total_value
property
¶
Total market value of all assets.
get_bond_allocation()
¶
Calculate percentage allocated to bonds.
Source code in fundedness/models/assets.py
141 142 143 144 145 146 147 148 | |
get_stock_allocation()
¶
Calculate percentage allocated to stocks.
Source code in fundedness/models/assets.py
132 133 134 135 136 137 138 139 | |
Liabilities¶
fundedness.models.liabilities.Liability
¶
Bases: BaseModel
A future spending obligation or liability.
Source code in fundedness/models/liabilities.py
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 | |
duration_years
property
¶
Duration of the liability in years, if end_year is specified.
get_inflation_rate(base_cpi=0.025)
¶
Get the effective inflation rate for this liability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_cpi
|
float
|
Base CPI inflation rate assumption |
0.025
|
Returns:
| Type | Description |
|---|---|
float
|
Effective annual inflation rate as decimal |
Source code in fundedness/models/liabilities.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
Household¶
fundedness.models.household.Household
¶
Bases: BaseModel
A household unit for financial planning.
Source code in fundedness/models/household.py
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 | |
discretionary_spending
property
¶
Total annual discretionary spending.
essential_spending
property
¶
Total annual essential spending.
planning_horizon
property
¶
Planning horizon based on longest-lived member.
primary_member
property
¶
Get the primary household member.
total_assets
property
¶
Total asset value.
total_spending
property
¶
Total annual spending target.
fundedness.models.household.Person
¶
Bases: BaseModel
An individual person in the household.
Source code in fundedness/models/household.py
11 12 13 14 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 | |
planning_horizon
property
¶
Total years in planning horizon.
years_in_retirement
property
¶
Expected years in retirement.
years_to_retirement
property
¶
Years until retirement (0 if already retired).
validate_ages()
¶
Validate age relationships.
Source code in fundedness/models/household.py
55 56 57 58 59 60 61 62 63 | |
Market Model¶
fundedness.models.market.MarketModel
¶
Bases: BaseModel
Market return and risk assumptions.
Source code in fundedness/models/market.py
9 10 11 12 13 14 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 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
expected_portfolio_return(stock_weight, bond_weight=None)
¶
Calculate expected return for a portfolio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stock_weight
|
float | ndarray
|
Weight in stocks (0-1), scalar or array |
required |
bond_weight
|
float | ndarray | None
|
Weight in bonds (remainder is cash if not specified) |
None
|
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Expected annual real return (scalar or array matching input) |
Source code in fundedness/models/market.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
get_cholesky_decomposition()
¶
Get Cholesky decomposition for correlated returns generation.
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower triangular Cholesky matrix |
Source code in fundedness/models/market.py
131 132 133 134 135 136 137 138 | |
get_correlation_matrix()
¶
Get the correlation matrix for asset classes.
Returns:
| Type | Description |
|---|---|
ndarray
|
4x4 correlation matrix for [stocks, bonds, cash, real_estate] |
Source code in fundedness/models/market.py
102 103 104 105 106 107 108 109 110 111 112 113 | |
get_covariance_matrix()
¶
Get the covariance matrix for asset classes.
Returns:
| Type | Description |
|---|---|
ndarray
|
4x4 covariance matrix for [stocks, bonds, cash, real_estate] |
Source code in fundedness/models/market.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
portfolio_volatility(stock_weight, bond_weight=None)
¶
Calculate portfolio volatility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stock_weight
|
float | ndarray
|
Weight in stocks (0-1), scalar or array |
required |
bond_weight
|
float | ndarray | None
|
Weight in bonds (remainder is cash if not specified) |
None
|
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Annual portfolio volatility (scalar or array matching input) |
Source code in fundedness/models/market.py
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 | |
validate_dof(v)
classmethod
¶
Ensure degrees of freedom is reasonable.
Source code in fundedness/models/market.py
94 95 96 97 98 99 100 | |
Simulation Config¶
fundedness.models.simulation.SimulationConfig
¶
Bases: BaseModel
Configuration for Monte Carlo simulations.
Source code in fundedness/models/simulation.py
12 13 14 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 | |
get_percentile_labels()
¶
Get formatted percentile labels.
Source code in fundedness/models/simulation.py
78 79 80 | |
Tax Model¶
fundedness.models.tax.TaxModel
¶
Bases: BaseModel
Tax rates and assumptions.
Source code in fundedness/models/tax.py
8 9 10 11 12 13 14 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 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 | |
total_ltcg_rate
property
¶
Combined federal + state + NIIT long-term capital gains rate.
total_ordinary_rate
property
¶
Combined federal + state ordinary income tax rate.
get_effective_tax_rate(account_type, cost_basis_ratio=None)
¶
Get the effective tax rate for withdrawals from an account type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_type
|
AccountType
|
Type of account |
required |
cost_basis_ratio
|
float | None
|
Cost basis as fraction of value (for taxable accounts) |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Effective tax rate as decimal (0-1) |
Source code in fundedness/models/tax.py
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 | |
get_haircut_by_account_type()
¶
Get tax haircut factors by account type.
Returns:
| Type | Description |
|---|---|
dict[AccountType, float]
|
Dictionary mapping account type to (1 - tax_rate) |
Source code in fundedness/models/tax.py
114 115 116 117 118 119 120 121 122 123 124 125 | |