Riskfolio-Lib in 2026: Portfolio Optimization in Python Beyond CVaR and Sortino

CVaR and Sortino have become the default vocabulary for downside-aware portfolio construction in Python, and for good reason: both are convex-friendly, well documented, and easy to explain to a risk committee. But they describe one slice of the loss distribution. Neither says much about how long a drawdown lasts, how the tail is shaped beyond a single quantile, or whether your optimizer can respect a rule like “no more than three assets from any one sector.”

Riskfolio-Lib occupies that wider territory. It is not a faster solver and not a drop-in replacement for the tools covered elsewhere on this site. It is a broader objective-and-constraint surface wrapped around the same CVXPY and pandas stack most Python quants already use.

How this guide was researched. This guide is based on official documentation, the PyPI release page and the GitHub repositories; we did not run the tools hands-on. No benchmarks were executed, no solver timings were collected, and no performance comparison between libraries is made or implied. Where a claim comes from a README or docs page rather than verified behavior, it is attributed as such.

What Is Riskfolio-Lib? (And Why It Isn’t Just Another PyPortfolioOpt)

Riskfolio-Lib is a BSD-3-Clause Python library, at version 7.4.0 on PyPI, built on CVXPY and closely integrated with Pandas. Its README describes it as “Portfolio Optimization in Python, Easy for Everyone,” and the repository shows active maintenance, with the latest commit landing on October 22, 2026.

