Riskfolio-Lib
Python library for portfolio optimization built on CVXPY and Pandas, with mean-risk, risk parity, hierarchical clustering and Black-Litterman models plus reports and charts.
Compare how different portfolio-construction methods and risk measures behave on your own returns data, all in Python.
Who it is for
Students, analysts and Python users who want to study diversification and risk budgeting on their own data, for research and education.
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.
Custom bots are coming soon
We are preparing a service to build bots on tools like this one. Follow our Telegram channel to know when it opens.
Real-life uses
Diversification check for a small watchlist
Feed the daily returns of a handful of assets into a script that compares equal-weight, risk-parity and hierarchical portfolios, so you see how risk is spread before choosing any limits. Illustrative only, never a promise of returns.
Compare it with others
PyPortfolioOpt vs Riskfolio-Lib vs skfolio: which Python portfolio optimization library to start with
Three free, open-source Python libraries for portfolio optimization compared from checked sources: methods, risk models, validation tools, level and who each one suits.
Riskfolio-Lib vs skfolio vs QuantStats: free Python tools for portfolio analysis
Three free, open-source Python libraries compared: build portfolios with Riskfolio-Lib or skfolio, then review any returns series with QuantStats. Features, requirements, level and who each suits.
Quick answers
How much does Riskfolio-Lib cost?
Free and open source (BSD-3-Clause). Optional commercial solvers such as MOSEK or GUROBI are separate products; check their official websites for costs. Prices change, so check the official website before you decide.
Is Riskfolio-Lib open source?
Yes. License: BSD-3-Clause.
Who is Riskfolio-Lib for?
Students, analysts and Python users who want to study diversification and risk budgeting on their own data, for research and education.
What is Riskfolio-Lib written in?
Riskfolio-Lib is written in Python.
What should I know before using Riskfolio-Lib?
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.
Want a bot like this when custom bots open? Get notified · All comparisons · Guides
Sources
Every fact on this page comes from these sources, checked on 2026-11-13. If something has changed, the source wins.
- https://raw.githubusercontent.com/dcajasn/Riskfolio-Lib/master/README.md: features, risk measure counts, constraints, reports, pip install, Python 3.10+, optional MOSEK/GUROBI, docs link
- https://api.github.com/repos/dcajasn/Riskfolio-Lib: BSD-3-Clause, about 4,600 stars, last push 2026-11-04, not archived
Alternatives in Backtesting
FinRL
Open-source Python framework for learning and experimenting with reinforcement-learning trading agents on stock, crypto and portfolio environments.
NautilusTrader
High-performance algorithmic trading platform (Rust core, used from Python) that runs the same strategy code in backtests and live.
Qlib
Microsoft's open-source quantitative research platform that covers data processing, machine-learning model training and backtesting in one workflow, driven by config files or Python code.
skfolio
Python library for portfolio optimization and risk management built on scikit-learn, with cross-validation tools to test portfolio models on walk-forward and purged splits.