📰
What's NEW!
💖
Recent released features
Feature | Status |
---|---|
ADD model | Released on Nov 22, 2021 |
ADARNN model | Released on Nov 14, 2021 |
TCN model | Released on Nov 4, 2021 |
Temporal Routing Adaptor (TRA) | Released on July 30, 2021 |
Transformer & Localformer | Released on July 22, 2021 |
Release Qlib v0.7.0 | Released on July 12, 2021 |
TCTS Model | Released on July 1, 2021 |
Online serving and automatic model rolling | |
DoubleEnsemble Model | Released on Mar 2, 2021 |
High-frequency data processing example | Released on Feb 5, 2021 |
High-frequency trading example | Part of code released on Jan 28, 2021 |
High-frequency data(1min) | Released on Jan 27, 2021 |
Tabnet Model | Released on Jan 22, 2021 |
Features released before 2021 are not listed here.
Qlib is an AI-oriented quantitative investment platform, which aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment.
It contains the full ML pipeline of data processing, model training, back-testing; and covers the entire chain of quantitative investment: alpha seeking, risk modeling, portfolio optimization, and order execution.
With Qlib, users can easily try ideas to create better Quant investment strategies.
For more details, please refer to our paper "Qlib: An AI-oriented Quantitative Investment Platform".
- Plans
- Framework of Qlib
- Quick Start
- Quant Model(Paper) Zoo
- Quant Dataset Zoo
- More About Qlib
- Offline Mode and Online Mode
- Related Reports
- Contact Us
- Contributing
Plans
New features under development(order by estimated release time). Your feedbacks about the features are very important.
Feature | Status |
---|---|
Planning-based portfolio optimization | Under review: https://github.com/microsoft/qlib/pull/280 |
Fund data supporting and analysis | Under review: https://github.com/microsoft/qlib/pull/292 |
Point-in-Time database | Under review: https://github.com/microsoft/qlib/pull/343 |
High-frequency trading | Under review: https://github.com/microsoft/qlib/pull/408 |
Meta-Learning-based data selection | Initial opensource version under development |
Framework of Qlib
At the module level, Qlib is a platform that consists of the above components. The components are designed as loose-coupled modules, and each component could be used stand-alone.
Name | Description |
---|---|
Infrastructure layer |
Infrastructure layer provides underlying support for Quant research. DataServer provides a high-performance infrastructure for users to manage and retrieve raw data. Trainer provides a flexible interface to control the training process of models, which enable algorithms to control the training process. |
Workflow layer |
Workflow layer covers the whole workflow of quantitative investment. Information Extractor extracts data for models. Forecast Model focuses on producing all kinds of forecast signals (e.g. alpha, risk) for other modules. With these signals Portfolio Generator will generate the target portfolio and produce orders to be executed by Order Executor . |
Interface layer |
Interface layer tries to present a user-friendly interface for the underlying system. Analyser module will provide users detailed analysis reports of forecasting signals, portfolios and execution results |
- The modules with hand-drawn style are under development and will be released in the future.
- The modules with dashed borders are highly user-customizable and extendible.
Quick Start
This quick start guide tries to demonstrate
- It's very easy to build a complete Quant research workflow and try your ideas with Qlib.
- Though with public data and simple models, machine learning technologies work very well in practical Quant investment.
Here is a quick demo shows how to install Qlib
, and run LightGBM with qrun
. But, please make sure you have already prepared the data following the instruction.
Installation
This table demonstrates the supported Python version of Qlib
:
install with pip | install from source | plot | |
---|---|---|---|
Python 3.7 | |
|
|
Python 3.8 | |
|
|
Python 3.9 | |
|
|
Note:
- Conda is suggested for managing your Python environment.
- Please pay attention that installing cython in Python 3.6 will raise some error when installing
Qlib
from source. If users use Python 3.6 on their machines, it is recommended to upgrade Python to version 3.7 or useconda
's Python to installQlib
from source. - For Python 3.9,
Qlib
supports running workflows such as training models, doing backtest and plot most of the related figures (those included in notebook). However, plotting for the model performance is not supported for now and we will fix this when the dependent packages are upgraded in the future.
Install with pip
Users can easily install Qlib
by pip according to the following command.
pip install pyqlib
Note: pip will install the latest stable qlib. However, the main branch of qlib is in active development. If you want to test the latest scripts or functions in the main branch. Please install qlib with the methods below.
Install from source
Also, users can install the latest dev version Qlib
by the source code according to the following steps:
-
Before installing
Qlib
from source, users need to install some dependencies:pip install numpy pip install --upgrade cython
-
Clone the repository and install
Qlib
as follows.- If you haven't installed qlib by the command
pip install pyqlib
before:git clone https://github.com/microsoft/qlib.git && cd qlib python setup.py install
- If you have already installed the stable version by the command
pip install pyqlib
:git clone https://github.com/microsoft/qlib.git && cd qlib pip install .
Note: Only the command
pip install .
can overwrite the stable version installed bypip install pyqlib
, while the commandpython setup.py install
can't. - If you haven't installed qlib by the command
Tips: If you fail to install Qlib
or run the examples in your environment, comparing your steps and the CI workflow may help you find the problem.
Data Preparation
Load and prepare data by running the following code:
# get 1d data
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
# get 1min data
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
This dataset is created by public data collected by crawler scripts, which have been released in the same repository. Users could create the same dataset with it.
Please pay ATTENTION that the data is collected from Yahoo Finance, and the data might not be perfect. We recommend users to prepare their own data if they have a high-quality dataset. For more information, users can refer to the related document.
Automatic update of daily frequency data (from yahoo finance)
It is recommended that users update the data manually once (--trading_date 2021-05-25) and then set it to update automatically.
For more information refer to: yahoo collector
-
Automatic update of data to the "qlib" directory each trading day(Linux)
-
use crontab:
crontab -e
-
set up timed tasks:
* * * * 1-5 python
-