Skip to content
All library documents

Portfolio Optimization for Return and Benchmark Tracking Error

Article Qlib

Summary

This document presents an optimization-based alternative to a simple top-ranked stock strategy. It describes using Qlib’s EnhancedIndexingStrategy to seek a balance between portfolio return and tracking error against a benchmark, with correlation and volatility identified as portfolio risks that a basic ranking rule does not control. The example uses Chinese equities and the CSI 300 as its benchmark, alongside return forecasts from alpha models.

The workflow requires benchmark constituent weights and risk-model data, then runs a configured strategy. The example uses a statistical risk model, while recommending that users consider other models for improved risk estimates. Benchmark weights are described as manually prepared because the authors could not find a free public source. The document outlines a workflow, not empirical results: it gives no optimization settings, performance comparison, transaction-cost analysis, or evidence that the strategy improves realized returns. Its outcome depends on forecast quality, benchmark data, and the chosen risk model.

Key ideas

  • A simple top-ranked stock strategy may not manage portfolio correlation and volatility.
  • EnhancedIndexingStrategy is presented as a way to balance predicted return against tracking error to a benchmark.
  • The example uses Chinese stock data and CSI 300 constituent weights.
  • The workflow depends on risk-model inputs, and the example uses a statistical risk model.
  • The document gives no performance comparison or transaction-cost analysis.

Tags

Full text
# Portfolio Optimization Strategy


# 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:

   ```bash
   wget https://github.com/SunsetWolf/qlib_dataset/releases/download/v0/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:

   ```bash
   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:
* **Fundamental Risk Model** like MSCI BARRA
* [Deep Risk Model](https://arxiv.org/abs/2107.05201)


## 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`.

Shown in full with attribution under the source's licence. Licence: MIT

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.