A Streamlit dashboard for analysing multi-asset portfolios — risk metrics, benchmarking, and interactive charts. No installation required.
Highlights • Live Demo • Quickstart • Features • Metrics • Structure
- 100+ tickers — stocks, broad market ETFs, sector ETFs, bonds, commodities, leveraged/inverse
- 6 risk metrics — return, volatility, Sharpe, max drawdown, VaR, beta
- 5 interactive charts — cumulative returns, drawdown, correlation heatmap, risk vs return, return distribution
- Cookie persistence — your last portfolio is saved automatically across sessions
- No login, no setup — use it directly in the browser
🔗 stockportfolioanalyser.streamlit.app — no installation needed. Your portfolio is saved in cookies so it persists between visits.
# 1. Clone the repo
git clone https://github.com/your-username/portfolio-analyser.git
cd portfolio-analyser
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run
streamlit run app.pyThen open http://localhost:8501.
Search and select from 100+ tickers. Set custom weights per holding — automatically normalised to 100%.
Six key metrics displayed at a glance on every analysis run.
| Tab | Chart |
|---|---|
| 📊 Cumulative Returns | Portfolio vs SPY benchmark + individual stocks (toggle via legend) |
| 📉 Drawdown | Peak-to-trough decline over time, filled area chart |
| 🔥 Correlation | Lower-triangle heatmap of pairwise return correlations |
| ⚖️ Risk vs Return | Annualised scatter — stocks, portfolio ★, and benchmark |
| 📐 Distribution | Daily return histogram with normal fit and VaR 95% line |
Per-stock annualised return, volatility, Sharpe ratio, and max drawdown alongside normalised weights.
| Metric | Description |
|---|---|
| Annualised Return | Geometric mean return scaled to 1 year |
| Annualised Volatility | Daily std dev × √252 |
| Sharpe Ratio | Excess return over risk-free rate per unit of volatility |
| Max Drawdown | Largest peak-to-trough decline |
| VaR (95%, 1-day) | Estimated daily loss not exceeded 95% of the time (parametric) |
| Beta (vs SPY) | Portfolio sensitivity to S&P 500 moves |
portfolio-analyser/
├── app.py # Streamlit UI, charts, sidebar inputs
├── analysis.py # Pure computation backend — no UI dependencies
└── requirements.txt
analysis.py can be imported and used standalone without Streamlit.
| Package | Version |
|---|---|
| streamlit | ≥ 1.32.0 |
| yfinance | ≥ 0.2.36 |
| pandas | ≥ 2.0.0 |
| numpy | ≥ 1.24.0 |
| plotly | ≥ 5.18.0 |
| scipy | ≥ 1.11.0 |
| extra-streamlit-components | ≥ 0.1.60 |
Python 3.10+ recommended.
- Price data is fetched live from Yahoo Finance — an internet connection is required
- SPY is always fetched alongside your holdings and used as the benchmark
- Leveraged/inverse ETFs (e.g. TQQQ, SQQQ) are supported but carry higher risk
MIT