What it does
skfolio is a Python library for portfolio optimization, factor models and risk analysis built around scikit-learn conventions. It supports model fitting, parameter tuning, cross-validation and stress tests. The BSD-licensed core is free, while Skfolio Labs provides separate enterprise support.
A portfolio model can be placed in a familiar estimator workflow, then evaluated on observations it did not use for fitting. skfolio’s quick start converts prices to returns, separates earlier training data from later test data without shuffling, fits a MeanRisk model and calls predict to obtain a portfolio summary. Weight constraints, group limits and transaction costs can be included in the model.
Choose what the evaluation represents
Two settings make a material difference. weight_drift=False keeps target weights fixed while calculating returns within a holding period. Setting it to True lets weights change as the assets’ returns differ, until the next rebalance. compounded controls whether cumulative returns are added or compounded into a wealth path. Both default to False.
For example, a comparison of target-allocation decisions answers a different question from reconstructing holdings that drift between annual rebalances. The same target weights can produce different drawdowns under these settings. Keeping the settings with the result helps make that comparison understandable.
The current library requires Python 3.10 or later and is installed with pip install -U skfolio. Local use does not need a product account. The project publishes the code under BSD 3-Clause terms; institutional support and service agreements are offered separately through Skfolio Labs.
Strengths
- Uses scikit-learn-compatible fitting and model-selection patterns
- Supports weight, group and transaction-cost inputs
- Makes weight drift and return compounding separate evaluation controls
Watch out for
- Default cumulative-return settings do not reconstruct a compounded holdings path
- Portfolio weights remain sensitive to the estimates used by the model
Best for
- Python analysts evaluating portfolio models on unseen periods
- Teams comparing allocation decisions with realistic holding-period behavior
Sources
- skfolio installation, model fitting and portfolio constraints (Oct 27, 2026)
- skfolio evaluation conventions for weight drift and compounding (Oct 27, 2026)
- skfolio user guide and enterprise-support distinction (Oct 27, 2026)
- skfolio BSD 3-Clause licence (Oct 27, 2026)
