Portfolio Analysis¶
Professional portfolio analysis tools for systematic factor investing
What is Portfolio Analysis?¶
Portfolio Analysis is an open-source Python package that provides institutional-quality tools for:
- Performance Measurement - Sharpe, Sortino, max drawdown, VaR, and more
- Factor Analysis - Fama-French regressions, return attribution, factor tilts
- Portfolio Optimization - Mean-variance, risk parity, factor-aware optimization
- Professional Reporting - HTML tear sheets, interactive dashboards
Whether you're a DIY investor analyzing your 401(k) or a quant building factor strategies, this package has you covered.
Quick Example¶
from portfolio_analysis import DataLoader, PortfolioAnalysis
from portfolio_analysis.factors import FactorDataLoader, FactorRegression
# Load your portfolio
loader = DataLoader(['VTI', 'VXUS', 'BND'], '2019-01-01', '2024-01-01')
data = loader.fetch_data()
# Analyze performance
portfolio = PortfolioAnalysis(data, weights=[0.5, 0.2, 0.3])
portfolio.print_summary()
# Run factor analysis
factor_loader = FactorDataLoader()
ff3 = factor_loader.get_ff3_factors('2019-01-01', '2024-01-01')
regression = FactorRegression(portfolio.calculate_portfolio_returns(), ff3)
results = regression.run_regression('ff3')
print(results.summary())
Key Features¶
-
:material-chart-line:{ .lg .middle } Performance Metrics
Calculate 20+ performance metrics including Sharpe ratio, Sortino ratio, max drawdown, VaR, CAGR, and capture ratios.
-
:material-scale-balance:{ .lg .middle } Factor Analysis
Decompose returns using CAPM, Fama-French 3/5 factor, and Carhart models. Understand your true alpha vs systematic factor exposure.
-
:material-target:{ .lg .middle } Portfolio Optimization
Find optimal portfolios using max Sharpe, min volatility, risk parity, or custom factor targets.
-
:material-file-document:{ .lg .middle } Professional Reports
Generate beautiful HTML tear sheets with embedded charts, comprehensive metrics, and benchmark comparisons.
Installation¶
Why Portfolio Analysis?¶
| Feature | QuantStats | PyPortfolioOpt | Riskfolio | Portfolio Analysis |
|---|---|---|---|---|
| Return factor regressions (CAPM/FF/Carhart) + attribution | ❌ | ❌ | ❌ | ✅ |
| HTML Tear Sheets | ✅ | ❌ | ❌ | ✅ |
| Optimization | ❌ | ✅ | ✅ | ✅ |
| Interactive Widgets | ❌ | ❌ | ❌ | ✅ |
| Streamlit App | ❌ | ❌ | ❌ | ✅ |
| Beginner Friendly | ⚠️ | ⚠️ | ❌ | ✅ |
Try It Now¶
No installation required! Open in Google Colab:
Or try the Streamlit Web App →
Community¶
- GitHub: engineerinvestor/Portfolio-Analysis
- Twitter: @egr_investor
- Issues: Report bugs or request features
License¶
This project is licensed under the MIT License. See LICENSE for details.
Disclaimer
This is not investment advice. These tools are for educational purposes only. Past performance does not guarantee future results.