|
1 | 1 | # Integrated Risk App (Python) |
2 | 2 |
|
3 | | -An interactive **Streamlit web app** that brings together **market risk** and **credit risk** analytics in one tool — built from scratch in Python. |
4 | | -It demonstrates the ability to design, code, and validate professional risk models, including VaR/ES, backtesting, stress testing, and credit Expected Loss. |
| 3 | +Model Risk Validation Sandbox for Market & Credit Risk (Python) |
5 | 4 |
|
6 | | -## 📸 Screenshots |
| 5 | +This project is a model-risk–oriented risk analytics engine designed to measure, validate, and document market and credit risk models in a manner consistent with institutional risk management and model validation practices. |
7 | 6 |
|
8 | | -**1. Market Risk Backtest (VaR & Exceptions)** |
9 | | - |
10 | | -*Shows daily portfolio returns vs. the 99% VaR threshold. Red dots = exceedances. Used to validate if the model’s predicted risk matches actual losses (Kupiec POF test).* |
| 7 | +The focus is not on building a dashboard, but on demonstrating rigorous risk modeling, backtesting, and governance-aware design, with clear assumptions, diagnostics, and limitations. |
11 | 8 |
|
12 | | -**2. Credit Risk — Expected Loss (Batch)** |
13 | | - |
14 | | -*Aggregates Probability of Default (PD), Loss Given Default (LGD), and Exposure at Default (EAD) across facilities. Displays total expected losses and a breakdown by segment, useful for monitoring credit portfolios.* |
| 9 | +## 🎯 Project Objective (North Star) |
| 10 | + |
| 11 | +Build a validation-ready risk engine that computes core risk measures (VaR, ES, Expected Loss) and evaluates their reliability using standard model risk diagnostics. |
| 12 | + |
| 13 | +This repository is structured to resemble how pensions, model risk teams, and risk consultancies organize and review quantitative risk models. |
| 14 | + |
| 15 | +## 📌 Scope (What This Project Intentionally Covers) |
| 16 | +Market Risk |
| 17 | + |
| 18 | +Value-at-Risk (VaR) and Expected Shortfall (ES) |
| 19 | + |
| 20 | +Methods: |
| 21 | + |
| 22 | +Historical Simulation |
| 23 | + |
| 24 | +Parametric (Normal) |
| 25 | + |
| 26 | +Monte Carlo |
| 27 | + |
| 28 | +Filtered Historical (GARCH-lite) |
| 29 | + |
| 30 | +Rolling window estimation |
| 31 | + |
| 32 | +Backtesting using Kupiec Proportion-of-Failures (POF) test |
| 33 | + |
| 34 | +Multi-confidence-level calibration (e.g. 95%, 99%) |
| 35 | + |
| 36 | +Credit Risk |
| 37 | + |
| 38 | +Expected Loss (EL) framework: |
| 39 | + |
| 40 | +Probability of Default (PD) |
| 41 | + |
| 42 | +Loss Given Default (LGD) |
| 43 | + |
| 44 | +Exposure at Default (EAD) |
15 | 45 |
|
16 | | -Interactive Streamlit app for market & credit risk: |
17 | | -- VaR/ES: Historical, Parametric (Normal), Monte Carlo, GARCH-lite (Filtered Historical) |
18 | | -- Backtesting: rolling VaR with Kupiec POF test + multi-alpha calibration |
19 | | -- Analytics: correlation heatmap, VaR decomposition, what-if weights |
20 | | -- Stress & Scenarios: equity shocks, rates (duration), correlation bumps, historical window replay |
21 | | -- Credit: Expected Loss (batch) |
22 | | -- Risk Budgeting: Equal Risk Contribution (ERC) |
| 46 | +Batch portfolio-level aggregation |
| 47 | + |
| 48 | +Segment-level loss breakdown for monitoring |
| 49 | + |
| 50 | +Stress & Scenario Analysis |
| 51 | + |
| 52 | +Deterministic equity shocks |
| 53 | + |
| 54 | +Interest-rate shocks using duration approximations |
| 55 | + |
| 56 | +Correlation stress |
| 57 | + |
| 58 | +Historical window replay |
| 59 | + |
| 60 | +## 🚫 Out of Scope (By Design) |
| 61 | + |
| 62 | +To preserve clarity and rigor, this project does not attempt to be: |
| 63 | + |
| 64 | +A trading or portfolio optimization system |
| 65 | + |
| 66 | +A real-time production risk engine |
| 67 | + |
| 68 | +A regulatory-approved model |
| 69 | + |
| 70 | +Advanced extensions (e.g. factor models, ALM, optimization) are intentionally deferred. |
| 71 | + |
| 72 | +🖥 Application Interface |
| 73 | + |
| 74 | +A lightweight Streamlit interface is provided only as a viewer to: |
| 75 | + |
| 76 | +Run models with selected parameters |
| 77 | + |
| 78 | +Visualize backtests and stress results |
| 79 | + |
| 80 | +Inspect outputs interactively |
| 81 | + |
| 82 | +All core modeling logic resides outside the UI to ensure separation between model logic and presentation. |
23 | 83 |
|
24 | 84 | **Live Demo:** <https://integrated-risk-app.onrender.com/> |
25 | 85 |
|
26 | | -## ⚡ Quickstart |
| 86 | +📸 Example Outputs |
27 | 87 |
|
28 | | -Clone the repo, install dependencies, and launch the app: |
| 88 | +Market Risk Backtesting (VaR & Exceptions) |
| 89 | +Daily portfolio returns plotted against the VaR threshold. |
| 90 | +Red points represent exceedances used in Kupiec backtesting. |
| 91 | + |
| 92 | +Credit Risk – Expected Loss (Batch) |
| 93 | +Aggregated EL with breakdown by segment, illustrating portfolio-level credit exposure. |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +## 🧠 Methodology Overview |
| 98 | + |
| 99 | +VaR: loss threshold exceeded with probability |
| 100 | +1 |
| 101 | +− |
| 102 | +𝛼 |
| 103 | +1−α |
| 104 | + |
| 105 | +Expected Shortfall: average loss conditional on VaR exceedance |
| 106 | + |
| 107 | +Kupiec POF Test: statistical test for unconditional coverage |
| 108 | + |
| 109 | +Filtered Historical Simulation: volatility-adjusted return filtering |
| 110 | + |
| 111 | +Expected Loss: |
| 112 | +PD |
| 113 | +× |
| 114 | +LGD |
| 115 | +× |
| 116 | +EAD |
| 117 | +PD×LGD×EAD |
| 118 | + |
| 119 | +All models follow a loss-based convention (risk measures reported as positive loss values). |
| 120 | + |
| 121 | +## 🧪 Validation & Testing Philosophy |
| 122 | + |
| 123 | +This project emphasizes model validation, not just model output. |
| 124 | + |
| 125 | +Unit tests verify: |
| 126 | + |
| 127 | +Monotonicity of VaR across confidence levels |
| 128 | + |
| 129 | +ES ≥ VaR under consistent loss conventions |
| 130 | + |
| 131 | +Correct behavior of backtesting logic |
| 132 | + |
| 133 | +Credit EL aggregation consistency |
| 134 | + |
| 135 | +Backtesting results are interpretable and reproducible |
| 136 | + |
| 137 | +Assumptions and limitations are explicitly acknowledged |
| 138 | + |
| 139 | +## ⚙️ Tech Stack |
| 140 | + |
| 141 | +Python — core modeling language |
| 142 | + |
| 143 | +Streamlit — lightweight interface |
| 144 | + |
| 145 | +Pandas / NumPy — data handling and numerical computation |
| 146 | + |
| 147 | +SciPy / Statsmodels — statistical modeling |
| 148 | + |
| 149 | +Plotly — interactive visualization |
| 150 | + |
| 151 | +yfinance — market data (demo use only) |
| 152 | + |
| 153 | +## ⚡ Quickstart |
29 | 154 |
|
30 | 155 | ```bash |
31 | 156 | git clone https://github.com/sensor-aae/Integrated-Risk-App.git |
32 | 157 | cd Integrated-Risk-App |
33 | | -python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate |
| 158 | + |
| 159 | +python -m venv .venv |
| 160 | +source .venv/bin/activate # Windows: .venv\Scripts\activate |
| 161 | + |
34 | 162 | pip install -r requirements.txt |
35 | 163 | streamlit run app/app.py |
36 | 164 | ``` |
37 | | -## 🛠 Tech Stack |
38 | 165 |
|
39 | | -- **Python** — core language for all risk modeling |
40 | | -- **Streamlit** — interactive web app framework |
41 | | -- **Pandas & NumPy** — data handling, returns, matrix math |
42 | | -- **Plotly** — dynamic charts (backtests, stress tests, EL by segment) |
43 | | -- **yfinance** — market data source for demo |
44 | | -- **SciPy / Statsmodels** — statistics & GARCH-lite modeling |
| 166 | +Demo datasets are included so the app can be explored immediately. |
45 | 167 |
|
46 | | -Demo CSVs are included in data/ so you can click around immediately. |
| 168 | +## 📄 Documentation |
47 | 169 |
|
48 | | -## 📊 How it works |
| 170 | +A Model Risk Report (methodology, assumptions, validation results, and limitations) is maintained in the /docs directory and is intended to mirror institutional model documentation standards. |
49 | 171 |
|
50 | | -VaR = loss threshold at confidence level α. |
| 172 | +## ⚠️ Disclaimer |
51 | 173 |
|
52 | | -ES = average loss beyond VaR. |
| 174 | +This project is for educational and demonstrative purposes only. |
| 175 | +It is not intended for production use or investment decision-making. |
53 | 176 |
|
54 | | -Kupiec test = checks if exceedances match expectation. |
| 177 | +## ⭐ Why This Project Exists |
55 | 178 |
|
56 | | -FHS (GARCH-lite) = filters volatility for better tail calibration. |
| 179 | +This repository is designed as a work sample for roles in: |
57 | 180 |
|
58 | | -ERC weights = equalize each asset’s risk contribution. |
| 181 | +Risk Analytics |
59 | 182 |
|
60 | | -## ⚠️ Disclaimer |
61 | | -For educational use only. Not investment advice. |
| 183 | +Model Risk / Model Validation |
| 184 | + |
| 185 | +Credit Risk |
| 186 | + |
| 187 | +Pension & Institutional Investment Risk |
| 188 | + |
| 189 | +Risk Consulting |
| 190 | + |
| 191 | +It reflects how quantitative risk models are built, tested, challenged, and documented — not just how they are computed. |
| 192 | +An interactive **Streamlit web app** that brings together **market risk** and **credit risk** analytics in one tool — built from scratch in Python. |
| 193 | +It demonstrates the ability to design, code, and validate professional risk models, including VaR/ES, backtesting, stress testing, and credit Expected Loss. |
62 | 194 |
|
63 | 195 |
|
64 | 196 |
|
0 commit comments