Riskfolio-Lib

Twenty-six convex risk measures, four objectives, one cvxpy-backed optimiser.

by Dany Cajas

Last updated

From
Free
Licence
BSD-3-Clause
Self-hosted
Yes
Platforms
Library

What it is

Riskfolio-Lib is the widest risk-measure catalogue in open-source portfolio optimisation. Where most libraries give you variance and perhaps CVaR, this one builds the same four objectives — minimum risk, maximum return, maximum utility, maximum risk-adjusted ratio — over 26 convex risk measures: mean absolute deviation, semi-variance, kurtosis and semi-kurtosis, lower partial moments, CVaR and its range, tail Gini, entropic and relativistic value-at-risk, Ulcer index, average, conditional, entropic and relativistic drawdown-at-risk, and maximum drawdown. Both arithmetic and logarithmic (Kelly) formulations are available for each.

The rest of the surface is the estimation work around that. ParamsEstimation carries Black-Litterman in three flavours — classic, augmented and Bayesian — plus factor models through forward and backward stepwise regression and principal component regression, entropy pooling, bootstrapping and Gerber statistics. HCPortfolio does the clustering family: hierarchical risk parity, hierarchical equal risk contribution and nested clustered optimisation, with DBHT as well as the usual linkages. Reports writes a Jupyter tear sheet or an Excel workbook.

It is one person's project, and has been since March 2020 — 58 PyPI releases, the latest 7.3.0 on 31 May 2026, with every recent commit authored by Dany Cajas. The repository is not archived, the last commit to master was 22 June 2026, and 10 issues are open. There are no GitHub releases or tags, which is worth knowing before you go looking for a changelog in the usual place.

Pricing

The library is free and BSD 3-Clause. The author funds it the way single-maintainer projects are funded — a Springer book, a paid course, GitHub Sponsors, Ko-fi and consulting — and none of that gates anything in the Python package. What is sold is a different product: Riskfolio-XL, a Windows Excel add-in built on PyXLL, installed with pip install riskfolio-xl and last released in October 2024. Installing it gives a trial capped at seven assets and three risk factors; the full version needs a monthly or annual licence, bought through PayPal and issued under a proprietary EULA by ORENJI EIRL rather than under the BSD licence. The price is not printed anywhere on the page — the buttons are PayPal-hosted.

Data & coverage

No data. Prices or returns arrive as a pandas DataFrame from wherever you got them; the documentation's examples use yfinance, which is not a dependency. Asset classes and markets are properties of your series.

Integrations

cvxpy does the optimisation, and Portfolio.solvers defaults to ['CLARABEL', 'ECOS', 'SCS', 'OSQP', 'CVXOPT'], with the clustering class HCPortfolio using a shorter ['CLARABEL', 'SCS', 'ECOS'] — note that ECOS and CVXOPT are named in those defaults but are not in the install requirements, and both are GPLv3, so whether they end up in your environment is decided by something other than Riskfolio-Lib.

statsmodels and arch back the regression and volatility estimation, networkx and astropy the clustering, xlsxwriter the Excel report, and a pybind11 C++ extension compiled from vendored Eigen 3.4.0 and Spectra 1.0.1 headers does the heavy linear algebra.

Limitations

  • No data fetching, no backtest, no broker. The documentation demonstrates backtesting by handing the weights to a separate library, which is a different card and a different install.
  • The dependency tree is the hidden cost. install_requires pins vectorbt>=0.28.0 even though nothing in the installed package imports it and the README lists it under example requirements only. vectorbt is Apache 2.0 with the Commons Clause, so a licence scanner will flag a non-OSI package in your environment that your code never calls, and the current release drags numba, imageio, dateparser and a numpy and pandas floor higher than Riskfolio-Lib's own.
  • Ten or so of the 26 risk measures are only comfortable with MOSEK, a commercially licensed solver. The free path exists but can fail to converge or take far too long, which is a limit you discover at the end of a long run rather than at the start.
  • The BSD licence covers the Python, not the binary. The extension is compiled against Eigen 3.4.0 including its unsupported tree, without EIGEN_MPL2_ONLY; Eigen describes itself as primarily MPL-2.0 with some files under LGPL 2.1, and Spectra is MPL-2.0. That is a question for whoever redistributes wheels, not for a notebook.
  • Single maintainer, no co-maintainer, no organisation behind it. Four and a half thousand stars do not change the bus factor.

Alternatives

PyPortfolioOpt is smaller, lighter and easier to read if mean-variance, Black-Litterman and HRP are all you need. skfolio covers a comparable range of risk measures with a scikit-learn API, a slimmer dependency tree and cross-validation built in. Portfolio Optimizer offers many of the same models as HTTP endpoints, with no install and no solver to choose.

Specs

Interfaces
Python, Python
Export
Xlsx
Asset classes
Stocks, ETF, Bonds, Commodities
Markets
Global
Platforms
Library
AI features
None
Pricing verified
Capabilities verified
Coverage verified

Also worth comparing

  • PyPortfolioOptPrices in, weights out — efficient frontier, Black-Litterman and HRP.
  • skfolioPortfolio optimisation as scikit-learn estimators — fit, predict, cross-validate.
  • Portfolio Optimizer248 portfolio maths endpoints over HTTP — no install, no solver, no account.
  • archGARCH and the rest of the volatility-model family, plus the tests you need around them.
  • empyrical-reloadedThe maintained fork of Quantopian's empyrical — risk statistics, no plots.
  • ffnPerformance stats, drawdowns and portfolio weights from a DataFrame of prices.

FAQ

What licence is Riskfolio-Lib under?

The repository's LICENSE.txt is BSD 3-Clause, copyright 2020-2026 Dany Cajas, and that covers the Python you import. It does not cover two things underneath it — the compiled extension is built from vendored Eigen and Spectra headers, and install_requires pins vectorbt, which is Apache 2.0 with the Commons Clause and therefore not OSI open source.

Why does pip install vectorbt when I install Riskfolio-Lib?

Because it is declared as a hard dependency in setup.py, although the project's own README lists it under "Examples requires" and no module in the installed package imports it. It arrives with numba, matplotlib, ipywidgets and a dozen more packages, and vectorbt 1.1.0 also demands numpy 2.4.6 or newer and pandas 3.

Do I need a commercial solver?

For most of the library, no — CLARABEL and SCS install with it and cover the linear, quadratic and second-order cone models. The documentation's own solver table flags about ten of the 26 risk measures, among them EVaR, RLVaR, Tail Gini and the entropic and relativistic drawdown measures, as cases where MOSEK is highly recommended because CLARABEL sometimes fails and SCS is too slow. MOSEK is commercial, with free academic licences.

Is it still maintained, and by whom?

By one person, Dany Cajas, and yes. Version 7.3.0 went to PyPI on 31 May 2026, the last commit to master was 22 June 2026, the repository is not archived and 10 issues are open excluding pull requests. There are no GitHub releases or tags at all, so PyPI and CHANGELOG.rst are the only version history.