Visualization Functions¶
Plotly chart generation functions.
CEFR Charts¶
fundedness.viz.waterfall.create_cefr_waterfall(cefr_result, show_liability=True, title='CEFR Calculation Breakdown', height=500, width=None)
¶
Create a waterfall chart showing CEFR calculation breakdown.
Shows: Gross Assets → Tax Haircut → Liquidity Haircut → Reliability Haircut → Net Assets Optionally shows liability comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cefr_result
|
CEFRResult
|
CEFR calculation result |
required |
show_liability
|
bool
|
Whether to show liability PV for comparison |
True
|
title
|
str
|
Chart title |
'CEFR Calculation Breakdown'
|
height
|
int
|
Chart height in pixels |
500
|
width
|
int | None
|
Chart width in pixels (None = responsive) |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/waterfall.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 | |
Simulation Charts¶
fundedness.viz.fan_chart.create_fan_chart(years, percentiles, title='Wealth Projection', y_label='Portfolio Value ($)', show_median_line=True, show_floor=None, height=500, width=None)
¶
Create a fan chart showing percentile bands over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
ndarray
|
Array of year values (x-axis) |
required |
percentiles
|
dict[str, ndarray]
|
Dictionary mapping percentile names to value arrays Expected keys: "P10", "P25", "P50", "P75", "P90" |
required |
title
|
str
|
Chart title |
'Wealth Projection'
|
y_label
|
str
|
Y-axis label |
'Portfolio Value ($)'
|
show_median_line
|
bool
|
Whether to show a distinct median line |
True
|
show_floor
|
float | None
|
Optional floor value to show as horizontal line |
None
|
height
|
int
|
Chart height in pixels |
500
|
width
|
int | None
|
Chart width in pixels (None = responsive) |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/fan_chart.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 | |
fundedness.viz.survival.create_survival_curve(years, survival_prob, floor_survival_prob=None, title='Portfolio Survival Probability', threshold_years=None, height=450, width=None)
¶
Create a survival curve showing probability of not running out of money.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
ndarray
|
Array of year values |
required |
survival_prob
|
ndarray
|
Probability of portfolio survival at each year (above ruin) |
required |
floor_survival_prob
|
ndarray | None
|
Probability of being above spending floor at each year |
None
|
title
|
str
|
Chart title |
'Portfolio Survival Probability'
|
threshold_years
|
list[int] | None
|
Years to highlight with vertical lines (e.g., [20, 30]) |
None
|
height
|
int
|
Chart height in pixels |
450
|
width
|
int | None
|
Chart width in pixels |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/survival.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 | |
fundedness.viz.histogram.create_time_distribution_histogram(time_to_event, event_name='Ruin', planning_horizon=None, percentiles_to_show=None, title=None, height=400, width=None)
¶
Create a histogram of time-to-event distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_to_event
|
ndarray
|
Array of time values (years until event, inf for no event) |
required |
event_name
|
str
|
Name of the event (e.g., "Ruin", "Floor Breach") |
'Ruin'
|
planning_horizon
|
int | None
|
Maximum planning horizon (for x-axis) |
None
|
percentiles_to_show
|
list[int] | None
|
Percentiles to mark (e.g., [10, 50, 90]) |
None
|
title
|
str | None
|
Chart title (auto-generated if None) |
None
|
height
|
int
|
Chart height in pixels |
400
|
width
|
int | None
|
Chart width in pixels |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/histogram.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 | |
Comparison Charts¶
fundedness.viz.comparison.create_strategy_comparison_chart(years, strategies, metric='wealth_median', title='Strategy Comparison', y_label='Portfolio Value ($)', height=500, width=None)
¶
Create a line chart comparing multiple strategies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
ndarray
|
Array of year values |
required |
strategies
|
dict[str, dict[str, ndarray]]
|
Dictionary mapping strategy name to metrics dict Each metrics dict should contain arrays for the requested metric |
required |
metric
|
str
|
Which metric to plot (e.g., "wealth_median", "spending_median") |
'wealth_median'
|
title
|
str
|
Chart title |
'Strategy Comparison'
|
y_label
|
str
|
Y-axis label |
'Portfolio Value ($)'
|
height
|
int
|
Chart height in pixels |
500
|
width
|
int | None
|
Chart width in pixels |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/comparison.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 81 82 83 84 85 86 87 88 89 90 | |
Sensitivity Charts¶
fundedness.viz.tornado.create_tornado_chart(parameters, low_values, high_values, base_value, parameter_labels=None, title='Sensitivity Analysis', value_label='CEFR', height=500, width=None)
¶
Create a tornado chart for sensitivity analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
list[str]
|
List of parameter names |
required |
low_values
|
list[float]
|
Outcome values when parameter is at low end |
required |
high_values
|
list[float]
|
Outcome values when parameter is at high end |
required |
base_value
|
float
|
Baseline outcome value |
required |
parameter_labels
|
list[str] | None
|
Display labels for parameters (uses parameters if None) |
None
|
title
|
str
|
Chart title |
'Sensitivity Analysis'
|
value_label
|
str
|
Label for the outcome metric |
'CEFR'
|
height
|
int
|
Chart height in pixels |
500
|
width
|
int | None
|
Chart width in pixels |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in fundedness/viz/tornado.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 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 | |