skfolio
Portfolio optimization built on top of scikit-learn
What it is and what it does
skfolio is a machine-learning-focused portfolio optimization framework built on scikit-learn's API. It addresses shortcomings in classical mean-variance optimization by offering a unified toolkit for model selection, validation, and parameter tuning while mitigating overfitting and data leakage. The library provides naive allocation strategies (equal-weight, inverse-volatility), convex optimization methods (mean-risk, risk budgeting, maximum diversification), clustering-based approaches (hierarchical risk parity), and ensemble techniques. It also includes estimators for expected returns, covariance matrices, distributions, and priors, plus cross-validation and hyperparameter tuning compatible with scikit-learn's ecosystem.
The package is designed for quantitative finance practitioners and researchers who need to experiment with multiple portfolio construction methods and compare their out-of-sample performance. Its dependencies—numpy, scipy, pandas, scikit-learn, plotly, cvxpy-base, and clarabel—provide numerical computing, optimization, data handling, and visualization. The library targets Python 3.10 and later and is actively maintained with recent releases.
Use it for:
- Build and backtest mean-risk portfolio models with different covariance estimators and risk measures.
- Compare naive allocation strategies against optimized portfolios using walk-forward or purged cross-validation.
- Construct hierarchical risk parity or equal-risk-contribution portfolios for diversification.
- Stress-test portfolio allocations under different market regimes or synthetic scenarios.
- Tune portfolio optimization hyperparameters (e.g., regularization, constraints) via grid or randomized search.
- Estimate expected returns and covariance using shrinkage, denoising, or regime-adjusted methods.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
skfolio is a Python library for portfolio optimization and risk management that integrates with scikit-learn to build, tune, cross-validate, and stress-test portfolio models using a unified interface.
Yes. skfolio is actively maintained, has no known vulnerabilities, uses a permissive license, and offers low install friction. It is well-suited for anyone building quantitative portfolio models in Python who wants scikit-learn-style workflows, multiple optimization methods, and robust cross-validation. The 2101 GitHub stars and recent release cycle signal a mature, community-backed project. Install it if you need portfolio optimization; skip it if you only need basic mean-variance calculations or prefer a different API.
Install
skfolio on PyPI
pip
pip install skfoliouv
uv add skfoliopoetry
poetry add skfolioInstalling skfolio
Before you install
Low install friction with a pure-Python wheel and eight well-established dependencies (numpy, scipy, pandas, scikit-learn, plotly, cvxpy-base, clarabel, joblib). Actively maintained with a release 1 day old and 2101 GitHub stars.
License in practice
Distributed under the permissive BSD 3-Clause License, which permits commercial and private use with minimal restrictions—only requiring retention of copyright and license text in source distributions.
Quickstart
pip install skfolio
from skfolio.optimization import MeanRisk
from skfolio.datasets import load_sp500_dataset
prices = load_sp500_dataset()
model = MeanRisk()
model.fit(prices)
Requires Python >= 3.10; cvxpy-base and clarabel are compiled dependencies that may require a C compiler or prebuilt wheels on some platforms.
Verify before relying
- Whether the library handles missing data or late-inception assets automatically or requires preprocessing.
- Performance characteristics and scalability limits for large universes of assets or long time series.
- Whether enterprise support from Skfolio Labs is included or requires a separate contract.
Package facts
| License | BSD 3-Clause License Copyright (c) 2023-2026 The skfolio developers. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — numpy, scipy, pandas, cvxpy-base, clarabel, scikit-learn, joblib, plotly |
| Maintenance | actively maintained — 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 92,039/month — #13,485 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: skfolio-0.20.2-py3-none-any.whl
Keywords: portfolio, optimization, optimisation, finance, asset, allocation, quantitative, quant, investment, strategy, machine-learning, scikit-learn, data-mining, data-science
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
pyportfoliooptPyPortfolioOpt implements portfolio…
permissive · top 15,000 on PyPI
riskfolio-libRiskfolio-Lib builds optimized investment…
permissive · top 15,000 on PyPI
quantstatsQuantStats computes portfolio performance…
permissive · top 15,000 on PyPI
QuantLibQuantLib provides Python bindings to a C++…
permissive · top 5,000 on PyPI
empyrical-reloadedComputes financial return and risk…
permissive · top 15,000 on PyPI
gs-quantGS Quant is a Python toolkit for quantitative…
permissive · top 15,000 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
backtestingBacktesting.py lets you define and test trading…
agpl · top 15,000 on PyPI
quantile-forestQuantile regression forests for estimating…
permissive · top 15,000 on PyPI
numpy-financialProvides elementary financial functions (IRR,…
permissive · top 5,000 on PyPI