PyPortfolioOpt is a Python library for financial portfolio optimization that implements mean-variance optimization, Black-Litterman models, and Hierarchical Risk Parity methods. It provides a complete toolkit for constructing risk-adjusted asset portfolios by combining expected return estimation, covariance modeling, constraint handling, and discrete allocation into a single optimization framework.
The library distinguishes itself through its integration of multiple optimization approaches within a unified interface. It includes a Black-Litterman Bayesian framework that blends market equilibrium returns with investor views, a Hierarchical Risk Parity method that allocates capital based on asset correlation clustering, and a mean-variance optimization engine that solves the efficient frontier with user-defined constraints. The constraint-aware solver enforces position bounds, market neutrality, and long-short limits during weight optimization, while the discrete share allocation algorithm converts continuous portfolio weights into integer share counts for a given investment amount.
The toolkit covers the full portfolio management workflow, from estimating expected returns using historical averages, exponential weighting, or CAPM, to modeling portfolio risk through sample, shrinkage, or robust covariance matrix estimation. It then applies these inputs to compute optimal asset allocations under specified constraints, producing investable portfolios ready for implementation.