Skip to main content

A Quantitative-research Platform

Project description

Python Versions Platform PypI Versions Documentation Status Upload Python Package License Join the chat at https://gitter.im/Microsoft/qlib

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

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

  1. It's very easy to build a complete Quant research workflow and try your ideas with Qlib.
  2. Though with public data and simple models, machine learning technologies work very well in practical Quant investment.

Installation

Users can easily install Qlib by pip according to the following command

  pip install pyqlib

Also, Users can install 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:

    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:

  1. Quant Research Workflow: Run Estimator with estimator_config.yaml as following. (Please note that this may not work under MacOS with Python 3.8 due to the incompatibility of the sacred package we use with Python 3.8. We will fix this bug in the future.)

      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.

  2. Graphical Reports Analysis: Run examples/estimator/analyze_from_estimator.ipynb with jupyter notebook to get graphical reports

    • Forecasting signal (model prediction) analysis

      • Cumulative Return of groups Cumulative Return
      • Return distribution long_short
      • Information Coefficient (IC) Information Coefficient
        Monthly IC IC
      • Auto Correlation of forecasting signal (model prediction) Auto Correlation
    • Portfolio analysis

      • Backtest return Report

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyqlib-0.5.1-cp38-cp38-win_amd64.whl (217.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyqlib-0.5.1-cp38-cp38-manylinux2010_x86_64.whl (613.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pyqlib-0.5.1-cp38-cp38-manylinux1_x86_64.whl (613.0 kB view details)

Uploaded CPython 3.8

pyqlib-0.5.1-cp38-cp38-macosx_10_14_x86_64.whl (210.4 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pyqlib-0.5.1-cp37-cp37m-win_amd64.whl (215.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyqlib-0.5.1-cp37-cp37m-manylinux2010_x86_64.whl (575.8 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pyqlib-0.5.1-cp37-cp37m-manylinux1_x86_64.whl (575.8 kB view details)

Uploaded CPython 3.7m

pyqlib-0.5.1-cp37-cp37m-macosx_10_14_x86_64.whl (209.6 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pyqlib-0.5.1-cp36-cp36m-win_amd64.whl (216.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

pyqlib-0.5.1-cp36-cp36m-manylinux2010_x86_64.whl (573.3 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pyqlib-0.5.1-cp36-cp36m-manylinux1_x86_64.whl (573.3 kB view details)

Uploaded CPython 3.6m

pyqlib-0.5.1-cp36-cp36m-macosx_10_14_x86_64.whl (211.0 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file pyqlib-0.5.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 217.6 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

Hashes for pyqlib-0.5.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2aef6487f7323b6a3ed5e02172401e83fcb0cb411e095dbccbbd0865bb4f6a24
MD5 6164740480763e4c5ca83dc7715268de
BLAKE2b-256 46771a4dd9f97356c31e5cf10ad290bb2e38c6ded70f48ae2a206b28ea811c0e

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 613.0 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

Hashes for pyqlib-0.5.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 93c945ce9518a87e261a6912f48b73f5bf6a192754dd42e75060f9e6f2d9bce8
MD5 02425f2f42f66aceb5ca9ad31ebb9f96
BLAKE2b-256 9e4a8b96ba00b4bc01b799c34090a1e5f182502b884f117ba31d985e06bcefcf

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 613.0 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

Hashes for pyqlib-0.5.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a962df7f6226b06a61657b94eb954ecb7604c444f37d0ca81c801df6dc7fd03d
MD5 63b60b42b20a075f7ff01a2a28fa2b05
BLAKE2b-256 5fa4c393e83d4749f2df7a1b98c828d4b81a91e74f103a4fe1d887593c97348f

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 210.4 kB
  • Tags: CPython 3.8, macOS 10.14+ 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

Hashes for pyqlib-0.5.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f8a43392a3a0d3bd1f8ca3afafd110adc60bf9764986044d148cfc9d69919be0
MD5 c24ee71243c58ec8719f470766bcaa77
BLAKE2b-256 e5b7b586d382ed4d528ff1fd9610e5435361f05fe76ec07dfaca594dd36d017d

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 215.8 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

Hashes for pyqlib-0.5.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d3e2bf9e0ae1b6e97e3421fb8ac372688df353cbf9df352f0e98dfe92398aa44
MD5 5a7cc517d68119d7ccc3f7153f79cc20
BLAKE2b-256 19c8c6f8ae298b061138c4f992aa361d64af87df6d154cd57744bb005328bd66

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 575.8 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

Hashes for pyqlib-0.5.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 eb8367394ae8d284bf139b49f1b3a31ae037a4694bd50f065ef8b16a8bc220ae
MD5 26c454a1f61786a6d037984ea51663f3
BLAKE2b-256 1e79be694279bc2610f9d4fb70591f1a6b01254cca0b8b46add06c20796ebb2a

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 575.8 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

Hashes for pyqlib-0.5.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d2de4b92e991fb54d0a227d64e359d0f4c54795eecdd6fa5a2cea1b77a46f069
MD5 3fefcd1a608af59e7ada525cac7d3821
BLAKE2b-256 2d62f4e08e0bf4d48805845e744f27ff5e58e892c7d9f8b93b17fd8cafa518ad

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 209.6 kB
  • Tags: CPython 3.7m, macOS 10.14+ 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

Hashes for pyqlib-0.5.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 067b4b89f081d75c634a34a70609725391f99c287a7135980aa49c443a67c902
MD5 abbeac30640c157dbdf422f97217714d
BLAKE2b-256 d96a43f65a56c71db5b03806be8bbe5ac442a8a40b478e02b820fe5ecee37a5a

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 216.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

Hashes for pyqlib-0.5.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d7141e8f3c4f8a7816ebe942d232f6126547861a9693a320c50ce05e725d3294
MD5 51d6dfa7efb792181918b0d25af26a9f
BLAKE2b-256 df53433acc651660b92861a14f3dea77904f7b5e4e9a7669d6b6e2a277a8bb1b

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 573.3 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

Hashes for pyqlib-0.5.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d058a3412669765b0c2a868e44d58b09128e4816719d67306463c84e6a4367ad
MD5 9caff3436b776c27c50e65b25658095e
BLAKE2b-256 243b1687cb31a32a723466401e859152bbcba8bdf03849edba773ec7356e5f99

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 573.3 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

Hashes for pyqlib-0.5.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fad958f08c6a49cc61480a7261bfa219296abba549b467652e6c8db48c337d3a
MD5 564c425566a7e3a73bac5cc6d18f1da6
BLAKE2b-256 8f7a95df0d71f4abaf36424ac824e961a41fd2e7f40b7b6ba98aeb1d07541174

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 211.0 kB
  • Tags: CPython 3.6m, macOS 10.14+ 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.12

File hashes

Hashes for pyqlib-0.5.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 913929f738f0fd29619083347dac68429041157ac0aa7bcc8e1367fb983efb6b
MD5 a9ed2e375f5dd1c52ff88540494ff9e1
BLAKE2b-256 eaddfd7d9832c7a63f873b146b3a77088a948e61720fa1c21aacf8b13558da4a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page