Skip to main content

A Quantitative-research Platform

Project description

Python Versions Platform PypI Versions Documentation Status 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.

      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.0.dev8-cp38-cp38-win_amd64.whl (216.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyqlib-0.5.0.dev8-cp38-cp38-manylinux2010_x86_64.whl (612.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pyqlib-0.5.0.dev8-cp38-cp38-manylinux1_x86_64.whl (612.2 kB view details)

Uploaded CPython 3.8

pyqlib-0.5.0.dev8-cp38-cp38-macosx_10_14_x86_64.whl (209.6 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pyqlib-0.5.0.dev8-cp37-cp37m-win_amd64.whl (215.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyqlib-0.5.0.dev8-cp37-cp37m-manylinux2010_x86_64.whl (575.0 kB view details)

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

pyqlib-0.5.0.dev8-cp37-cp37m-manylinux1_x86_64.whl (575.0 kB view details)

Uploaded CPython 3.7m

pyqlib-0.5.0.dev8-cp37-cp37m-macosx_10_14_x86_64.whl (208.8 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pyqlib-0.5.0.dev8-cp36-cp36m-win_amd64.whl (215.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

pyqlib-0.5.0.dev8-cp36-cp36m-manylinux2010_x86_64.whl (572.5 kB view details)

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

pyqlib-0.5.0.dev8-cp36-cp36m-manylinux1_x86_64.whl (572.5 kB view details)

Uploaded CPython 3.6m

pyqlib-0.5.0.dev8-cp36-cp36m-macosx_10_14_x86_64.whl (210.2 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file pyqlib-0.5.0.dev8-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 216.8 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.0.dev8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ac6b6fea154fa831c1255c1225bf7b1ba2813700d1057b8808a31a0e3caefbb3
MD5 d8780d321ec0378fa7364587adca0454
BLAKE2b-256 d1ea88078610efdd9c5f6d4af54536fa9a30bb84792df309ae9abd2b4a2911a3

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 612.2 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.0.dev8-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f05f022461fc6dba40e04e85c113187d837d26b0aa64ab7b7321c161bb711e9f
MD5 3ff3a06e3fc12217f6ef8f3781c13021
BLAKE2b-256 dc07eea641f12905671b352fd635355c9359ba7c2fd6051ad1f727da8e3f8a10

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 612.2 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.0.dev8-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8a388a42cf9f1ca057406f6cc36572f85f0e0c598a0daf183fd38c2f720a148e
MD5 86caa1ab0f1cc8e3e05fe471e307c4b5
BLAKE2b-256 27cd16bb8c7c7971de203d315f73a7223a4281817bd0a8b6f29494c9d6777db4

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 209.6 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.0.dev8-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9041eec8542181388937769ca713277121442a270a686cf2c2bb2c83c2ec94ab
MD5 495b8329d1c254d5b32b1ebf96bda1be
BLAKE2b-256 824760fc71a69fcc8252fe79e620d407758258276c227fd3b429449785829cc6

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 215.0 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.0.dev8-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b9024eb8c330ea2edb188ee05ae4fb327687a386301544e67d1b36db3b173e4e
MD5 19349b1a1ca661c88aa3d8293517f7af
BLAKE2b-256 4e5ec05c87f9e3ae3a510c80eb357f0cc05d0f37c6260fabb11c8cb593051c80

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 575.0 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.0.dev8-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 02bc7ea698fbb1c54dbe3eaf88cd18daf404c7328087360029d9696a789a9370
MD5 fe856cd316a9de7f2d3a726e082f47f8
BLAKE2b-256 50610638aadeee76fba9706e08c0526dd5f3c24d41b19ce758e2222fcfe3c171

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 575.0 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.0.dev8-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 60726c327fd38f3842c058edd73ff1f3aa94c4c6dd1cfa8fb67414142d721070
MD5 5dcb9c369de50e28751aa1c1e7c82104
BLAKE2b-256 ac1a3cd398be75d1ac0ae4eccf8c67bd079c2b43be614a2e983e8d148da0126a

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 208.8 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.0.dev8-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 69fc4439b27241c8bf45f7b42e9a6debd5c943d8c544c79b9c74860dab3b764a
MD5 bf493f71def977ff2d5473870c93bad3
BLAKE2b-256 8c2365d4dadbabc864601b0802feb4375541747ce067e4d36106b2258a5b39bf

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 215.2 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.0.dev8-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 13337bb39b5002ce90a7b150c55ef18757c002925ab8198e63f594d59d689241
MD5 bb9638bc57778d4c5e3be0e58e7f9718
BLAKE2b-256 d1222d1d8f126bb5721db133015ce54bd9f9246ebaccffd2925bc884b5d4cfab

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 572.5 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.0.dev8-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8effeb876b0de4ae292162b7a16a58a39171cb872bd900700048d6e34964208c
MD5 314ea3ce74d6c52b568f7a869ded8877
BLAKE2b-256 c620f60d28bf5c4f1ae6a2e2f734adff4b51f81e8eee7e7b9ad2162a850321bd

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 572.5 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.0.dev8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 631441c81f4e0802e98cd92fc80d0e6f6f26267d32f86b6dce741c785180d564
MD5 490e358a9b4975fec365ea36602feaa1
BLAKE2b-256 5ae77dad47bfb95fc63a8381f1faf3628bbca46cda0e1c5de7f8d61d2f033ff7

See more details on using hashes here.

File details

Details for the file pyqlib-0.5.0.dev8-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyqlib-0.5.0.dev8-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 210.2 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.0.dev8-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 da1be66d23ed31e4e2386d6d8abe33d9a7c2a20569ef579fcea0e353b8e3b874
MD5 fcf1df37312fe722c12599e5cac89efe
BLAKE2b-256 6442e50a0d8e70baf9f7b07fe86dc15ef4c0d1dd119bc316eabec322a5be3dcd

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