# Title: ISDA Quantitative Engine Mathematical & Data Overhaul ## Goal Transform the climate risk engine from a heuristic-based approximation model into a mathematically rigorous, ISDA-compliant valuation framework. Eliminate theoretical "fudging", correct NGFS data scaling errors, and ensure that all market scenarios accurately map to formal reference data and baseline dataset snapshots instead of arbitrary values. ## Proposed Steps ### 1. Data Governance & Entity Relational Mapping - **Create `firm_reference_data` table:** Implement a Security Master mechanism (SQLite or CSV) mapping `asset_code` to specific ISDA Firmographics (`gics_sector`, `credit_rating`, `ksic_code`). - **Load Firmographic Reference Data**: Implement logic in `base_market_data_loader.py` to join against this robust catalog, replacing all previous Python `lambda` arbitrary sector mapping. ### 2. Market Data Integration (ISDA Baseline) - **JSONB Parsing**: Extract the pre-evaluated market dataset snapshot (`spots` & `vols`) from the `eval_datasets` Postgres table. - **Bind True Starting State ($V_0$ & $\sigma_0$)**: Substitute all uniformly hardcoded constants ($V_{base} = 100.0, \sigma_V = 0.20$) with actual market prices and observed implied volatilities for precise baseline setting (e.g., Samsung Electronics `56300`). ### 3. Quantitative Formulation Overhaul - **Merton Model Rectification**: Halt arbitrary scalar amplifications of Firm Asset Volatility ($\sigma_V$). Restore $\sigma_V$ as an invariant across normal & stressed environments so equity spread amplification triggers organically via capital structural leverage ($V/E \cdot N(d_1)$). - **Hull-White 1-Factor Correct Pricing Formula**: Replace simplistic Beta curve increments. Implement the precise Affine Term Structure $B(0, T)$ Zero Rate formulation factoring mean reversion (`hw_kappa`). - **NGFS Percentage Recalibration**: Divide structural NGFS policy inputs by 100 to map them into formal decimal yield configurations (`0.0525` instead of `5.25`), aligning seamlessly with HW mathematical bounds. ### 4. UI & Presentation Integration - Extend existing frontend (`App.jsx`) and API serialization (`main.py`) to expose accurate curve `Tenor` fields explicitly. - Render accurate HW mathematical formulas on the guidance panels corresponding to the reformed backend physics. ## Testing & Verification - Manually review `engine_results` and JSON API outputs to verify newly produced PVs and Deltas align with expected Quant characteristics. - Ensure the UI adequately parses `Tenor` without exceptions.