A transparent, programmatic Basel III Risk & Capital Adequacy engine for a simulated $50B commercial bank β built with Python, visualized with Plotly Dash.
β οΈ Educational & Demonstration Use Only. This project does not constitute financial or regulatory advice and is not certified for actual BIS / Fed / ECB regulatory reporting.
- Problem Statement
- Solution Overview
- System Architecture
- Tech Stack
- Features
- Directory Structure
- Setup & Installation
- Running the Project
- Dashboard Preview
- Methodology
- Testing
- Disclaimer
Financial institutions operating under Basel III face stringent, multi-dimensional regulatory requirements β covering credit risk, market risk, operational risk, capital adequacy, and liquidity buffers. The challenge:
- Manual computation of Risk-Weighted Assets (RWA) is error-prone at scale.
- Enterprise solutions (e.g., Bloomberg, Moody's) are expensive, black-boxed, and inaccessible for learning.
- Stress testing across adverse macroeconomic scenarios requires rapid, reproducible pipeline reruns.
- Regulatory thresholds (CET1 β₯ 7%, LCR β₯ 100%, NSFR β₯ 100%) must be continuously monitored with automated alerting.
There is no open, transparent, end-to-end Basel III engine that a quantitative analyst, risk student, or fintech professional can inspect, modify, and learn from.
BaselCore is a fully programmatic, open-source Basel III risk analytics engine that:
- Generates a synthetic, reproducible $50B commercial bank balance sheet.
- Computes Credit, Market, and Operational RWA using Basel III standardized formulas.
- Calculates regulatory capital ratios (CET1, Tier 1, Total Capital) and liquidity metrics (LCR, NSFR).
- Stress-tests the balance sheet across 8 adverse macroeconomic scenarios.
- Alerts stakeholders with a multi-level (Green / Amber / Red / Critical) threshold monitoring system.
- Visualizes all outputs through an interactive Plotly Dash dashboard with heatmaps, gauges, and comparison charts.
The engine follows a sequential pipeline architecture, where each module feeds cleanly into the next:
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Data Generator ββββββΆβ RWA Computation ββββββΆβ Capital Metrics β
β (Balance Sheet) β β Credit / Market β β CET1 / Tier 1 / β
β $50B Synthetic β β / Operational β β Total Capital β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β
ββββββββββββββββββββ ββββββββββββββββββββ βΌ
β Liquidity βββββββ Stress Testing βββββ ββββββββββββββββββββ
β LCR / NSFR β β 8 Scenarios β β Alerts Engine β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β β β
ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββ
β Plotly Dash Dashboard β
β Heatmaps Β· Gauges Β· Alerts β
ββββββββββββββββββββββββββββββββ
Data Flow Summary:
- A deterministic random seed ensures full reproducibility of the balance sheet.
- RWA modules (credit, market, operational) are independent and composable.
- The stress testing engine mutates the balance sheet and reruns the entire pipeline per scenario.
- The dashboard and alert system consume final outputs from all modules.
- Credit RWA β Standardized Approach: maps (Exposure Class Γ Rating) to Basel III risk weights (0%β150%). Covers Sovereign, Bank, Corporate, Retail, Residential Mortgage, Commercial Real Estate, and Past Due exposures.
- Market RWA β Standardized Measurement Method: Interest Rate (General + Specific), Equity (8% general + 8% specific), FX (8% net open position), Commodity (15% net + 3% basis risk).
- Operational RWA β New Standardized Approach: Business Indicator Component (BIC) with marginal scaling buckets (12% / 15% / 18%) and Internal Loss Multiplier (ILM = 1.0).
- CET1 Ratio β Common Equity minus regulatory deductions (Goodwill, Intangibles, DTA) / Total RWA. Minimum: 7.0% (4.5% + 2.5% conservation buffer).
- Tier 1 & Total Capital Ratios β Full regulatory capital stack.
- LCR β HQLA (post-haircut, with Level 2 β€ 40% and Level 2B β€ 15% limits) / Net Cash Outflows (30-day stress). Minimum: 100%.
- NSFR β Available Stable Funding / Required Stable Funding. Minimum: 100%.
| # | Scenario | Shock Applied |
|---|---|---|
| 1 | Interest Rate Surge | +200 bps |
| 2 | Rate Cut | β100 bps |
| 3 | Equity Crash | β30% equity positions |
| 4 | Credit Deterioration | 1-notch rating downgrade across portfolio |
| 5 | Liquidity Redemption | 20% deposit run-off |
| 6 | FX Shock | Β±20% currency moves |
| 7 | Combined Adverse | All shocks simultaneously |
| 8 | Severe Recession | GDP β5%, Unemployment +5% |
Each scenario reruns the full pipeline and outputs a Pass/Fail per regulatory threshold (CET1, LCR, NSFR).
| Status | Threshold | Meaning |
|---|---|---|
| π’ GREEN | Above buffer requirement | Fully compliant |
| π‘ AMBER | Approaching minimum | Monitor closely |
| π΄ RED | Below minimum | Breach β action required |
| π¨ CRITICAL | Severe breach | Immediate escalation |
- Capital Gauges (3) β CET1, Tier 1, Total Capital with colored threshold zones.
- Liquidity Gauges (2) β LCR, NSFR.
- RWA Breakdown β Stacked bar chart: Credit / Market / Operational.
- Risk Heatmap β Exposure Class Γ Credit Rating matrix showing RWA concentration.
- Stress Test Comparison β Grouped bar chart: CET1 % vs LCR % across all 8 scenarios.
- Alert Log Table β Live alert status for all monitored metrics.
baselcore-risk-analytics/
βββ config/
β βββ regulatory_config.py # Basel III risk weights & regulatory parameters
βββ data/ # Generated raw & processed balance sheet data
βββ dashboard/
β βββ app.py # Plotly Dash interactive web application
βββ notebooks/ # Jupyter notebooks for exploratory analysis
βββ outputs/
β βββ reports/ # Auto-generated Excel reports & visualizations
βββ src/
β βββ data_generator.py # Synthetic $50B bank balance sheet generator
β βββ credit_rwa.py # Credit risk RWA (Standardized Approach)
β βββ market_rwa.py # Market risk RWA (SMM)
β βββ operational_rwa.py # Operational risk RWA (NSA / BIC)
β βββ capital_metrics.py # CET1 / Tier 1 / Total Capital calculations
β βββ liquidity_metrics.py # LCR / NSFR calculations
β βββ stress_testing.py # 8 adverse macroeconomic scenarios
β βββ alerts.py # Multi-level threshold alert system
βββ tests/ # Pytest unit tests & coverage
βββ main.py # Pipeline orchestrator β run this first
βββ requirements.txt # Python dependencies
- Python 3.10+
pippackage manager- Git
git clone https://github.com/nilaysureka/BaselCore-Risk_Analytics_Engine.git
cd BaselCore-Risk_Analytics_Engine# Create
python -m venv venv
# Activate (macOS / Linux)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activatepip install -r requirements.txtpython main.pyThis will:
- Generate the synthetic $50B balance sheet.
- Compute all RWA modules (credit, market, operational).
- Calculate capital ratios and liquidity metrics.
- Execute all 8 stress test scenarios.
- Export results to
outputs/reports/as Excel files.
python dashboard/app.pyOpen your browser and navigate to:
http://127.0.0.1:8050
The dashboard is organized as follows:
| Section | Component |
|---|---|
| Header | Bank name Β· As-of date Β· Basel III compliance tag |
| Alert Banner | Overall status: Healthy / Monitor / Action Required |
| Capital Panel | Three gauges: CET1, Tier 1, Total Capital |
| Liquidity Panel | Two gauges: LCR, NSFR |
| RWA Breakdown | Stacked bar: Credit / Market / Operational |
| Risk Heatmap | Exposure Class Γ Rating RWA concentration matrix |
| Stress Test View | Grouped bar: CET1 % vs LCR % across 8 scenarios |
| Data Tables | Interactive stress test results + alert log |
Theme: Darkly Bootstrap (Plotly Dash Bootstrap Components)
RWA = EAD Γ Risk Weight
Risk weights assigned by (Exposure Class, External Rating) per Basel III Table β ranging from 0% (AAA Sovereign) to 150% (Past Due / Unrated CRE).
IR Risk = General (Duration Γ ΞYield) + Specific (Credit Spread Charge)
Equity = 8% General + 8% Specific on gross position
FX = 8% Γ Net Open Position
Commodity = 15% Γ Net Position + 3% Γ Gross Position (basis risk)
BIC = ILDC Component + Services Component + Financial Component
Scaling: β€β¬1B β 12% | β¬1Bββ¬30B β 15% | >β¬30B β 18%
Op RWA = BIC Γ ILM (ILM = 1.0)
CET1 = Common Equity β Goodwill β Intangibles β DTA
CET1 Ratio = CET1 / Total RWA [Minimum: 7.0%]
Tier 1 Ratio = Tier 1 Capital / Total RWA
Total Ratio = Total Capital / Total RWA
LCR = HQLA (post-haircut) / Net Cash Outflows (30-day stress) [Minimum: 100%]
NSFR = Available Stable Funding / Required Stable Funding [Minimum: 100%]
HQLA constraints: Level 2 β€ 40% of total HQLA; Level 2B β€ 15% of total HQLA.
Run the full test suite with:
pytest tests/ -v --cov=src| Test Area | What's Validated |
|---|---|
| Data reproducibility | Fixed seed generates identical balance sheets across runs |
| RWA boundary checks | Risk weights bounded to 0%β150% for all exposure classes |
| Capital ordering | CET1 < Tier 1 < Total Capital at all times |
| HQLA composition | Level 2 β€ 40%, Level 2B β€ 15% limits enforced |
| Stress test logic | Combined Adverse scenario produces the lowest CET1 ratio |
In scope:
- Standardized Approach for credit, market, and operational risk.
- Full capital stack (CET1, AT1, Tier 2) and liquidity ratios (LCR, NSFR).
- 8 predefined macroeconomic stress scenarios with automated pass/fail logic.
- Interactive executive dashboard with alert system.
Out of scope:
- Internal Ratings-Based (IRB) models for credit risk.
- Real-time market data feeds (live API integration).
- Certified regulatory submission to BIS / Federal Reserve / ECB.
- Advanced market risk (FRTB / Internal Models Approach).
This project is for educational and demonstration purposes only. The simulated data, simplified methodologies, and outputs do not represent any real financial institution. This engine is not certified for actual regulatory reporting to the BIS, Federal Reserve, ECB, or any other regulatory body, and does not constitute financial or legal advice.
Nilay Sureka
β If you found this project useful, please consider starring the repo! β
Made with π Python Β· π Plotly Dash Β· ποΈ Basel III