fire-planner/fire_planner/geo.py
Viktor Barzin edb4d11352
Some checks are pending
Build and Push / lint-and-test (push) Waiting to run
Build and Push / build (push) Blocked by required conditions
Build and Push / deploy (push) Blocked by required conditions
Build and Push / notify-failure (push) Blocked by required conditions
feat(fire-target): per-Case FIRE-number solver for the retirement countdown
Add a Monte-Carlo "FIRE number" solver so the wealth dashboard can show a £
countdown to retirement across life-stage cases, in today's money.

Viktor wants to see, per country, how far his net worth is from being able to
retire for good under three cases — Solo (his spend ×1.5), Household (+Anca
×1.5), Family (+2 kids) — with cost-of-living re-scaling per country and a 99%
Guyton-Klinger success bar.

- spend_model: per-Case real-GBP spend, COL-scaled (rent + non-rent essentials
  scale by country; Holidays fixed), ×1.5 safety. Constants sourced live from
  actualbudget (Viktor) / on-record (Anca).
- geo: city -> tax jurisdiction (nomad fallback).
- fire_target: binary-search the smallest LIQUID net worth where GK reaches the
  bar; pension modelled as a tranche unlocking at ~57, kids ramp + optional home
  as cashflows. New fire_target table (migration 0007) + idempotent upsert.
- recompute-fire-targets CLI: solve every Case x country and persist for Grafana.
- CONTEXT.md glossary + ADR-0001 (why MC-threshold on liquid NW, not 25x spend).

Reuses the existing simulator unchanged (its cashflow hooks already supported
pension/kids/home). 345 tests pass; mypy + ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 11:49:23 +00:00

29 lines
1.1 KiB
Python

"""Map a COL city slug to a tax jurisdiction the simulator models.
Cities without a dedicated tax engine fall back to ``nomad`` (a neutral 1%
regulatory-premium regime) — a deliberate, documented approximation. Adding a
real regime (e.g. Portugal NHR, Greece, Spain Beckham) is a separate change;
until then their countdown targets carry the nomad assumption.
"""
from __future__ import annotations
# Only slugs whose jurisdiction has a dedicated engine in `tax/`. Everything
# else (Lisbon, Porto, Athens, Tallinn, Tbilisi, Madrid, Valencia, Singapore,
# Taipei, Bali, Medellin, Mexico City, Bucharest, Ho Chi Minh City) -> nomad.
CITY_JURISDICTION: dict[str, str] = {
"sofia": "bulgaria",
"limassol": "cyprus",
"bangkok": "thailand",
"chiang-mai": "thailand",
"kuala-lumpur": "malaysia",
"penang": "malaysia",
"dubai": "uae",
"london": "uk",
}
FALLBACK_JURISDICTION = "nomad"
def jurisdiction_for_city(slug: str) -> str:
"""Return the tax-jurisdiction key for a COL city slug (``nomad`` if none)."""
return CITY_JURISDICTION.get(slug, FALLBACK_JURISDICTION)