An actuarial and risk management dashboard built with Python and Streamlit to quantify portfolio risk and analyze historical performance.
This project demonstrates cross-disciplinary expertise in Financial Engineering, Quantitative Risk Management (QRM), and Data Automation.
In quantitative finance, understanding risk density is as critical as projected returns. This analyzer implements the Variance-Covariance (Parametric) Method to calculate Value at Risk (VaR).
- Key Assumption: It assumes asset returns follow a multivariate normal distribution.
- Actuarial Relevance: Essential for capital adequacy assessments, solvency padding, and stress-testing under Basel III / Solvency II frameworks.
- Automated Data Pipeline: Pulls 2 years of adjusted close price data via the
yfinanceAPI with asynchronous thread handling to prevent data lockups. - Advanced Portfolio Metrics: Calculates annualized expected return, multi-asset portfolio volatility (via covariance matrix), and risk-adjusted return (Sharpe Ratio based on a customizable risk-free rate).
- Parametric Value at Risk (VaR): Dynamically computes 1-day VaR across 90%-99% confidence levels using inverse cumulative distribution functions (
scipy.stats.norm.ppf). - Dynamic Visualizations: Interactive portfolio valuation curves built with
Plotly Expressand robust data caching (@st.cache_data) for sub-second re-rendering.
- Frontend/UI: Streamlit (Web Interface)
- Data Processing: Pandas, NumPy
-
Quantitative Math: SciPy (Statistical Modeling), Portfolio Matrix Multiplication (
$W^T \cdot \Sigma \cdot W$ ) - Financial Data: yfinance API
- Data Visualization: Plotly Express
git clone https://github.com/TigerGO20/portfolio-risk-analyzer.git
cd portfolio-risk-analyzerIt is highly recommended to use a virtual environment:
# Create a virtual environment
python -m venv venv
# Activate it (Windows)
.\venv\Scripts\activate
# Activate it (Mac/Linux)
source venv/bin/activate
# Install required packages
pip install streamlit yfinance pandas numpy scipy plotlystreamlit run app.pyYour browser will automatically open to http://localhost:8501 to display the active application.
- Historical & Monte Carlo VaR: Implement non-parametric and stochastic simulation VaR to capture fat-tailed market distributions.
- Expected Shortfall (TVaR): Calculate Tail Value at Risk to quantify average losses beyond the VaR threshold (Solvency II compliance).
- Markowitz Mean-Variance Optimization: Add an automated frontier solver to suggest optimal risk-adjusted portfolio weights.