Initial extraction from monorepo
This commit is contained in:
commit
f7ef7ca4ab
56 changed files with 6163 additions and 0 deletions
31
fire_planner/reporters/cli.py
Normal file
31
fire_planner/reporters/cli.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Pretty terminal output for `fire-planner simulate`."""
|
||||
from __future__ import annotations
|
||||
|
||||
from fire_planner.scenarios import ScenarioSpec
|
||||
from fire_planner.simulator import SimulationResult
|
||||
|
||||
|
||||
def format_scenario(spec: ScenarioSpec, result: SimulationResult) -> str:
|
||||
"""Return a multi-line string summarising one scenario's MC output."""
|
||||
lines = [
|
||||
f"Scenario: {spec.external_id}",
|
||||
f" jurisdiction = {spec.jurisdiction}",
|
||||
f" strategy = {spec.strategy}",
|
||||
f" leave_uk_year = {spec.leave_uk_year}",
|
||||
f" glide_path = {spec.glide_path}",
|
||||
f" starting_nw_gbp = {spec.nw_seed_gbp:>12,.0f}",
|
||||
f" spending_target = {spec.spending_gbp:>12,.0f}",
|
||||
f" horizon_years = {spec.horizon_years}",
|
||||
" ----",
|
||||
f" paths = {result.n_paths:>12,}",
|
||||
f" success_rate = {result.success_rate*100:>11.2f}%",
|
||||
f" p10_ending_gbp = {result.ending_percentile(10):>12,.0f}",
|
||||
f" p50_ending_gbp = {result.ending_percentile(50):>12,.0f}",
|
||||
f" p90_ending_gbp = {result.ending_percentile(90):>12,.0f}",
|
||||
f" median_lifetime_tax = {result.median_lifetime_tax():>12,.0f}",
|
||||
]
|
||||
ytr = result.median_years_to_ruin()
|
||||
if ytr is not None:
|
||||
lines.append(f" median_years_to_ruin= {ytr:>12.1f}")
|
||||
lines.append(f" seq_risk_correlation= {result.sequence_risk_correlation():>12.4f}")
|
||||
return "\n".join(lines)
|
||||
Loading…
Add table
Add a link
Reference in a new issue