🔗 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.
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).
- 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
| 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) |
- 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
For selected individual stocks:
- 20-day & 50-day Moving Averages
- Bollinger Bands
- RSI (Relative Strength Index)
pip install -r requirements.txt
streamlit run app_final.pyAfter 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 pushYashna Meher · Hemangi Suthar · Mahika Jain
Created for BA870 Financial Analytics.