TradeBot Check
Trading involves a risk of losing money. Nothing on this site is financial advice and past results do not guarantee future results. Risk disclosure
Comparison · facts checked 2026-11-18

PyPortfolioOpt vs Riskfolio-Lib vs skfolio: which Python portfolio optimization library to start with

PyPortfolioOpt, Riskfolio-Lib and skfolio all turn a table of asset returns into portfolio weights, so they are often searched together. They differ in how much they ask from you: PyPortfolioOpt is the most direct route from prices to weights and whole-share quantities, Riskfolio-Lib offers the widest set of risk measures, and skfolio brings scikit-learn style tools and out-of-sample validation. All three are libraries, not trading bots: none connects to a broker or places orders, and you bring your own price data. This comparison uses only the facts on each tool's review page, and any example is illustrative: optimization is not a forecast and past data does not predict future returns.

Short answer

  • PyPortfolioOpt: Investors and analysts who want a short path from a list of assets to weights, with several risk models, Black-Litterman, Hierarchical Risk Parity and discrete allocation into whole shares (intermediate); MIT licence.
  • Riskfolio-Lib: Students and analysts who want to compare many risk measures and methods on their own returns, with efficient-frontier plots and Jupyter or Excel reports (advanced); BSD-3-Clause.
  • skfolio: Python users who already know scikit-learn and want portfolio models they can tune and test out of sample with walk-forward and purged cross-validation (advanced); BSD-3-Clause.

Want the next comparison in your pocket? Follow our free channel.

PyPortfolioOptRiskfolio-Libskfolio
PriceFree and open source (MIT). Install with pip; market data comes from whichever source you choose, so check the official website of that provider for costs.Free and open source (BSD-3-Clause). Optional commercial solvers such as MOSEK or GUROBI are separate products; check their official websites for costs.Free and open source (BSD-3-Clause).
Cost modelFreeFreeFree
Open sourceYesYesYes
LicenseMITBSD-3-ClauseBSD-3-Clause
LevelIntermediateAdvancedAdvanced
Best forInvestors and analysts who want a short path from a list of assets to weights, with several risk models, Black-Litterman, Hierarchical Risk Parity and discrete allocation into whole shares (intermediate); MIT licence.Students and analysts who want to compare many risk measures and methods on their own returns, with efficient-frontier plots and Jupyter or Excel reports (advanced); BSD-3-Clause.Python users who already know scikit-learn and want portfolio models they can tune and test out of sample with walk-forward and purged cross-validation (advanced); BSD-3-Clause.

PyPortfolioOpt

Turn a list of assets into a clear set of portfolio weights, with sensible risk models and whole-share quantities, in a few lines of Python.

Best for: Investors and analysts who want a short path from a list of assets to weights, with several risk models, Black-Litterman, Hierarchical Risk Parity and discrete allocation into whole shares (intermediate); MIT licence.

Strengths

  • Objectives include maximum Sharpe ratio, minimum volatility, efficient return, efficient risk and maximum quadratic utility.
  • Risk models include sample, semicovariance, exponential and shrinkage covariance (Ledoit-Wolf, Oracle Approximating Shrinkage).
  • Adds Black-Litterman allocation, Hierarchical Risk Parity, mean-CVaR, mean-semivariance and the critical line algorithm.
  • Supports weight bounds, long/short portfolios and discrete allocation that converts weights into whole-share quantities.

Good to know

  • Not a backtesting engine or broker connector: you bring your own price data and execution.
  • Estimates from historical returns and covariance carry estimation risk, and the author notes mean-variance results can have many zero weights.
  • Market-neutral portfolios are not available for the maximum Sharpe or minimum volatility objectives.
  • Needs Python knowledge; the README says tests do not cover every combination of objectives and parameters.

Riskfolio-Lib

Compare how different portfolio-construction methods and risk measures behave on your own returns data, all in Python.

Best for: Students and analysts who want to compare many risk measures and methods on their own returns, with efficient-frontier plots and Jupyter or Excel reports (advanced); BSD-3-Clause.

Strengths

  • Mean-risk and Kelly (log mean-risk) optimization with 26 convex risk measures, plus risk parity with 22 risk measures.
  • Hierarchical clustering portfolios (HRP, HERC) and Nested Clustered Optimization.
  • Black-Litterman, entropy pooling and risk-factor models; constraints such as turnover and cardinality.
  • Efficient-frontier plots and reports in Jupyter and Excel; installs with pip install riskfolio-lib.

Good to know

  • Needs Python 3.10 or higher and a long list of scientific dependencies.
  • Requires some knowledge of portfolio theory; results depend on the data and assumptions you feed in.
  • Some large models work best with commercial solvers (MOSEK, GUROBI), which are separate products.
  • Optimization is not a forecast: any example is illustrative and never a promise of returns.

skfolio

Build, tune and cross-validate portfolio models with the same scikit-learn tools many Python users already know.

Best for: Python users who already know scikit-learn and want portfolio models they can tune and test out of sample with walk-forward and purged cross-validation (advanced); BSD-3-Clause.

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.

Which one should you choose?

Start with PyPortfolioOpt if you are new to portfolio optimization: it is the only one of the three listed as intermediate and it can convert weights into whole-share quantities. Move to Riskfolio-Lib when you want to study many risk measures, risk parity and clustering methods side by side, and to skfolio when you want to validate models with walk-forward or combinatorial purged splits using the scikit-learn tools you may already know. All three are free and open source and need Python knowledge. Include trading costs in your assumptions, test on data the model has not seen, and keep in mind that estimates from historical returns carry estimation risk.

Quick answers

Which one is easiest to start with?

Levels: PyPortfolioOpt (intermediate); Riskfolio-Lib (advanced); skfolio (advanced). Start in a simulated or demo mode whenever the tool has one.

How much do they cost and what licence do they use?

PyPortfolioOpt: Free and open source (MIT). Install with pip; market data comes from whichever source you choose, so check the official website of that provider for costs (licence: MIT). Riskfolio-Lib: Free and open source (BSD-3-Clause). Optional commercial solvers such as MOSEK or GUROBI are separate products; check their official websites for costs (licence: BSD-3-Clause). skfolio: Free and open source (BSD-3-Clause) (licence: BSD-3-Clause). Prices change, so check the official websites before you decide.

What should I know before choosing?

PyPortfolioOpt: Not a backtesting engine or broker connector: you bring your own price data and execution. Riskfolio-Lib: Needs Python 3.10 or higher and a long list of scientific dependencies. skfolio: Needs Python 3.10 or later and some familiarity with scikit-learn and portfolio theory.

Guides that use these tools

Want a bot like this when custom bots open? Get notified · more bot ideas

Coming soon

Coming soon: custom bots

We are preparing a service to code, backtest and automate trading and statistics bots to your own rules. It is not available yet: follow our Telegram channel to know when it opens.

Sources

  1. PyPortfolioOpt: https://raw.githubusercontent.com/robertmartin8/PyPortfolioOpt/master/README.md
  2. PyPortfolioOpt: https://api.github.com/repos/robertmartin8/PyPortfolioOpt
  3. Riskfolio-Lib: https://raw.githubusercontent.com/dcajasn/Riskfolio-Lib/master/README.md
  4. Riskfolio-Lib: https://api.github.com/repos/dcajasn/Riskfolio-Lib
  5. skfolio: https://github.com/skfolio/skfolio
  6. skfolio: https://api.github.com/repos/skfolio/skfolio

More comparisons