skfolio/skfolio
Python library for portfolio optimization and risk models, built on scikit-learn
What it solves
Classic mean-variance optimization (MVO) is highly sensitive to input estimates, leads to concentrated weights, high turnover, and poor out-of-sample performance. Many alternative methods exist, but they lack a common, machine-learning-friendly interface for model selection, validation, and hyperparameter tuning. skfolio solves this by providing a unified, scikit-learn-style framework that lets you build, fine-tune, cross-validate, and stress-test portfolio models while reducing data leakage and overfitting.
How it works
skfolio follows scikit-learn's API with methods like fit() and predict(). It offers a large set of interchangeable components: prior estimators (empirical, factor models, Black-Litterman), expected return and covariance estimators, risk measures, and optimization objectives. You can combine these into pipelines and use scikit-learn's cross-validation and grid search, along with financial-specific techniques like WalkForward and Combinatorial Purged Cross-Validation. It also includes pre-selection transformers, uncertainty sets, and synthetic data generators for stress testing.
Who it’s for
Quantitative researchers, portfolio managers, and Python developers who want to build, validate, and deploy portfolio optimization models using a familiar machine-learning workflow. It is open-source but also backed by Skfolio Labs for enterprise support, making it suitable for institutional use.
Highlights
- Seamless integration with scikit-learn's ecosystem (pipelines, cross-validation, hyperparameter search)
- Broad selection of optimization models: naive, convex, clustering-based, and ensemble methods
- Many estimators for covariance, expected returns, and risk measures (including CVaR, drawdown, and copulas)
- Specialized cross-validation schemes for financial time series (WalkForward, CombinatorialPurgedCV)
- Factor model construction with 46 descriptors and support for attribution and alpha estimation
- Built-in stress testing via synthetic data and uncertainty sets
Related
- Project
- Project
- Project
- Project
- Project