Riskfolio-Lib vs skfolio vs QuantStats: free Python tools for portfolio analysis
Riskfolio-Lib, skfolio and QuantStats are free Python libraries for studying portfolios and backtests, but they do different jobs. Riskfolio-Lib and skfolio help you construct portfolios (weights, risk measures, constraints); QuantStats takes a series of returns, from a backtest, a bot or a portfolio, and turns it into metrics, charts and an HTML report. They are libraries, not trading bots: none of them connects to a broker or places orders. This side-by-side is built only from the facts on each tool's review page, and any example is illustrative: past data does not predict future returns.
Short answer
- Riskfolio-Lib: Students and analysts who want to compare many risk measures and methods (mean-risk, risk parity, HRP, Black-Litterman) on their own returns, with efficient-frontier plots and reports (advanced).
- skfolio: Python users who already know scikit-learn and want portfolio models they can tune and validate out of sample with walk-forward and purged cross-validation (advanced).
- QuantStats: Anyone with a returns series from a backtest or portfolio who wants Sharpe, drawdowns, monthly heatmaps and a shareable HTML tearsheet in a few lines of Python.
Want the next comparison in your pocket? Follow our free channel.
| Riskfolio-Lib | skfolio | QuantStats | |
|---|---|---|---|
| Price | 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). | Free and open source. |
| Cost model | Free | Free | Free |
| Open source | Yes | Yes | Yes |
| License | BSD-3-Clause | BSD-3-Clause | Apache-2.0 |
| Level | Advanced | Advanced | Intermediate |
| Best for | Students and analysts who want to compare many risk measures and methods (mean-risk, risk parity, HRP, Black-Litterman) on their own returns, with efficient-frontier plots and reports (advanced). | Python users who already know scikit-learn and want portfolio models they can tune and validate out of sample with walk-forward and purged cross-validation (advanced). | Anyone with a returns series from a backtest or portfolio who wants Sharpe, drawdowns, monthly heatmaps and a shareable HTML tearsheet in a few lines of Python. |
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 (mean-risk, risk parity, HRP, Black-Litterman) on their own returns, with efficient-frontier plots and reports (advanced).
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 validate out of sample with walk-forward and purged cross-validation (advanced).
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.
QuantStats
A quick way to see a backtest or portfolio the way analysts do: Sharpe, drawdowns, monthly heatmaps and a shareable HTML report from a few lines of Python.
Best for: Anyone with a returns series from a backtest or portfolio who wants Sharpe, drawdowns, monthly heatmaps and a shareable HTML tearsheet in a few lines of Python.
Strengths
- Metrics include Sharpe, Sortino, volatility, win rate, CVaR and the Kelly criterion.
- Charts cover drawdowns, rolling statistics, monthly returns and yearly returns.
- Report modes (metrics, plots, basic, full, html) produce a complete HTML tearsheet.
- Includes Monte Carlo simulations for probabilistic risk analysis.
Good to know
- Metrics work on return series, not individual trades, so trade-level statistics can differ.
- The README says full documentation is still coming soon.
- Needs Python 3.10 or later plus pandas, numpy, scipy, matplotlib, seaborn and yfinance.
- Past statistics describe history only and are illustrative, not a promise of future results.
Which one should you choose?
Use QuantStats when you already have returns and want to see them clearly; it is the gentlest starting point. Choose Riskfolio-Lib if you want the widest choice of risk measures and classic portfolio-theory models, and skfolio if you prefer the scikit-learn style with built-in out-of-sample validation. The tools combine well: build weights with one of the first two, then review the resulting returns with QuantStats. Include trading costs in your assumptions and remember that optimization is not a forecast.
Quick answers
Which one is easiest to start with?
Levels: QuantStats (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?
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). QuantStats: Free and open source (licence: Apache-2.0). Prices change, so check the official websites before you decide.
What should I know before choosing?
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. QuantStats: Metrics work on return series, not individual trades, so trade-level statistics can differ.
Guides that use these tools
- How to run your first backtest in Python: a moving average crossover in 20 lines
- How to backtest a trading strategy properly: 7 checks before risking money
Want a bot like this when custom bots open? Get notified · more bot ideas
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
- Riskfolio-Lib: https://raw.githubusercontent.com/dcajasn/Riskfolio-Lib/master/README.md
- Riskfolio-Lib: https://api.github.com/repos/dcajasn/Riskfolio-Lib
- skfolio: https://github.com/skfolio/skfolio
- skfolio: https://api.github.com/repos/skfolio/skfolio
- QuantStats: https://github.com/ranaroussi/quantstats
- QuantStats: https://api.github.com/repos/ranaroussi/quantstats