Qlib is an open-source AI-oriented quantitative investment platform from Microsoft, designed to leverage AI technology to realize the potential of quantitative investment, empower research, and create value, supporting the entire process from exploring ideas to implementing production. It is an open-source platform specifically designed for quantitative researchers in the modern AI era.
Qlib adopts a modular design, based on modern research workflows, providing maximum flexibility to adapt to AI technology. Quantitative researchers can extend modules and build workflows to efficiently try out their ideas.
The platform includes a complete ML pipeline, covering data processing, model training, backtesting, and automated workflows for the entire quantitative investment process.
Qlib supports multiple machine learning modeling paradigms, including supervised learning, market dynamics modeling, and reinforcement learning. The platform is constantly releasing more and more SOTA quantitative research work/papers.
The Qlib Reinforcement Learning Toolkit (QlibRL) is an RL platform for quantitative investment, providing support for implementing RL algorithms in Qlib. RL methods have demonstrated significant achievements in various applications such as games, resource allocation, and recommendation systems.
Other functions include risk modeling, portfolio optimization, Alpha mining, and order execution.
Qlib adopts a highly modular architecture design, where each module can be independently extended and customized:
# Example: Basic Qlib workflow
import qlib
from qlib.constant import REG_CN
from qlib.utils import exists_qlib_data, init_instance_by_config
from qlib.workflow import R
from qlib.tests.data import GetData
# Initialize Qlib
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
qlib.init(provider_uri=provider_uri, region=REG_CN)
# Data processing example
from qlib.data import D
# Get stock data
instruments = D.instruments(market='csi300')
data = D.features(instruments, fields=['$open', '$high', '$low', '$close'])
This is the first open-source platform covering the workflow of modern quantitative researchers in the AI era, providing a foundation for community contributions.
Designed for processing large-scale financial data, it has high-performance computing capabilities.
Using Qlib, users can easily try out their ideas to create better quantitative investment strategies.
The modular architecture supports rapid integration of custom algorithms and strategies.
# Install Qlib
pip install pyqlib
# Download sample data
python scripts/get_data.py qlib_data/cn_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
# Create a simple trading strategy
import qlib
from qlib.constant import REG_CN
# Initialization
qlib.init(provider_uri="~/.qlib/qlib_data/cn_data", region=REG_CN)
# Data acquisition and processing
from qlib.data import D
instruments = D.instruments(market='csi300')
# Model training
from qlib.contrib.model.gbdt import LGBModel
model = LGBModel()
# Backtesting
from qlib.contrib.strategy.signal_strategy import TopkDropoutStrategy
strategy = TopkDropoutStrategy()
Microsoft Qlib, as an open-source AI-oriented quantitative investment platform, provides a powerful toolset for the FinTech field. It not only meets the needs of academic research but also provides a reliable infrastructure for industrial applications. Through its modular design and rich functionality, Qlib is becoming an important open-source platform in the quantitative investment field.