Riskfolio-Lib is a Python package for portfolio optimization built on CVXPY and Pandas. It helps students, academics, and practitioners build portfolios from complex risk models with less manual setup.
Overview
Riskfolio-Lib packages portfolio optimization workflows for Python users who work with investment data in Pandas. It sits on top of CVXPY for convex optimization and is aimed at lowering the effort needed to run mathematically involved allocation models.
Mean-risk and logarithmic mean-risk (Kelly) optimization support several objectives such as minimum risk, maximum return, maximum utility, and maximum risk-adjusted return. Many convex risk measures cover dispersion, downside, and drawdown families. Risk parity, hierarchical clustering methods, nested clustered optimization, and additional specialized formulations are included.
The library also offers Black–Litterman and factor-model variants, constraints on turnover and tracking error, cardinality and category limits, tools for efficient frontiers, risk contributions, clustering, and reporting to Jupyter or Excel. Solver choice follows CVXPY compatibility, with guidance on which solvers fit each risk measure type.
Install the stable release from PyPI with pip. Optional commercial solvers such as MOSEK or GUROBI can handle larger problems when configured.
Key features
- Mean-risk and Kelly optimization objectives
- Large set of convex risk measures
- Risk parity and hierarchical portfolio methods
- Black–Litterman and factor-model optimization
- Portfolio constraints and integer cardinality rules
- Efficient frontier and risk contribution tools
- CVXPY-based solver integration
- Jupyter and Excel reporting helpers
Use cases
- Academic portfolio optimization research
- Asset allocation with custom risk measures
- Teaching quantitative portfolio construction
- Backtesting allocation policies in Python