Guide · Open source
How to use qlib: install pyqlib and run your first quant workflow
Updated · written with AI from the project's own documentation and checked against our catalogue data
Qlib is an open-source Python platform from Microsoft for quantitative investment research. It is built for analysts who want to test whether machine learning models can predict market behavior from historical data. This guide shows you how to install it, what the workflow covers, and what Qlib does not do, so you can decide whether it fits your project.
Quick start
- 1Check your Python version. Look up the supported Python versions on the pyqlib PyPI page, since the README asks you to confirm the exact range there.
- 2Install pyqlib. Run pip install pyqlib in a clean virtual environment.
- 3Read the documentation. Open the official docs at qlib.readthedocs.io to learn the workflow before writing code.
- 4Run the notebook tutorial. Open the tutorial in the examples/tutorial folder of the repository to see a complete workflow.
- 5Check the artifact loading notes. If you reload saved models or datasets, read the artifact loading migration guide before using trusted=True.
What Qlib is and who it is for
Qlib describes itself as an AI-oriented quantitative investment platform. It covers the process from exploring ideas to running models, and supports supervised learning, market dynamics modeling, and reinforcement learning.
It suits quant researchers who want a structured machine learning workflow for stock data, Python developers experimenting with financial machine learning, and students learning how quantitative research is organized. Teams that want to reuse published quant models listed in the README may also find it useful.
Install Qlib with pip
Qlib is distributed on PyPI under the package name pyqlib. Install it with the command below. The package page on PyPI lists the supported Python version range, and the README asks you to check it for the exact supported versions before you install.
Qlib is licensed under MIT and is written in Python, so you need a working Python environment and comfort with the command line.
- Check the Python versions listed on the PyPI page for pyqlib.
- Use a virtual environment so the install does not conflict with other projects.
pip install pyqlibUnderstand the research workflow
Qlib organizes quant research as a sequence: explore an idea, build a dataset and model, run the model, and evaluate the results. The README frames the platform as covering this path from research to production.
The README also notes that Qlib now connects to RD-Agent, a separate Microsoft project for automating factor mining and model optimization. RD-Agent is a different repository and has its own setup, so treat it as a separate tool.
- Supervised learning models for predicting market behavior.
- Market dynamics modeling.
- Reinforcement learning for decision making.
- Connection to RD-Agent for automated factor mining and model optimization.
Read the unreleased artifact loading change before upgrading
The README flags a backward-incompatible safety default in unreleased source builds. Recorder loads are restricted. If you reload saved models or datasets, resume online or delayed training, or use DDG-DA, you need to verify the artifact writer and storage permissions before opting in with trusted=True (CLI: --trusted=True).
Fresh in-memory training and supported data-only reads do not need this opt-in. Read the artifact loading migration guide linked in the README before upgrading, and match the guide to the version of code you are running.
- Source installs from main may differ from PyPI releases.
- The change stays unreleased until the first tagged release that contains it.
Where to find documentation and examples
The official documentation is hosted at qlib.readthedocs.io. The README also points to a notebook tutorial in the examples/tutorial folder of the repository and to a nested decision framework example in examples/nested_decision_execution.
Start with the documentation and the notebook tutorial to learn the data and model components before you change anything.
What people use it for
- Testing whether a supervised learning model can rank stocks using historical data.
- Comparing published quant models listed in the README on the same data.
- Studying how a quant research pipeline is structured for a course or thesis.
- Experimenting with reinforcement learning for portfolio decisions.
- Exploring automated factor mining through the RD-Agent connection.
Frequently asked questions
Is Qlib free to use?
Qlib is released under the MIT licence, as shown in the repository. The MIT licence permits use under its terms, but check the LICENSE file in the repository for the full text.
What do I need to run Qlib?
You need Python and a command line for installation. The README says the supported Python version range is shown on PyPI, and you should check the README for the exact supported versions.
How do I install Qlib?
Run pip install pyqlib. The package is published on PyPI under the name pyqlib.
Is Qlib a ready-made trading bot?
No. The README describes Qlib as a research platform rather than a turnkey strategy. It does not provide guaranteed returns or investment advice.
What are alternatives to Qlib?
Comparable projects mentioned for this item include FinRL, Zipline, Backtrader and vectorbt. Each one covers a different part of quant work, so compare them against your goal, whether that is machine learning research, backtesting or reinforcement learning.
Why does loading my saved model fail?
The README says recorder loads are restricted by default in unreleased source builds. You may need to verify the artifact writer and storage permissions, then opt in with trusted=True after reading the artifact loading migration guide.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Qlib is a good fit for quant researchers, Python developers and students who want a structured machine learning workflow for stock data. It is not a trading bot or an investment service, and people who are uncomfortable with Python and the command line will find it hard going. If you want a backtesting engine for simple rule-based strategies, a tool such as Backtrader or vectorbt may be a better starting point.
Install options & downloads