Skip to content

Portfolio Analysis

Professional portfolio analysis tools for systematic factor investing

PyPI version Tests Coverage License: MIT


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.

    :octicons-arrow-right-24: Learn more

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

    :octicons-arrow-right-24: Learn more

  • :material-target:{ .lg .middle } Portfolio Optimization


    Find optimal portfolios using max Sharpe, min volatility, risk parity, or custom factor targets.

    :octicons-arrow-right-24: Learn more

  • :material-file-document:{ .lg .middle } Professional Reports


    Generate beautiful HTML tear sheets with embedded charts, comprehensive metrics, and benchmark comparisons.

    :octicons-arrow-right-24: Learn more


Installation

pip install engineer-investor-portfolio
pip install "engineer-investor-portfolio[factors]"
pip install "engineer-investor-portfolio[all]"
git clone https://github.com/engineerinvestor/Portfolio-Analysis.git
cd Portfolio-Analysis
pip install -e ".[all]"

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


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.