Extra Activity 2
Monte Carlo Simulation in Python
Monte Carlo Simulation in Python
Here is my google colab
(pl click on the link; code is given therein, run to see)
Screenshot is attached above
Monte Carlo Value at Risk (VaR) Simulator — Indian Equity Portfolio
This project implements a Monte Carlo simulation engine to estimate the Value at Risk of a multi-stock Indian equity portfolio listed on the NSE. Given a portfolio of five large-cap stocks — Reliance Industries, TCS, HDFC Bank, ICICI Bank, and Infosys — the model simulates 10,000 possible future portfolio trajectories over a 100-day horizon and quantifies the maximum expected loss at a 95% confidence level.
The simulation is grounded in modern portfolio theory. Historical price data spanning 2020 to 2025 is used to estimate each stock's mean daily return and the full covariance structure of the portfolio, capturing not just individual volatility but also inter-stock correlations. Random future return scenarios are then drawn from a multivariate normal distribution, ensuring that the simulated paths respect the statistical relationships between assets rather than treating each stock independently. Daily returns are compounded across the time horizon to produce realistic portfolio value trajectories.
The output has two layers — a visual layer and a risk metric layer. The simulation path chart shows the full spread of possible outcomes, giving an intuitive sense of uncertainty. The ending value histogram reveals the shape of the return distribution and clearly marks the VaR threshold. The final risk summary reports the expected portfolio value, best and worst case outcomes, and the VaR figure in absolute rupee terms — directly interpretable by a portfolio manager or risk officer.
The project is built entirely in Python using yfinance, NumPy, pandas, and Matplotlib, and is designed to be modular and extensible — serving as a foundation for more advanced risk analytics including Conditional VaR, fat-tail modelling, stress testing, and portfolio optimization.
The Fan Shape is Healthy The simulation starts from a single point (₹10 lakhs) and expands outward — this is exactly what a well-implemented Monte Carlo should look like. The fact that it fans symmetrically rather than drifting wildly in one direction suggests your mean return and covariance estimates are statistically stable.
The Upward Bias is Visible Look closely — the fan is not centered on the red dashed line. The bulk of the mass sits above ₹10 lakhs by Day 100. This reflects the positive mean daily returns your portfolio earned historically from 2020–2025, a period that included a massive post-COVID bull run in Indian markets. Your simulation has captured that bullish drift.
The Asymmetry in Extremes The upper tail (best case paths reaching ₹1.8–1.9 lakhs) extends further from the center than the lower tail (worst case around ₹0.65–0.7 lakhs). This is a natural property of compounded returns — gains can theoretically compound without bound, but losses are floored. This is why VaR alone can understate risk and CVaR becomes important.
Uncertainty Grows Non-Linearly The spread widens rapidly in the first 30 days and then continues expanding but more gradually. This is the square-root-of-time effect in action — risk scales with √T, not T linearly. A quant interviewer would love to hear you mention this.
The Red Line Tells the Real Story A significant portion of paths — roughly the bottom 20–25% visually — end below your initial investment by Day 100. That gap between where most paths land and the red line is essentially your VaR story told graphically before you even compute the number.
Here are some fun facts about Value at Risk (VaR):
VaR answers one simple question: "What's the most I can expect to lose on a bad day?" (with a certain confidence level)
Example: A 1-day 95% VaR of $1 million means there's only a 5% chance you'll lose more than $1 million tomorrow
VaR was popularized by J.P. Morgan in the 1990s through their "RiskMetrics" system
The CEO wanted a simple "4:15 pm report" showing the firm's overnight risk exposure in one number
VaR didn't predict the 2008 financial crisis - it's terrible at capturing "tail risk" (rare extreme events)
Critics call it "an airbag that only works in minor accidents"
Nassim Taleb famously called VaR users "sitting on a powder keg"
Historical VaR - looks at past data (simple but assumes history repeats)
Parametric VaR - assumes normal distribution (fast but often wrong)
Monte Carlo VaR - runs thousands of simulations (accurate but computationally expensive)
Basel Accords require banks to use VaR for capital requirements
Banks must hold capital equal to their 10-day 99% VaR
VaR tells you the minimum you might lose in the worst 5% of cases, but says nothing about HOW BAD those worst cases could be
It's like knowing there's a 5% chance of rain, but not whether it'll be a drizzle or a hurricane!