A Quantitative-research Platform
Project description
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.
With Qlib, you can easily try your ideas to create better Quant investment strategies.
For more details, please refer to our paper "Qlib: An AI-oriented Quantitative Investment Platform".
- Framework of Qlib
- Quick Start
- Quant Model Zoo
- Quant Dataset Zoo
- More About Qlib
- Offline Mode and Online Mode
- Contributing
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 |
---|---|
Data layer |
DataServer focuses on providing high-performance infrastructure for users to manage and retrieve raw data. DataEnhancement will preprocess the data and provide the best dataset to be fed into the models. |
Interday Model |
Interday model focuses on producing prediction scores (aka. alpha). Models are trained by Model Creator and managed by Model Manager . Users could choose one or multiple models for prediction. Multiple models could be combined with Ensemble module. |
Interday Strategy |
Portfolio Generator will take prediction scores as input and output the orders based on the current position to achieve the target portfolio. |
Intraday Trading |
Order Executor is responsible for executing orders output by Interday Strategy and returning the executed results. |
Analysis |
Users could get a detailed analysis report of forecasting signals and portfolios in this part. |
- 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.
Installation
Users can easily intsall Qlib
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
:git clone https://github.com/microsoft/qlib.git && cd qlib python setup.py install
Data Preparation
Load and prepare data by running the following code:
python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data
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 high-quality dataset. For more information, users can refer to the related document
Auto Quant Research Workflow
Qlib provides a tool named Estimator
to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). You can start an auto quant research workflow and have a graphical reports analysis according to the following steps:
-
Quant Research Workflow: Run
Estimator
with estimator_config.yaml as following.cd examples # Avoid running program under the directory contains `qlib` estimator -c estimator/estimator_config.yaml
The result of
Estimator
is as follows, please refer to please refer to Intraday Trading for more details about the result.risk excess_return_without_cost mean 0.000675 std 0.005456 annualized_return 0.170077 information_ratio 1.963824 max_drawdown -0.063646 excess_return_with_cost mean 0.000479 std 0.005453 annualized_return 0.120776 information_ratio 1.395116 max_drawdown -0.071216
Here are detailed documents for Estimator.
-
Graphical Reports Analysis: Run
examples/estimator/analyze_from_estimator.ipynb
withjupyter notebook
to get graphical reports-
Forecasting signal (model prediction) analysis
- Cumulative Return of groups
- Return distribution
- Information Coefficient (IC)
- Auto Correlation of forecasting signal (model prediction)
-
Portfolio analysis
- Backtest return
-
Building Customized Quant Research Workflow by Code
The automatic workflow may not suite the research workflow of all Quant researchers. To support a flexible Quant research workflow, Qlib also provides a modularized interface to allow researchers to build their own workflow by code. Here is a demo for customized Quant research workflow by code
Quant Model Zoo
Here is a list of models build on Qlib
.
Your PR of new Quant models is highly welcomed.
Quant Dataset Zoo
Dataset plays a very important role in Quant. Here is a list of the datasets build on Qlib
.
Here is a tutorial to build dataset with Qlib
.
Your PR to build new Quant dataset is highly welcomed.
More About Qlib
The detailed documents are organized in docs. Sphinx and the readthedocs theme is required to build the documentation in html formats.
cd docs/
conda install sphinx sphinx_rtd_theme -y
# Otherwise, you can install them with pip
# pip install sphinx sphinx_rtd_theme
make html
You can also view the latest document online directly.
Qlib is in active and continuing development. Our plan is in the roadmap, which is managed as a github project.
Offline Mode and Online Mode
The data server of Qlib can either deployed as Offline
mode or Online
mode. The default mode is offline mode.
Under Offline
mode, the data will be deployed locally.
Under Online
mode, the data will be deployed as a shared data service. The data and their cache will be shared by all the clients. The data retrieval performance is expected to be improved due to a higher rate of cache hits. It will consume less disk space, too. The documents of the online mode can be found in Qlib-Server. The online mode can be deployed automatically with Azure CLI based scripts. The source code of online data server can be found in Qlib-Server repository.
Performance of Qlib Data Server
The performance of data processing is important to data-driven methods like AI technologies. As an AI-oriented platform, Qlib provides a solution for data storage and data processing. To demonstrate the performance of Qlib data server, we compare it with several other data storage solutions.
We evaluate the performance of several storage solutions by finishing the same task, which creates a dataset (14 features/factors) from the basic OHLCV daily data of a stock market (800 stocks each day from 2007 to 2020). The task involves data queries and processing.
HDF5 | MySQL | MongoDB | InfluxDB | Qlib -E -D | Qlib +E -D | Qlib +E +D | |
---|---|---|---|---|---|---|---|
Total (1CPU) (seconds) | 184.4±3.7 | 365.3±7.5 | 253.6±6.7 | 368.2±3.6 | 147.0±8.8 | 47.6±1.0 | 7.4±0.3 |
Total (64CPU) (seconds) | 8.8±0.6 | 4.2±0.2 |
+(-)E
indicates with (out)ExpressionCache
+(-)D
indicates with (out)DatasetCache
Most general-purpose databases take too much time on loading data. After looking into the underlying implementation, we find that data go through too many layers of interfaces and unnecessary format transformations in general-purpose database solutions. Such overheads greatly slow down the data loading process. Qlib data are stored in a compact format, which is efficient to be combined into arrays for scientific computation.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the right to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pyqlib-0.5.0.dev7-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 216.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17b9f2eb891e7765823d141881f9da843f9b642b606a9ab44c1b74b291e2f053 |
|
MD5 | f6c795f3a820236cc478961880838e9e |
|
BLAKE2b-256 | 2ae7c808d2d4d469cd9f143acd1fe2bd55b33c86d4058586b9d2dda6bef24e6a |
File details
Details for the file pyqlib-0.5.0.dev7-cp38-cp38-manylinux2010_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp38-cp38-manylinux2010_x86_64.whl
- Upload date:
- Size: 612.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a76362e5ad3132d27d862fbb97a121431a6521c1a90ae6cf7b12716ec4beab6 |
|
MD5 | 0df9b5fab063b5e6f7b52a52f186bb99 |
|
BLAKE2b-256 | a850a55a3a35d7c5575cd1fd87e838dd66ad49a3b968fc9e58cc2d3cc058970f |
File details
Details for the file pyqlib-0.5.0.dev7-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 612.1 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e02bac65c5eda9079143347b5ae8816619bfbef0648a02d894fbe0eb06edd74e |
|
MD5 | fcefac01991ec01883a9b2c10e00f569 |
|
BLAKE2b-256 | 88c3239c829a11285a02f8068381d92bc648a13ca25c90a7015e827c7cc8c587 |
File details
Details for the file pyqlib-0.5.0.dev7-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 214.9 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81cc7970361d7a00d3bae4af5e9fe3de5d1410a68d4851e2fdd3c7cf65530aa9 |
|
MD5 | 86d90afd4739ee8c5ca401461dce4055 |
|
BLAKE2b-256 | a3f441eaa3c110227b9c578b5943cb9fd72b78e72c212463b01b626ac0313d56 |
File details
Details for the file pyqlib-0.5.0.dev7-cp37-cp37m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp37-cp37m-manylinux2010_x86_64.whl
- Upload date:
- Size: 574.9 kB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c7259ed42f632c9953b4c7d6074ef31604d5604f005c89d6446f814d5552656 |
|
MD5 | 3a1b59fc198db4aafab787b918497dd9 |
|
BLAKE2b-256 | 169a672570537b54eae5336b13123b569562388702dd73c42c4abae60f377ba5 |
File details
Details for the file pyqlib-0.5.0.dev7-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 574.9 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7823401d435c9ea6b853ec06160910cf3756c08c6167f0980f1b90c6d2873540 |
|
MD5 | 74ff9e03c1136b078dd09ce696ebffc7 |
|
BLAKE2b-256 | 9ef9fd984165a10b36f5670cb8f269235e54adce27e04a011c96a18967fd20e1 |
File details
Details for the file pyqlib-0.5.0.dev7-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 215.1 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 601bdaacffae86b2f74d6a45de3a3cee42fbea144f7b8e61b52bc32b577caeaa |
|
MD5 | d227f0d5cafe2e1d791ae0b7338e72e3 |
|
BLAKE2b-256 | 529841b64b434ee911c5cc00541474d34b4edd416c5eb085cf00ba38998dc023 |
File details
Details for the file pyqlib-0.5.0.dev7-cp36-cp36m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp36-cp36m-manylinux2010_x86_64.whl
- Upload date:
- Size: 572.4 kB
- Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c3af748eaf8a93a25db821c76c9c6ceb7e5506228c769967db14c04257ec4bb |
|
MD5 | 2f3affa93d5acaad158a3809cf6e8bbe |
|
BLAKE2b-256 | 975209add11f3f951cff21d885b455905846f896571a98d6f2b7f968bce114bf |
File details
Details for the file pyqlib-0.5.0.dev7-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyqlib-0.5.0.dev7-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 572.4 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d4b622a239562272b7c18331c79f393ef0b11c3d431a8a9440ecea1d8e61cfd |
|
MD5 | c55d36bf61a12317996a928dbe81e3d7 |
|
BLAKE2b-256 | 527a11e7c763ac2bf1c520722a658a3a5e2eda965cd3aa4c8a3321bc06fe8558 |