skfolio: Portfolio Optimization in Python
Citation. The library: Hugo Delatte, Carlo Nicolini and Matteo Manzi. skfolio, release v1.15.2, 27 November 2026. Zenodo concept DOI 10.5281/zenodo.16148630. Site: skfolio.org. Source: github.com/skfolio/skfolio, BSD 3-clause licence. The paper: Carlo Nicolini, Matteo Manzi and Hugo Delatte. "skfolio: Portfolio Optimization in Python". Proceedings of the International Research and Industry Symposium on AI (IRIS-AI 25), 2025, pp. 35–41. DOI 10.65236/iris-ai/proceedings/2025/article/3. The README states that "skfolio is backed by Skfolio Labs, which provides enterprise support and SLAs for institutions". The README states no funding. It needs NumPy, SciPy, pandas, cvxpy, Clarabel, scikit-learn and Plotly.
Status. Planned. #332 adds the inverse-volatility benchmark that skfolio offers as a naive model. The project doesn't depend on skfolio. Whether it should, even only to cross-check, is a question for the maintainer below.
Read. Read on 2026-11-28 through a web-fetch subagent. It read these pages from their own text:
- the README, the release tags and
pyproject.toml. - the documentation of
WalkForward,CombinatorialPurgedCV,MultipleRandomizedCVand the model-selection guide. - the documentation of the measures: semi-variance, the first lower partial moment, CVaR, CDaR, maximum drawdown,
RatioMeasure, the deflated Sharpe ratio and the expected maximum Sharpe ratio. - the documentation of
MeanRisk,EqualWeighted,InverseVolatility,Random,SyntheticDataandVineCopula. - the source of
CombinatorialPurgedCV.
The index (llms.txt) and the Portfolio page came back in full for their first part and only as a summary after that. The paper was not read: its page returned no text. So nothing below comes from the paper. The user guide's full CVaR and CDaR formulas were not read.
Summary
Claim. The README presents skfolio as a library for portfolio optimisation and risk management, built on scikit-learn's interface. Each model has fit, and model selection uses scikit-learn's cross-validation and searches.
Method. A library. The parts that a backtest's evaluation touches:
- Model selection.
WalkForward(test_size, train_size, ..., purged_size=0)dropspurged_sizeobservations "from the end of each training set before the test set". It has no embargo.CombinatorialPurgedCV(n_folds=10, n_test_folds=8, purged_size=0, embargo_size=0)drops a fixed number of observations on each side of each test block. The source marks rows by index, not by the time each label ends. It gives splits and test paths.MultipleRandomizedCVdraws a time window and a subset of assets many times, and runs a walk-forward on each.
- Measures. Semi-variance and the first lower partial moment measure returns below a minimum acceptable return. Its default "is to use the returns' mean". The Sortino ratio is "the excess mean (mean - risk_free_rate) divided by the semi standard-deviation". CVaR has
beta=0.95and "averages the worst 1 - beta probability mass". The pages give no standard error for any measure. - The deflated Sharpe ratio.
deflated_sharpe_ratio(returns, trial_sharpe_ratios)is "the Probabilistic Sharpe Ratio benchmarked against the expected maximum Sharpe ratio of the search". It "uses the number of non-NaN trials as the independent trial count", and has no argument to change that. The subagent found no PBO and no other correction for multiple tests. - Costs.
MeanRisksubtracts for transaction costs and for fees from the expected return. Both are per period: the documentation's example spreads a cost of 10 basis points over a month's hold as0.001 / 21. The reported portfolio returns are net of both. - Naive models.
EqualWeightedgives each asset1/n_assets.InverseVolatilityweights each asset by the inverse of its volatility, from the prior's covariance.Randomdraws weights from a Dirichlet distribution. - Stress tests.
SyntheticDatasamples from a fitted distribution, by default a regular vine copula. Itssamplecan condition on an asset's or a factor's value, such as a quality factor at −0.2 or −0.5 in the examples.
Findings, as the source reports them. These are the defaults that matter for a backtest.
| Setting | Number | Value |
|---|---|---|
WalkForward |
purge, and embargo | 0 observations, and none |
CombinatorialPurgedCV |
folds, test folds, splits, paths | 10, 8, 45, 36 |
| The same | purge, and embargo | 0 and 0 observations |
| The Sortino ratio and semi-variance | default minimum acceptable return | the mean of the returns |
| CVaR | default beta |
0.95 |
| The deflated Sharpe ratio | its count of trials | every trial with a Sharpe ratio |
Portfolio |
default annualisation factor | 252 |
Where the claims go beyond the evidence
The purge is a count, not a label's horizon. The docstring of CombinatorialPurgedCV describes López de Prado's purge of training labels "whose labels overlapped in time". The code drops a fixed number of rows instead. The two agree only when every label spans the same number of observations, and the user sets that number.
The defaults leak. Both splitters default to no purge and no embargo. The documentation itself warns that with no purge the results "may be too optimistic" when trades execute with a delay. A user who keeps the defaults has López de Prado's splits without the protection that defines them.
Its Sortino ratio isn't the usual one. The default target is the sample mean, so the denominator is a downside deviation around the mean, not below zero or a fixed target. A Sortino ratio from skfolio and one from another tool can differ for the same returns.
Its deflated Sharpe ratio treats every trial as independent. The documentation warns that correlated trials "may therefore lead to an overly conservative adjustment". The function has no way to pass a smaller, effective count, although expected_max_sharpe_ratio takes one.
No measure has an error. The ratios and tail measures are point estimates. Model selection compares them across folds, with no interval and no test.
The paper is unread. This page couldn't check the paper's claims or tests against the library.
Credit. The documentation states the leak of a zero purge, and the conservatism of its trial count. It cites López de Prado (2018) for the splitters and Bailey and López de Prado (2014) for the deflated Sharpe ratio. It cites Palomar's book for the randomised CV. Its costs and fees enter both the optimiser and the reported returns.
Use in this repo
The splitters: keep the project's own. splits.py (#10) has walk_forward, purged_kfold and cpcv. Each requires purge, the label horizon in observations, and the k-fold splitters also require embargo. There is no default, so a run must state both, and the trial ledger (#7) records them. That is skfolio's fixed count, made explicit. skfolio's splitters add nothing that the project lacks, and their defaults of zero are the leak that #10 exists to stop.
The measures differ from the project's, on purpose.
metrics.sortinouses a target of 0 by default, stored with the result, and gives De Capitani's delta-method error (sortino-omega-intervals.md). skfolio's default target is the mean, and it gives no error.metrics.cvartakes the mean of the worst ⌈αn⌉ returns, andmetrics.cvar_estimateadds Chen's error for dependent returns (expected-shortfall.md). skfolio gives the point estimate only.- So skfolio can't stand in for the metrics. A cross-check would have to set its target and level to the project's.
The trial count: the project's is better informed. metrics.dsr takes the number of trials from Ledger.count (#7) and the variance of their Sharpe ratios. skfolio counts the trial Sharpe ratios that the caller passes. So it misses any trial that the caller didn't record. The calibration found the opposite risk to skfolio's warning (#325). Effective counts that were too small made the deflated Sharpe ratio too lax, not too strict. So the project counts every trial, and independence.dsr_trials gives a smaller N only from the active returns.
PBO stays in the project. skfolio has no PBO. overfitting.pbo (#11) computes it from the trials' returns.
Costs: the project's model is finer. skfolio charges a linear cost per unit of turnover, spread over the holding period. costs.py (#9) charges each venue's own fee schedule per trade, such as IBKR's fixed fee with its minimum and Kalshi's fee, which depends on the price. A linear cost is fine in an optimiser, but the backtest's returns should keep the venue's real fees.
#332: an inverse-volatility benchmark. The harness compares a run with buy-and-hold and 1/N (harness.py). DeMiguel et al. (2009, optimal-versus-naive-diversification.md) find that naive rules are hard to beat out of sample. skfolio's naive models add inverse volatility. #332 adds it as a benchmark, with each volatility from a trailing window only.
Stress tests: the scenarios come from the whole sample. A vine copula fitted on the full history gives scenarios from data that a backtest at an earlier date couldn't have had. For the stress report (#219), a fitted scenario must come from data before the test period. #328 asks the same of its regime labels.
A question for the maintainer. skfolio would add cvxpy, Clarabel, scikit-learn and Plotly, beyond the NumPy, SciPy and pandas that yfinance brings. The options:
- No dependency. The project keeps its own code, and this page records the differences.
- A development dependency, to cross-check
cpcv_paths,dsrandcvaragainst skfolio's in a test, with their settings matched. This is the role that #315 proposes for thearchpackage. - An optional extra for portfolio optimisation, if a portfolio in
registry/portfolios/needs mean-risk weights or risk budgets.
The first option fits the project as it stands, since no portfolio needs an optimiser yet.