1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 05:51:17 +08:00
Files
qlib/examples/portfolio
you-n-g be4646b4b7 Adjust rolling api (#1594)
* Intermediate version

* Fix yaml template & Successfully run rolling

* Be compatible with benchmark

* Get same results with previous linear model

* Black formatting

* Update black

* Update the placeholder mechanism

* Update CI

* Update CI

* Upgrade Black

* Fix CI and simplify code

* Fix CI

* Move the data processing caching mechanism into utils.

* Adjusting DDG-DA

* Organize import
2023-07-14 12:16:12 +08:00
..
2023-07-14 12:16:12 +08:00
2022-02-07 16:04:11 +08:00

Portfolio Optimization Strategy

Introduction

In qlib/examples/benchmarks we have various alpha models that predict the stock returns. We also use a simple rule based TopkDropoutStrategy to evaluate the investing performance of these models. However, such a strategy is too simple to control the portfolio risk like correlation and volatility.

To this end, an optimization based strategy should be used to for the trade-off between return and risk. In this doc, we will show how to use EnhancedIndexingStrategy to maximize portfolio return while minimizing tracking error relative to a benchmark.

Preparation

We use China stock market data for our example.

  1. Prepare CSI300 weight:

    wget http://fintech.msra.cn/stock_data/downloads/csi300_weight.zip
    unzip -d ~/.qlib/qlib_data/cn_data csi300_weight.zip
    rm -f csi300_weight.zip
    

    NOTE: We don't find any public free resource to get the weight in the benchmark. To run the example, we manually create this weight data.

  2. Prepare risk model data:

    python prepare_riskdata.py
    

Here we use a Statistical Risk Model implemented in qlib.model.riskmodel. However users are strongly recommended to use other risk models for better quality:

End-to-End Workflow

You can finish workflow with EnhancedIndexingStrategy by running qrun config_enhanced_indexing.yaml.

In this config, we mainly changed the strategy section compared to qlib/examples/benchmarks/workflow_config_lightgbm_Alpha158.yaml.