Microsoft’s open source AI quantitative trading platform Qlib

Microsoft’s open source AI quantitative trading platform Qlib

2022-09-16 0 1,002
Resource Number 38555 Last Updated 2025-02-24
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends Qlib, an open-source AI quantitative trading platform from Microsoft, which contains modules such as data processing, model training, and backtesting, covering functions such as Alpha mining, risk modeling, and combinatorial optimization.

Microsoft’s open source AI quantitative trading platform Qlib插图

Project Description

Qlib is an AI-oriented quantitative investment platform that aims to tap the potential, empower research, and create the value of AI technology in quantitative investment.

It contains a complete ML pipeline for data processing, model training, and backtest; It covers the entire chain of quantitative investing: alpha seeking, risk modeling, portfolio optimization, and order execution.

Using Qlib, users can easily try out ideas for creating better quantitative investment strategies.

Qlib framework

Microsoft’s open source AI quantitative trading platform Qlib插图1

At the module level, Qlib is a platform made up of the above components. The components are designed as loosely coupled modules, and each component can be used independently.

Name

Description

Infrastructure layer

The Infrastructure layer provides the underlying support for Quant research. DataServer provides a high-performance infrastructure for users to manage and retrieve raw data. The Trainer provides a flexible interface to control the training process of the model, so that the algorithm can control the training process.

Workflow layer

The Workflow layer covers the entire workflow of the quantitative investment. Information Extractor extracts data for the model. The Forecast Model focuses on generating various prediction signals for other modules (e.g. alpha, risk). With these signal Decision generators, the target trading decision (i.e., portfolio, order) to execute is generated and the Execution Env (i.e., trading market) is generated. There may be multiple levels of Trading agents and Execution Env (for example, order executor Trading Agent and intraday order execution environment may behave like a day trading environment and be nested within daily portfolio management trading agent and day trading environment )

Interface layer

Interfacelayer attempts to provide a user-friendly interface to the underlying system. The Analyser module will provide the user with a detailed analysis report on the predicted signals, portfolio and execution results

Fast start

  • It’s very easy to build a complete Quant research workflow using Qlib and try out your ideas.
  • Despite the use of public data and simple models , machine learning techniques work well in actual quantitative investing.

Installation

Note:

  • It is recommended to use Conda to manage your Python environment.
  • Note that installing cython in Python 3.6 raises some errors when Qlib is installed from source. If a user is using Python 3.6 on their own machine, it is recommended to upgrade Python to version 3.7 or install it from source using conda’s Python.
  • Qlib requires the tables package, and python3.9 is not supported in the hdf5 table.

Users can easily install it via pip according to the following command.

  pip install pyqlib

In addition, users can install the latest development version from source code by following these steps:

Before installing from the source, the user needs to install some dependencies:

pip install numpy
pip install --upgrade  cython

Clone the repository and install

as follows

git clone  https://github.com/microsoft/qlib.git & &  cd qli
pip install 

Note : You can also install Qlib python setup.py install. But this is not the recommended approach. It skips pip and leads to arcane problems. For example, only the command pip install. Can overwrite the stable version pip install pyqlib that is installed, while the command python setup.py install cannot.

< 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

Automatic quantization research workflow

Qlib provides a tool called qrun that automates the entire workflow (including building datasets, training models, backtesting, and evaluation).

Quantitative research workflow: qrun run using lightgbm workflow configuration

  cd examples  # Avoid running program under the directory contains `qlib`
qrun benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml

If the user wants qrun to be used in debug mode, use the following command:

python -m pdb qlib/workflow/cli.py  examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml

The results are as follows


'The following are analysis results of the excess return  without cost.'
                       risk
mean               0.000708
std                0.005626
annualized_return  0.178316
information_ratio  1.996555
max_drawdown      -0.081806
'The following are analysis results of the excess return with cost.'
                       risk
mean               0.000512
std                0.005626
annualized_return  0.128982
information_ratio  1.444287
max_drawdown      -0.091078

Graphic Report analysis

Prediction signal (model prediction) Analysis:

Microsoft’s open source AI quantitative trading platform Qlib插图2

Group aggregate return

Microsoft’s open source AI quantitative trading platform Qlib插图3

Return assignment

Microsoft’s open source AI quantitative trading platform Qlib插图4

Information coefficient (IC)

Portfolio analysis:

Microsoft’s open source AI quantitative trading platform Qlib插图5

Qlib data server performance

The performance of data processing is important for data-driven approaches such as artificial intelligence technologies. Qlib, as an AI-oriented platform, provides solutions for data storage and data processing. To demonstrate the performance of the Qlib data server, we compared it to several other data storage solutions.

Microsoft’s open source AI quantitative trading platform Qlib插图6

  • +(-)E ExpressionCache
  • +(-)D indicates DatasetCache
资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code Microsoft’s open source AI quantitative trading platform Qlib https://ictcoder.com/microsofts-open-source-ai-quantitative-trading-platform-qlib/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services