finds.dev← search

// the find

PyPortfolio/PyPortfolioOpt

★ 5,787 · Jupyter Notebook · MIT · updated Jun 2026

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity

PyPortfolioOpt is a Python library for quantitative portfolio construction, covering mean-variance optimization, Black-Litterman, hierarchical risk parity, and CVaR. It's aimed at quant researchers and algorithmic traders who want to go from a price DataFrame to optimal weights in a few lines, without writing the optimization plumbing themselves. The scikit-learn-inspired API makes it easy to swap components.

The covariance shrinkage support is genuinely useful — Ledoit-Wolf and OAS are production-grade estimators, not afterthoughts. The L2 regularization on weights is a practical fix for mean-variance's notorious sparsity problem that most similar libraries ignore. Black-Litterman implementation handles the omega estimation (investor uncertainty) which is where most DIY implementations fall apart. DiscreteAllocation converts continuous weights to actual share counts, closing the gap between theory and a real brokerage order.

The expected returns module is weak by design — it offers mean historical returns and CAPM betas, both of which are widely known to be poor forward-looking estimators, and the library can't help you there. No transaction cost modeling means backtested allocations will look better than live performance, especially with frequent rebalancing. The optimizer backend is cvxpy, which is fine for prototyping but introduces a heavy dependency and can silently return suboptimal results when the problem is numerically ill-conditioned. No built-in rebalancing scheduler or time-series backtesting means you'll wire all of that yourself.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →