Validation-Grade Market & Credit Risk Engine
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.
The objective is not to build a trading system or a dashboard-centric application, but to demonstrate:
- Sound quantitative risk methodology
- Explicit assumptions and loss conventions
- Clear separation between model logic, configuration, and presentation
- Standard validation and backtesting diagnostics
This repository functions as a model risk validation sandbox.
- Value-at-Risk (VaR) and Expected Shortfall (ES)
- Supported methodologies:
- Historical Simulation
- Parametric (Normal)
- Monte Carlo (multivariate normal with covariance shrinkage)
- Filtered Historical Simulation (GARCH-lite)
- Multi-confidence-level analysis (e.g. 95%, 99%)
- Rolling-window estimation
- Out-of-sample backtesting using Kupiec Proportion-of-Failures (POF)
- Expected Loss (EL) framework:
- Probability of Default (PD)
- Loss Given Default (LGD)
- Exposure at Default (EAD)
- Portfolio-level aggregation
- Segment-level loss decomposition
- Deterministic equity shocks
- Interest-rate shocks via duration approximation
- Correlation stress
- Historical window replay
This repository is intentionally structured to reflect institutional model governance and review practices.
risklib/
market/
market_risk_model.py # MarketRiskModel + configuration objects
market.py # Risk measures, simulation, backtesting primitives
credit/
credit_risk_model.py
app/
app.py # Streamlit viewer only (no modeling logic)
docs/
model_report.md # Model methodology & validation notes
risklib/is the source of truth
All modeling, estimation, and validation logic lives here.app/is presentation-only
The UI visualizes results but does not implement risk logic.- Consistent loss-based convention
All risk measures are reported as positive loss amounts.
Market risk is implemented as a validation-grade model object, separating configuration, estimation, and diagnostics.
from risklib.market.market_risk_model import MarketRiskModel, MarketRiskConfig
cfg = MarketRiskConfig(
alpha=0.99,
method="historical", # historical | parametric | monte_carlo | fhs
horizon_days=1,
exposure=1_000_000,
)
model = MarketRiskModel(returns, weights, cfg)
model.fit()
var = model.compute_var()
es = model.compute_es()
summary = model.summary()This design mirrors institutional practice:
- Explicit configuration objects capture modeling assumptions
- Model objects encapsulate estimation logic
- Outputs include metadata required for validation review
- Backtesting is conducted separately and out-of-sample
- Rolling 1-day VaR backtests
- Trailing-window estimation
- Exception tracking
- Kupiec Proportion-of-Failures (POF) test for unconditional coverage
Interpretation The Kupiec test evaluates whether the observed exception frequency is statistically consistent with the expected (1 − α) rate implied by the model.
-
VaR: loss exceeded with probability (1 − α)
-
Expected Shortfall: average loss conditional on VaR exceedance
-
Filtered Historical Simulation:
- Volatility estimated using fixed-parameter GARCH(1,1)
- Returns standardized and rescaled
-
Expected Loss (Credit): EL = PD × LGD × EAD
All models follow a consistent loss-based convention.
This project emphasizes model validation, not just model output.
-
Unit tests verify:
- VaR monotonicity across confidence levels
- ES ≥ VaR under consistent loss conventions
- Correct exception counting in backtests
- Credit loss aggregation consistency
-
Backtesting results are interpretable and reproducible
-
Assumptions and limitations are explicitly documented
To preserve clarity and rigor, this project does not attempt to be:
- A trading or portfolio optimization system
- A real-time production risk engine
- A regulatory-approved model
Advanced extensions (e.g. factor models, ALM, optimization) are intentionally deferred.
A lightweight Streamlit interface is provided strictly as a viewer to:
- Run models with selected parameters
- Visualize backtests and stress results
- Export validation series
All modeling logic remains outside the UI.
- Python
- Pandas / NumPy
- SciPy / Statsmodels
- Plotly
- Streamlit
- yfinance (demo data only)
git clone https://github.com/sensor-aae/Integrated-Risk-App.git
cd Integrated-Risk-App
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
streamlit run app/app.pyA Model Risk Report (methodology, assumptions, validation results, and limitations) is maintained in the docs/ directory and mirrors institutional model documentation standards.
This project is for educational and demonstrative purposes only. It is not intended for production use or investment decision-making.
This repository is designed as a work sample for roles in:
- Market Risk
- Model Risk / Model Validation
- Credit Risk
- Pension & Institutional Investment Risk
- Risk Consulting
It reflects how quantitative risk models are built, tested, challenged, and reviewed — not just how they are computed.