Skip to main content
Back

skfolio Brings Portfolio Optimization Into scikit-learn's Open-Source Ecosystem

A scikit-learn compatible library brings modern portfolio construction, risk modeling, and stress testing into a single Pythonic API.

  • skfolio is a BSD-licensed Python library bringing portfolio optimization into the scikit-learn ecosystem.
  • Every optimizer exposes fit/predict, so GridSearchCV and Pipelines work out of the box.
  • Ships Mean-Risk, Risk Parity, Hierarchical Risk Parity, Nested Clusters, and Stacking optimizers.
  • Supports 20+ risk measures including CVaR, EVaR, CDaR, and Ulcer Index.
  • Vine copulas plus Entropy Pooling enable conditional stress tests and view-driven priors.
  • Companion arXiv paper documents the design and estimator API.

Portfolio optimization has long lived in a tangle of specialized libraries, each with its own API quirks, making it hard to combine cross-validation, hyperparameter tuning, and modern risk models in one workflow. skfolio tackles that by bolting a full portfolio construction and risk management stack directly onto scikit-learn, so estimators, pipelines, and grid searches work the way you already expect.

The library ships under a BSD 3-Clause license, installs via pip install -U skfolio, and requires Python 3.10+ with the usual numeric stack plus cvxpy and clarabel for the convex solvers. Every optimizer exposes a unified interface for building, tuning, cross-validating, and stress-testing portfolio models.

Why another portfolio library

The motivation is well trodden in quant circles. Since Markowitz (1952), mean-variance optimization has attracted enormous attention, yet it suffers from high sensitivity to input parameters, weight concentration, high turnover, and poor out-of-sample performance. Naive allocations like 1/N or inverse-vol tend to beat MVO once you leave the training window.

The field responded with dozens of fixes: shrinkage, robust uncertainty sets, higher moments, Bayesian priors, risk parity, hierarchical clustering, and ensembles. Given how many methods exist and how freely they can be combined, practitioners need a unified framework with a machine-learning approach to model selection, validation, and parameter tuning that also guards against data leakage and overfitting. That is the gap skfolio fills.