Skip to content

Repository files navigation

Market Risk Engine — Value at Risk (VaR) & Expected Shortfall (CVaR)

Project 2:

A Monte Carlo simulation of a $100m multi-asset portfolio's one-day P&L, calibrated on real historical volatility, used to estimate Value at Risk (VaR) and Expected Shortfall (CVaR) — the two headline numbers a bank's market risk committee reports daily.

![Simulated 1-day P&L distribution](output/var_pnl_distribution.png)

Results (100,000 simulated scenarios)

Metric 95% Confidence 99% Confidence
Value at Risk (VaR) $1,888,542 $2,734,152
Expected Shortfall (CVaR) $2,404,020 $3,145,086

Worst simulated 1-day loss: -$5,341,289 · Best simulated 1-day gain: $5,602,188

Full write-up: Market\_Risk\_Memo\_VaR\_CVaR.docx

Portfolio & methodology

Constituents AAPL (30%), MSFT (30%), JPM (20%), BARC.L (20%)
Notional $100,000,000
Calibration window 2 years of daily historical closing prices
Simulation 100,000 draws from Normal(mean, vol), calibrated on real historical returns

The portfolio includes Barclays (BARC.L) alongside two US tech names and a US bank, both for relevance to this portfolio's theme and as a sanity check against a name with well-understood volatility.

Repo structure

market-risk-var-engine/
├── market\_risk\_var\_engine.ipynb   # main analysis notebook
├── market\_risk\_var\_engine.py      # standalone script version
├── Market\_Risk\_Memo\_VaR\_CVaR.docx # 1-page risk committee memo
├── output/
│   └── var\_pnl\_distribution.png   # P\&L distribution chart
├── requirements.txt
├── .gitignore
└── LICENSE

Note: output/var\_simulation.csv (the raw 100,000-row simulated P&L output) is generated by running the notebook/script and is not committed — see .gitignore.

Running it yourself

python -m venv venv
source venv/bin/activate          # venv\\Scripts\\activate on Windows
pip install -r requirements.txt
jupyter notebook market\_risk\_var\_engine.ipynb

Requires an internet connection to download price history from Yahoo Finance via yfinance. Results will vary slightly from the figures above as market data updates — the notebook is calibrated on a live 2-year rolling window, not a fixed historical snapshot.

Skills demonstrated

Monte Carlo simulation · real market data calibration (yfinance) · Value at Risk (VaR) · Expected Shortfall (CVaR) · historical-simulation sanity checking · NumPy · Pandas

Limitations / next steps

  • Returns are modelled as Normally distributed; real returns are typically fat-tailed, so this VaR/CVaR is best read as a lower bound on tail risk. A Student's-t or historical-simulation approach is a natural extension.
  • 1-day horizon only; regulatory capital calculations typically require 10-day VaR, commonly approximated via the square-root-of-time rule.
  • Correlation between constituents is captured only implicitly through the blended historical portfolio-return series, not as an explicit covariance matrix — sufficient for portfolio-level VaR, but not for single-asset what-if stress testing.

---

About

Simulate 100,000 portfolio return paths to estimate VaR and Expected Shortfall (CVaR).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages