8000 GitHub - kiminh/qlib at main · GitHub
[go: up one dir, main page]

Skip to content
kiminhPublic
forked from microsoft/qlib

About

No description, website, or topics provided.

Resources

Readme< 10000 /div>

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Qlib is a an AI-oriented quantitative investment platform. aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment.

With you Qlib, you can easily apply your favorite model to create better Quant investment strategy.

Framework of Qlib

framework

At module level, Qlib is a platform that consists of the above components. Each components is loose-coupling and can be used stand-alone.

Name Description
Data layer DataServer focus on providing high performance infrastructure for user to retreive and get raw data. DataEnhancement will preprocess the data and provide the best dataset to be fed in to the models
Interday Model Interday model focus on produce forecasting signals(aka. alpha). Models are trained by Model Creator and managed by Model Manager. User could choose one or multiple models for forecasting. Multiple models could be combined with Ensemble module
Interday Strategy Portfolio Generator will take forecasting signals as input and output the orders based on current position to achieve target portfolio
Intraday Trading Order Executor is responsible for executing orders output by Interday Strategy and returning the executed results.
Analysis User could get detailed analysis report of forecasting signal and portfolio in this part.
  • The modules with hand-drawn style is under development and will be released in the future.
  • The modules with dashed border is highly user-customizable and extendible.

Quick start

Installation

To install Qlib from source you need Cython in addition to the normal dependencies above:

pip install cython

Clone the repository and then run:

python setup.py install

Get Data

  • Load and prepare the Data: execute the following command to load the stock data:
    python scripts/get_data.py qlib_data_cn --target_dir ~/.qlib/qlib_data/cn_data

Auto Quant research workflow with estimator

Qlib provides a tool named estimator to run whole workflow automatically(including building dataset, train models, backtest, analysis)

  1. Run estimator (config.yaml for: estimator_config.yaml):

    estimator -c example/estimator/estimator_config.yaml

    Estimator result:

    pred_long       mean    0.001386
                    std     0.004403
                    annual  0.349379
                    sharpe  4.998428
                    mdd    -0.049486
    pred_short      mean    0.002703
                    std     0.004680
                    annual  0.681071
                    sharpe  9.166842
                    mdd    -0.053523
    pred_long_short mean    0.004089
                    std     0.007028
                    annual  1.030451
                    sharpe  9.236475
                    mdd    -0.045817
    sub_bench       mean    0.000953
                    std     0.004688
                    annual  0.240123
                    sharpe  3.226878
                    mdd    -0.064588
    sub_cost        mean    0.000718
                    std     0.004694
                    annual  0.181003
                    sharpe  2.428964
                    mdd    -0.072977

    See the full documnents for Use Estimator to Start An Experiment.

  2. Analysis

    Run examples/estimator/analyze_from_estimator.ipynb in jupyter notebook

    1. forecasting signal analysis

      • Model Performance Model Performance
    2. portfolio analysis

      • Report Report

Customized Quant research workflow by code

Automatical workflow may not suite the research workflow of all Quant researchers. To support flexible Quant research workflow, Qlib also provide modulized interface to allow researchers to build their own workflow. Here is a demo for customized Quant research workflow by code

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.

Offline mode and online mode

The data server of Qlib can both deployed as offline mode and 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 clients. The data retrieving performance is expected to be improved due to higher rate of cache hits. It will use 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

Performance of Qlib Data Server

The performance of data processing is important to datadriven 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, We compare Qlib with several other solutions.

The task for the solutions is to create a dataset from the basic OHLCV daily data of a stock market, which involves data query and processing.

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 solution. 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 rights 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.

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0