Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

📈 Portfolio Risk & VaR Analyzer

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.


💼 Actuarial & Risk Insights (Why This Matters)

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.

🚀 Features

  • Automated Data Pipeline: Pulls 2 years of adjusted close price data via the yfinance API 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 Express and robust data caching (@st.cache_data) for sub-second re-rendering.

🛠️ Tech Stack & Mathematical Concepts

  • 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

🏃‍♂️ How to Run Locally

1. Clone the Repository

git clone https://github.com/TigerGO20/portfolio-risk-analyzer.git
cd portfolio-risk-analyzer

2. Set Up Environment & Install Dependencies

It 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 plotly

3. Run the Streamlit Application

streamlit run app.py

Your browser will automatically open to http://localhost:8501 to display the active application.


🔮 Future Enhancements (Roadmap)

  • 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.

About

An interactive Streamlit quantitative risk dashboard that engineers real-time historical data workflows to calculate portfolio annualized returns, volatility covariance matrices, Sharpe Ratios, and Parametric Value at Risk (VaR).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages