skfolio/skfolio

Python library for portfolio optimization built on top of scikit-learn

What it solves

Traditional mean-variance optimization (MVO) often suffers from high sensitivity to input parameters, weight concentration, and poor out-of-sample performance. skfolio provides a unified, machine-learning-oriented framework to build, fine-tune, and validate portfolio models, helping users mitigate risks like data leakage and overfitting through a standardized API.

How it works

Built on top of scikit-learn, skfolio implements a wide array of portfolio optimization and risk management tools. It allows users to define a pipeline that includes:

  • Estimators: Tools for calculating expected returns, covariance, and variance, including advanced methods like denoising and shrinkage.
  • Optimization Models: Various strategies ranging from naive allocations (Equal-Weighted) to complex convex optimization (Mean-Risk, Risk Budgeting) and clustering methods (Hierarchical Risk Parity).
  • Prior Estimators: Integration of views via Black & Litterman, factor models, or synthetic data generation using Vine Copulas.
  • Validation Tools: Specialized cross-validation techniques for time-series data, such as Walk Forward and Combinatorial Purged Cross-Validation.
  • Constraints: Support for transaction costs, management fees, and various weight or group constraints.

Who it’s for

Quantitative researchers, portfolio managers, and data scientists who need a robust, scikit-learn-compatible library for professional asset allocation and risk management.

Highlights

  • Scikit-learn Integration: Fully compatible with GridSearchCV, RandomizedSearchCV, and Pipeline for seamless model selection and hyper-parameter tuning.
  • Extensive Model Library: Supports a vast range of risk measures (CVaR, EVaR, Maximum Drawdown) and optimization objectives.
  • Advanced Risk Management: Includes tools for stress testing via synthetic data and entropy pooling to incorporate subjective views.
  • Robust Validation: Implements specialized financial cross-validation to prevent look-ahead bias.

Related

  • Project
  • Project
  • Project
  • Project
  • Project