From Excel to Python: Building a Value at Risk (VaR) Model for a Multi-Asset Portfolio

Table Of Content
- ๐ก Why This Project?
- ๐ What is Value at Risk (VaR)?
- ๐งฉ Portfolio Setup
- ๐ง Why These Assets?
- โ๏ธ Methodology
- ย 1๏ธโฃ Historical VaR
- ย 2๏ธโฃ Parametric VaR (Variance-Covariance)
- ๐งฎ Key Step: Portfolio Risk Aggregation
- ๐ Why Python?
- ๐ Results
- ย Interpretation
- ๐ Visualization
- โ ๏ธ Limitations
- ๐ Connecting Finance and Technology
- ๐ Final Thoughts
- ๐ Project Links
- ๐ Next Steps
๐ก Why This Project?
As part of my transition into technology-focused roles, I wanted to revisit one of the core concepts from my background in financial risk: Value at Risk (VaR).
Rather than treating this as a purely academic exercise, I approached it with two goals:
- Reinforce core financial risk concepts (VaR, covariance, portfolio risk)
- Translate those concepts into a Python-based workflow to demonstrate automation and data analysis skills
This project became a useful bridge between:
- Finance โ Risk Modeling
- Technology โ Python, data processing, reproducibility
๐ What is Value at Risk (VaR)?
Value at Risk (VaR) estimates the potential loss in value of a portfolio over a given time horizon at a specified confidence level.
For example:
A 10-day 95% VaR of $3,268 means that, under normal conditions, the portfolio is not expected to lose more than $3,268 over 10 days, 95% of the time.
๐งฉ Portfolio Setup
To keep things practical, I used a simple diversified portfolio:
| Asset | Weight |
|---|---|
| SPY | 40% |
| QQQ | 25% |
| AGG | 25% |
| GLD | 10% |
- Portfolio Value: $100,000
- Data: ~1 year of daily returns
๐ง Why These Assets?
The portfolio was constructed using four widely traded ETFs to represent different asset classes:
| Asset | Description |
|---|---|
| SPY | U.S. broad equity market (S&P 500) |
| QQQ | U.S. growth / technology-focused equities |
| AGG | U.S. investment-grade bonds |
| GLD | Gold (commodity / alternative asset) |
These assets were selected to illustrate a simple diversified portfolio with exposure to:
- Equities (SPY, QQQ) โ higher growth, higher volatility
- Fixed Income (AGG) โ lower volatility, income component
- Alternatives (GLD) โ diversification and potential hedge during market stress
The combination helps demonstrate a key concept in portfolio risk:
Portfolio risk is not just driven by individual asset volatility, but by how assets move relative to each other (correlation).
By including assets with different risk profiles and correlations, the model highlights the impact of diversification on:
- portfolio variance
- covariance structure
- and overall Value at Risk (VaR)
While simplified, this structure reflects a common multi-asset allocation framework used in portfolio and risk management.
โ๏ธ Methodology
Two approaches were used:
1๏ธโฃ Historical VaR
- Based on actual historical return distribution
- No assumptions about normality
- Computed using percentiles of portfolio returns
2๏ธโฃ Parametric VaR (Variance-Covariance)
- Assumes returns follow a normal distribution
- Uses:
- Covariance matrix
- Portfolio variance
- Z-scores
- Applies square-root-of-time scaling for multi-day VaR
๐งฎ Key Step: Portfolio Risk Aggregation
A core concept in this project is how portfolio risk is calculated.
Portfolio variance is computed as:
Portfolio Variance = wแต ฮฃ w
Where:
w= weights vectorฮฃ= covariance matrix
This captures not just individual asset volatility, but also how assets move together.
๐ Why Python?
The Excel model was useful for validation, but Python adds:
- Reproducibility
- Automation
- Scalability
- Cleaner handling of datasets
Using Python libraries such as:
pandasโ data handlingnumpyโ matrix operationsmatplotlibโ visualization
I was able to replicate the full VaR workflow programmatically.
๐ Results
Key outputs from the analysis:
- Portfolio Daily Volatility: ~0.63%
- 1-Day Historical VaR (95%): ~$1,044
- 10-Day Parametric VaR (95%): ~$3,268
Interpretation
Under normal market conditions, the portfolio is expected to lose no more than approximately $3,268 over a 10-day period with 95% confidence.
๐ Visualization
The project also includes:
- Distribution of portfolio returns (histogram)
- Time series of portfolio returns
These help visualize:
- volatility clustering
- distribution shape
- tail risk behavior
โ ๏ธ Limitations
Like all VaR models, there are important assumptions:
- Parametric VaR assumes normally distributed returns
- Historical VaR depends heavily on the chosen time window
- Square-root-of-time scaling assumes independent returns
- Extreme tail events are not fully captured
๐ Connecting Finance and Technology
This project reflects a broader direction Iโve been working toward:
- Applying analytical thinking from financial risk
- Using technical tools (Python, data workflows)
- Building repeatable, explainable models
The same mindset carries over into:
- security monitoring
- risk assessment
- data-driven decision-making
๐ Final Thoughts
This wasnโt about building the most complex VaR model.
It was about:
- revisiting core concepts,
- implementing them cleanly,
- and demonstrating how traditional risk analysis can be translated into modern, technical workflows.
๐ Project Links
๐ Full report and supporting files available on GitHub
๐ Next Steps
Potential extensions include:
- Monte Carlo simulation
- stress testing scenarios
- integrating real-time data
- expanding into risk dashboards
โ ๏ธ Disclaimer:
This project is a simplified portfolio risk analysis created for educational and portfolio purposes. The data and assumptions used (including asset selection, return distributions, and time horizons) are illustrative and do not represent investment advice or real-world portfolio recommendations.
Thanks for reading! ๐
If you're interested in financial risk, data-driven analysis, or the intersection of finance and technology - feel free to connect with me on LinkedIn.
Iโm particularly interested in roles and projects related to risk management, governance, and analytical problem-solving across finance and technology.
Feel free to reach out with any questions or thoughts.
