deena-lad/climate-risk-quant
π Climate Risk Quantification for Financial Assets
Map physical climate hazards to asset-level financial exposure β built to the same standard as MSCI ESG and ECB stress-test frameworks.
   
Motivation
Physical climate risk β floods, extreme heat, cyclones β is now a material financial risk. The TCFD framework requires institutional investors to disclose exposure, and the ECB has conducted mandatory climate stress tests since 2022. Yet most public implementations either stop at data visualisation or rely on proprietary black-box scores.
This project builds a transparent, auditable, end-to-end pipeline that:
- Ingests 30+ years of ERA5 reanalysis climate data (global, 0.25Β° resolution)
- Maps three physical hazards to the exact coordinates of each financial asset
- Produces normalised, sector-weighted climate risk scores (0β100)
- Computes risk-adjusted portfolio valuations and Monte Carlo Climate VaR
- Exposes every parameter to the analyst via an interactive dashboard
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA SOURCES β
β ERA5 / CDS API βββΊ NetCDF grids Company CSV βββΊ lat/lon β
ββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INGESTION (src/pipeline/ingest.py) β
β cdsapi download β xarray lazy load β pydantic asset validation β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PREPROCESSING (src/pipeline/preprocess.py) β
β Clip β monthly max β annual max β unit convert β tidy parquet β
β 30-yr climatology: ΞΌ, Ο, p95 per grid cell β z-score β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FEATURE ENGINEERING (src/pipeline/features.py) β
β KD-tree snap to ERA5 grid β spatial join β compound flag β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MODEL (src/model/) β
β HazardScorer: RobustScaler + percentile rank β 0-100 β
β CompositeRiskModel: sector-weighted average + PCA diagnostic β
β AnomalyDetector: IsolationForest tail-risk flagging β
β Valuation: linear/convex haircut + Monte Carlo Climate VaR β
β Evaluate: Gini, KS test, tail concentration, weight sensitivityβ
β MLflow: experiment tracking + artifact store β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DASHBOARD (app/streamlit_app.py) β
β Risk Map β Score Analysis β Valuation β Scorecard β Diagnosticsβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββQuick Start (local, 4 commands)
git clone https://github.com/deena-lad/climate-risk-quant.git && cd climate-risk-quant
pip install -r requirements.txt && pip install -e .
cp .env.example .env # add your CDS_API_KEY (optional for demo mode)
streamlit run app/streamlit_app.pyOpen http://localhost:8501 β the dashboard loads with synthetic data instantly, no ERA5 download required.
Live Demo
π [https://huggingface.co/spaces/deena-lad/climate-risk-quant](https://huggingface.co/spaces/deena-lad/climate-risk-quant)
Results / Key Findings
All numbers below are from the 200-asset synthetic demo run (seed=42, Ξ±=0.30):
Sector findings: Real Estate and Utilities carry the highest absolute haircuts due to fixed asset locations in coastal/tropical exposure zones. Energy shows highest cyclone sensitivity from offshore infrastructure.
Weight sensitivity: Gini is stable (Β± 0.05) across 200 random weight combinations β the composite score is robust to reasonable weight uncertainty, a key requirement for model validation sign-off.
Tech Stack
Skills Demonstrated
ERA5 / NetCDF Β· xarray Β· GeoPandas Β· rioxarray Β· Spatial joins Β· KD-tree indexing Β· ESG analytics Β· Physical risk modelling Β· TCFD Β· Climate VaR Β· Monte Carlo simulation Β· scikit-learn Β· IsolationForest Β· PCA diagnostics Β· MLflow experiment tracking Β· Plotly Β· Streamlit Β· Docker multi-stage builds Β· HuggingFace Spaces Β· pydantic Β· pytest Β· GitHub Actions CI/CD Β· Conventional Commits
Repo Structure
climate-risk-quant/
βββ README.md
βββ requirements.txt # 40 pinned packages
βββ pyproject.toml # ruff + mypy + pytest config
βββ .env.example # all env vars documented
βββ Dockerfile # multi-stage: builder β runtime
βββ .dockerignore
βββ .streamlit/
β βββ config.toml # port 7860, theme, fast reruns
β
βββ src/
β βββ config.py # pydantic-settings singleton
β βββ pipeline/
β β βββ ingest.py # ERA5 download + asset loader + synthetic gen
β β βββ preprocess.py # clip β resample β unit convert β climatology
β β βββ features.py # spatial join β hazard scores β ESG tier
β β βββ validate.py # 10 data quality checks
β βββ model/
β β βββ scorer.py # HazardScorer, CompositeRiskModel, AnomalyDetector
β β βββ valuation.py # haircut, portfolio NAV, Climate VaR, sector attr
β β βββ evaluate.py # Gini, KS, tail conc., MLflow logging, sensitivity
β β βββ artifacts.py # joblib save/load, run metadata
β β βββ pipeline.py # run_pipeline() end-to-end orchestrator
β βββ viz/
β βββ charts.py # 10 Plotly figure builders
β
βββ app/
β βββ streamlit_app.py # 5-tab dashboard, 10+ interactive elements
β βββ components/
β βββ sidebar.py # SidebarConfig dataclass + all widgets
β βββ metrics_row.py # 6 KPI metric cards
β
βββ notebooks/
β βββ data_exploration.ipynb # 7 EDA charts with interpretation notes
β
βββ tests/
β βββ test_pipeline.py # 30+ pipeline unit tests
β βββ test_model.py # 40+ model unit tests, full integration test
β
βββ .github/
βββ workflows/
βββ ci.yml # lint β test β docker build β (deploy to HF)Future Improvements
- Scenario analysis: Extend beyond historical ERA5 to CMIP6 SSP2-4.5 and SSP5-8.5 climate projections (2050/2100 horizons), enabling forward-looking TCFD Scope 3 disclosures.
- Asset-level granularity: Replace company centroids with building-level footprint polygons (OpenStreetMap) for real-estate portfolios, enabling flood inundation depth estimates rather than proximity scores.
- Transition risk overlay: Add a carbon-price sensitivity module using NGFS transition scenarios so users can see physical + transition risk on a single dashboard β the dual lens required by TCFD.
- Live ERA5 updates: Schedule a monthly CDS API pull via GitHub Actions so the dashboard always reflects the most recent completed climate year without manual intervention.
- Regulatory report export: Auto-generate a TCFD-aligned PDF risk report (asset table + heatmap + VaR) using
reportlab, reducing analyst copy-paste time from dashboard to board presentation.
References and Data Sources
Setup & Contributing
See SETUP.md for full local setup instructions. See DEPLOY.md for HuggingFace Spaces deployment.
Contributions welcome β please follow Conventional Commits and ensure pytest passes before opening a PR.