The GitHub repository lists 4.6k stars and 447 commits, the most recent being a numpy boolean-identity fix (PR #264) dated October 22, 2026. The author is Dany Cajas, and the project ships under BSD-3-Clause. The PyPI release page shows 7.4.0 as current, installed with pip install riskfolio-lib. Documentation lives at riskfolio-lib.readthedocs.io and is versioned to 7.4; the README suggests a BibTeX entry of “Riskfolio-Lib (7.4)” for citation.

Two design choices matter more than the version number. First, the library is built on CVXPY, so the problems it constructs are convex programs rather than closed-form solutions — that is what makes a catalog of two dozen risk measures tractable. Second, it is “closely integrated with Pandas” per the project README, which the README presents as close integration with pandas data structures.

This is the first post on this site covering Riskfolio-Lib. For the mechanics of the two measures most people start with, our guide to CVaR portfolio optimization in Python comparing PyPortfolioOpt and skfolio covers the CVaR side, and how the Sortino ratio and second lower partial moment handle downside risk in Python covers the ratio itself. Both remain useful; this post treats them as the entry point rather than the destination.

The Risk Measure Catalog: 26 Convex Measures Beyond CVaR

The docs list 26 convex risk measures for mean-risk optimization and 22 for risk parity. Beyond CVaR and the second lower partial moment behind the Sortino ratio, the downside list includes entropic VaR, relativistic VaR, worst realization (minimax), and Tail Gini — a materially wider menu than the two-measure default.

Per the documented risk measure list, the downside family includes Second Lower Partial Moment (the quantity behind the Sortino ratio), Conditional Value at Risk (CVaR), Entropic Value at Risk (EVaR), Relativistic Value at Risk (RLVaR), Worst Realization (Minimax), and Tail Gini.

The practical question is when to move past CVaR. CVaR is a single quantile average: it reports the mean loss in the worst slice of the distribution and is indifferent to how losses inside that slice are shaped. EVaR and RLVaR come from different constructions — entropic and relativistic respectively — and the docs list them among the convex risk measures available to the same optimization models. Tail Gini targets the tail more generally rather than at one cutoff. Worst Realization is the minimax case, optimizing against the single worst scenario in the sample.

The framing: these are different questions, not better answers. A desk that reports CVaR should keep optimizing CVaR. A desk with a mandate written in terms of one specific measure now has a library that offers it. Check the docs for which measures are available under which mode, since the counts differ.

Drawdown-Based Optimization: CDaR, EDaR, and the Ulcer Index

Riskfolio-Lib supports optimization on CDaR, entropic drawdown-at-risk, relativistic drawdown-at-risk, the Ulcer Index, and maximum drawdown (Calmar ratio). skfolio’s README also lists CDaR, EDaR, the Ulcer Index and drawdown-at-risk, so drawdown measures are not unique to Riskfolio-Lib. The difference is breadth: relativistic drawdown-at-risk (RLDaR) is in the Riskfolio-Lib docs and does not appear in the skfolio README fetched for this guide.

The documented drawdown measures include the Ulcer Index, Conditional Drawdown at Risk (CDaR), Entropic Drawdown at Risk (EDaR), Relativistic Drawdown at Risk (RLDaR), and Maximum Drawdown, the denominator of the Calmar ratio.

Two details matter. The docs note that the mean-risk and risk-parity drawdown measures use uncompounded cumulative returns (hierarchical clustering supports compounded and uncompounded variants), which matters because a drawdown measured on a compounded series and one measured on an uncompounded series are not the same number. Second, drawdown measures are path-dependent in a way tail-loss measures are not: CVaR asks how bad the worst slice of days is, while a drawdown measure asks how deep and how long the trough was. For strategies with slow bleeds — carry trades, short-volatility sleeves, anything with negative skew that daily tail statistics understate — that distinction is the point.

If your risk process already tracks drawdown duration or time-under-water, optimizing a drawdown measure aligns the objective with the report. That is a stronger argument for CDaR or the Ulcer Index than any claim about which measure is better.

Risk Parity, HRP, HERC, and Nested Clustered Optimization

Riskfolio-Lib covers risk parity with 22 convex risk measures, hierarchical clustering with HRP and HERC across 37 risk measures using naive risk parity inside clusters, and Nested Clustered Optimization with four objectives. PyPortfolioOpt’s documented feature set centers on HRP and Black-Litterman instead.

The README feature list states that hierarchical clustering supports both Hierarchical Risk Parity (HRP) and Hierarchical Equal Risk Contribution (HERC), with naive risk parity applied inside clusters and 37 risk measures available at that level. Nested Clustered Optimization (NCO) is listed with four objectives, and Relaxed Risk Parity also appears.

The contrast with PyPortfolioOpt is scope, not quality. PyPortfolioOpt’s repository lists Hierarchical Risk Parity and Black-Litterman among its features. Riskfolio-Lib exposes a much larger set of risk measures to the clustering layer and adds NCO and relaxed risk parity. If HRP from PyPortfolioOpt already works for you, there is no reason to migrate. If you want intra-cluster allocation driven by EDaR rather than variance, that is a configuration Riskfolio-Lib’s docs describe.

Beyond Mean-Variance: Kelly, Worst-Case, OWA, MVSK, and Black-Litterman Variants

The library adds logarithmic mean risk (Kelly) optimization with four objective functions, worst-case mean variance, OWA, MVSK via semidefinite relaxation, and a Black-Litterman family spanning Bayesian, risk-factor, augmented, and entropy-pooling variants. Our earlier Black-Litterman post covers the PyPortfolioOpt implementation, which is narrower in scope.

The four objective functions, per the documented feature list, are Minimum Risk, Maximum Return, Maximum Utility Function, and Maximum Risk Adjusted Return Ratio. They apply to both mean-risk and logarithmic mean risk (Kelly) optimization, so the same objective vocabulary carries across problem classes.

Beyond that, the README lists Worst Case Mean Variance, Relaxed Risk Parity, OWA (ordered weighted averaging), and MVSK — mean-variance-skewness-kurtosis — via semidefinite relaxation. The Black-Litterman family is the broadest item: Black-Litterman, a Risk Factors model, Black-Litterman Bayesian, Augmented Black-Litterman, and Entropy Pooling, the last being a general framework for blending views with a prior distribution.

MVSK deserves a caveat. Skewness and kurtosis objectives are non-convex in general, and the README describes a semidefinite relaxation, which is an approximation. Treat any MVSK result as a relaxation of the problem you wanted to solve and check the 7.4 documentation for the exact formulation.

Constraints That Matter to Real Portfolios: Cardinality, Turnover, Tracking Error

The docs list tracking error and turnover limits, short positions and leverage, maximum and effective number of assets, graph-based information, and integer constraints covering cardinality on assets and categories plus mutually exclusive and joint investment rules — the operational layer most textbook optimizers skip.

The documentation enumerates tracking error and turnover constraints; short positions and leverage limits; maximum number of assets and effective number of assets; graph-based information constraints; and integer constraints covering cardinality on assets, cardinality on categories, mutually exclusive investment, and joint investment.

Cardinality changes the character of the problem. “Hold at most 15 names” turns a convex program into a mixed-integer one. skfolio’s README lists cardinality constraints too, so check each library’s documented scope before assuming a feature is missing. Mutually exclusive and joint investment constraints encode rules like “hold at most one of these two ETFs” or “if you hold A you must hold B”. Effective number of assets is a softer version, controlling concentration without hard integer cuts.

Turnover and tracking error constraints are what make an optimizer deployable. An unconstrained mean-risk solution can churn the book every rebalance; the docs list turnover among the constraints on the optimizer itself, so the cap is part of the optimization rather than a filter applied afterward.

Riskfolio-Lib vs PyPortfolioOpt vs skfolio: Which One for Which Job?

Choose by documented scope, not by speed: Riskfolio-Lib for risk-measure and constraint breadth, PyPortfolioOpt for a lightweight mean-variance, Black-Litterman and HRP workflow, and skfolio for scikit-learn-style cross-validation and hyperparameter tuning. No performance comparison is implied; the repositories describe different feature surfaces.

Library License Repo snapshot (fetched 2026-10-28) Documented scope focus
Riskfolio-Lib BSD-3-Clause 4.6k stars, 447 commits, latest commit Oct 22, 2026 26 convex measures in mean-risk, 22 in risk parity, 37 in hierarchical clustering; drawdown family; integer/cardinality constraints
PyPortfolioOpt MIT 6.1k stars, 865 commits, v1.6.0 (Feb 26, 2026), last main commit Jul 7, 2026 Mean-variance, Black-Litterman, HRP; notebook-heavy repo (94.1% Jupyter, 5.9% Python)
skfolio BSD-3-Clause 2.6k stars; requires Python 3.10+ scikit-learn-compatible estimators, cross-validation and hyperparameter tuning; drawdown measures (CDaR, EDaR, Ulcer Index) and cardinality constraints in its README; arXiv 2507.04176

Notes on the table. PyPortfolioOpt is MIT-licensed, and its release history shows v1.6.0 dated February 26, 2026, with the last main-branch commit on July 7, 2026 (PR #735, a documentation link fix). Its language breakdown is 94.1% Jupyter Notebook and 5.9% Python by GitHub’s language count, a figure that describes the repository’s file mix and says nothing about the library’s quality or features. skfolio is BSD-3-Clause, built on scikit-learn, and its documentation and user guide describe a scikit-learn-compatible interface with cross-validation and hyperparameter tuning; the accompanying arXiv preprint 2507.04176 by Nicolini, Manzi and Delatte (2025) describes the design, and the Zenodo record archives the software. skfolio requires Python 3.10+ per its repo.

The practical split: if your problem is “which of these 40 candidate portfolios generalizes best out of sample,” skfolio’s estimator interface is the natural fit. If your problem is “give me a standard mean-variance or Black-Litterman portfolio with minimal ceremony,” PyPortfolioOpt is the shorter path. If your problem is “optimize CDaR subject to a turnover cap and at most 15 names,” Riskfolio-Lib is the one whose docs describe those constraints. None of these statements is a performance claim.

Getting Started: Install and a Minimal Optimization Sketch

Install with pip install riskfolio-lib, which resolves to version 7.4.0 on PyPI. The sketch assumes a pandas returns DataFrame in and weights out, with a portfolio object configured by a risk measure and constraints — verify exact signatures against the 7.4 docs.

pip install riskfolio-lib
pip show riskfolio-lib

The snippet below is an illustrative sketch — not executed output; verify signatures against the Riskfolio-Lib 7.4 docs. It shows the shape of the workflow, not a validated recipe; method names and keyword arguments should be checked against the current documentation before you rely on them.

# Illustrative sketch — not executed output; verify signatures against the Riskfolio-Lib 7.4 docs.
import pandas as pd
import riskfolio as rp

returns = pd.read_csv("returns.csv", index_col=0, parse_dates=True)

port = rp.Portfolio(returns=returns)
port.assets_stats(method_mu="hist", method_cov="hist")

# The documented pattern: choose a model, a risk measure, and an objective.
w = port.optimization(model="Classic", rm="CVaR", obj="Sharpe", hist=True)
print(w)

Three caveats. The risk-measure string in the optimization call is the pivot point of the whole library — swapping "CVaR" for a drawdown measure changes the objective in this sketch; confirm the accepted names in the docs. The covariance and expected-return estimators are configuration, not defaults to accept blindly; if you have read our piece on shrinkage covariance estimation with Ledoit-Wolf for portfolio construction, that is the same decision point. And integer constraints change the solver class, so expect to configure the solver rather than rely on defaults — check the docs for what the library expects. The same docs recommend MOSEK, a commercial solver, for several exponential-cone and power-cone measures (EVaR, RLVaR, Tail Gini, EDaR, RLDaR, GMD), because CLARABEL can fail to find a solution and SCS can be slow, so the solver license is part of the cost.

FAQ

Riskfolio-Lib is a broad, BSD-3-Clause portfolio optimization library; the questions that come up most are whether it replaces PyPortfolioOpt or skfolio, whether it still handles CVaR and Sortino, and what the install, license and Python requirements look like. Short answers below.

Is Riskfolio-Lib a replacement for PyPortfolioOpt or skfolio?

No — it is a different scope, not a successor. Riskfolio-Lib’s docs describe a much wider risk-measure catalog (26 convex measures in mean-risk, 22 in risk parity, 37 in hierarchical clustering) plus integer and cardinality constraints. PyPortfolioOpt covers mean-variance, Black-Litterman and HRP, and skfolio targets scikit-learn-style cross-validation and tuning. Pick by problem shape.

Does Riskfolio-Lib support CVaR and Sortino optimization?

Yes. CVaR appears in the documented downside-measure list, and the second lower partial moment behind the Sortino ratio is listed alongside it, per the project README. For the underlying math, our guide to CVaR portfolio optimization in Python comparing PyPortfolioOpt and skfolio and how the Sortino ratio and second lower partial moment handle downside risk in Python already cover it.

What license, install command, and Python version does it need?

Riskfolio-Lib is BSD-3-Clause per its GitHub repository, and installs with pip install riskfolio-lib, which resolves to 7.4.0 on PyPI. Riskfolio-Lib 7.4.0 supports Python 3.10 or higher, per its PyPI release page. skfolio also requires Python 3.10 or later.

The Bottom Line

Riskfolio-Lib is worth adding to your toolkit when the problem is the breadth of the objective or the constraint set, not the speed of a solve. Its drawdown family and integer constraints are the clearest capabilities beyond what the libraries covered elsewhere on this site offer.

In short: if you are optimizing CVaR or a Sortino-style measure and nothing else, the library you already use is fine, and the CVaR and Sortino posts on this site are the relevant reading. If you need CDaR, EDaR, RLVaR, Tail Gini, or a cardinality-constrained problem with turnover limits, Riskfolio-Lib’s documentation describes those capabilities directly, and the repository shows a project still being maintained as of October 2026. The caveat from the top still applies: this assessment is documentation-based, not benchmark-based, and the only way to know whether a given risk measure improves your portfolio is to test it on your own data.

← Back to all posts