skfolio
Python library for portfolio optimization and risk management built on scikit-learn, with cross-validation tools to test portfolio models on walk-forward and purged splits.
Build, tune and cross-validate portfolio models with the same scikit-learn tools many Python users already know.
Who it is for
Python users and students who know scikit-learn and want to compare portfolio-construction methods with proper out-of-sample validation, for research and education.
Strengths
- Follows the scikit-learn API, so it works with Pipeline, GridSearchCV and KFold.
- Naive, mean-risk, risk-budgeting and clustering models such as hierarchical risk parity, plus ensemble stacking.
- Walk-forward and combinatorial purged cross-validation to test models out of sample.
- Constraints on weights, turnover, transaction costs and cardinality; installs with pip install -U skfolio.
Good to know
- Needs Python 3.10 or later and some familiarity with scikit-learn and portfolio theory.
- Results depend on the data and assumptions you provide; past data does not predict future returns.
- A library, not a trading bot: it does not connect to brokers or place orders.
- Any example is illustrative and never a promise of returns.
Custom bots are coming soon
We are preparing a service to build bots on tools like this one. Follow our Telegram channel to know when it opens.
Real-life uses
Out-of-sample check for a portfolio idea
Before trusting a portfolio rule, run it with walk-forward splits so each period is tested on data the model has not seen, and compare the result with a simple equal-weight baseline. Illustrative only, never a promise of returns.
Compare it with others
PyPortfolioOpt vs Riskfolio-Lib vs skfolio: which Python portfolio optimization library to start with
Three free, open-source Python libraries for portfolio optimization compared from checked sources: methods, risk models, validation tools, level and who each one suits.
Riskfolio-Lib vs skfolio vs QuantStats: free Python tools for portfolio analysis
Three free, open-source Python libraries compared: build portfolios with Riskfolio-Lib or skfolio, then review any returns series with QuantStats. Features, requirements, level and who each suits.
Guides that use it
Quick answers
How much does skfolio cost?
Free and open source (BSD-3-Clause). Prices change, so check the official website before you decide.
Is skfolio open source?
Yes. License: BSD-3-Clause.
Who is skfolio for?
Python users and students who know scikit-learn and want to compare portfolio-construction methods with proper out-of-sample validation, for research and education.
What is skfolio written in?
skfolio is written in Python.
What should I know before using skfolio?
Needs Python 3.10 or later and some familiarity with scikit-learn and portfolio theory. Results depend on the data and assumptions you provide; past data does not predict future returns. A library, not a trading bot: it does not connect to brokers or place orders. Any example is illustrative and never a promise of returns.
Want a bot like this when custom bots open? Get notified · All comparisons · Guides
Sources
Every fact on this page comes from these sources, checked on 2026-11-14. If something has changed, the source wins.
- https://github.com/skfolio/skfolio: purpose, optimization models, cross-validation, scikit-learn compatibility, constraints, pip install, Python 3.10+, BSD-3-Clause
- https://api.github.com/repos/skfolio/skfolio: BSD-3-Clause, about 2,600 stars, last push 2026-11-13, not archived
Alternatives in Backtesting
FinRL
Open-source Python framework for learning and experimenting with reinforcement-learning trading agents on stock, crypto and portfolio environments.
NautilusTrader
High-performance algorithmic trading platform (Rust core, used from Python) that runs the same strategy code in backtests and live.
Qlib
Microsoft's open-source quantitative research platform that covers data processing, machine-learning model training and backtesting in one workflow, driven by config files or Python code.
Riskfolio-Lib
Python library for portfolio optimization built on CVXPY and Pandas, with mean-risk, risk parity, hierarchical clustering and Black-Litterman models plus reports and charts.