Skip to content

yashnamb/Portfolio-Risk-Analysis

Repository files navigation

📊 Portfolio Risk Analyzer: Financial Analytics Dashboard

🔗 Live App: https://portfolio-risk-analysis-ym.streamlit.app/


A Streamlit dashboard for analyzing, simulating, and visualizing an investment portfolio with advanced financial metrics and interactive plots. It is designed to be approachable for first-time investors, part-time investors, and students getting started with the stock market.

To begin, select tickers and investment amounts in the sidebar, then click Analyze Portfolio to unlock the full set of features.


Data

Historical prices for the full S&P 500 (plus the ^GSPC index) are pre-downloaded and bundled with the repository under data/, so the app runs entirely from local data:

  • No live API calls are made at runtime, so the app is unaffected by Yahoo Finance rate limits.
  • Coverage runs from 2015 through the end of the previous calendar year (the selectable end date is capped there automatically).
  • Daily closing prices are used for performance, risk metrics, Monte Carlo simulation, and clustering.

The dataset can be regenerated once a year with build_dataset.py (see below).


Features

  • Portfolio Performance (vs. S&P 500)
  • Monte Carlo Simulation for future projections
  • Risk Metrics (Volatility, Drawdown, VaR)
  • Technical Indicators (Moving Averages, Bollinger Bands, RSI)
  • Stock Clustering (K-Means based on return patterns)
  • Sector Allocation, Asset Correlation, and Drawdown Analysis

APIs & Libraries

Tool/Library Purpose
streamlit Interactive web app frontend
pandas, numpy Data manipulation and calculation
plotly Interactive visualizations
scikit-learn Clustering (KMeans), scaling, PCA
scipy Portfolio optimization (efficient frontier)
yfinance Building the historical price dataset (offline, one-time)

Simulations & Metrics

  • Monte Carlo Simulation: projects future portfolio value using normally distributed returns
  • Efficient Frontier: optimal risk-return portfolios via scipy.optimize
  • Sharpe Ratio: risk-adjusted return
  • Value at Risk (VaR): 95% and 99% thresholds
  • Beta: sensitivity to the S&P 500
  • Drawdown: maximum drop from a peak

Technical Analysis

For selected individual stocks:

  • 20-day & 50-day Moving Averages
  • Bollinger Bands
  • RSI (Relative Strength Index)

🚀 Getting Started

pip install -r requirements.txt
streamlit run app_final.py

Refreshing the dataset (yearly)

After January 1, regenerate the bundled data to include the newly completed year, then commit the updated files:

python build_dataset.py
git add data/
git commit -m "Refresh price data"
git push

Contributors

Yashna Meher · Hemangi Suthar · Mahika Jain

Created for BA870 Financial Analytics.

About

Interactive Streamlit dashboard for portfolio risk analysis: performance vs S&P 500, Monte Carlo, VaR, efficient frontier, and stock clustering.

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors