Skip to content
All library documents

Nested Backtests with Portfolio Decisions and Order Execution at Different Frequencies

Article Qlib

Summary

This example explains nested decision execution in Qlib backtesting: one strategy forms a portfolio at a slower frequency while another handles orders at a faster frequency. The first workflow generates portfolios weekly with DropoutTopkStrategy, described as using a daily-frequency LightGBM model, and executes orders daily with SBBStrategyEMA, a rule-based strategy using exponential moving averages.

A second workflow applies the same division across daily portfolio generation and minute-level order execution. The document gives runnable workflow entry points for backtesting and data collection, including a separate high-frequency backtest command. It demonstrates how strategy decisions and execution timing can be separated in a backtest, but reports no performance results, data details, or evaluation of the strategies. The examples therefore illustrate workflow structure rather than establishing that either strategy is profitable or that the simulated execution reflects live trading.

Key ideas

  • Nested execution lets a backtest use different strategies at portfolio and order levels.
  • The weekly example forms portfolios weekly and executes orders daily.
  • The higher-frequency example forms portfolios daily and executes orders minutely.
  • The portfolio strategy uses a LightGBM-based approach, while the execution strategy uses EMA rules.
  • The examples describe workflow commands but provide no performance evidence.

Tags

Full text
# Nested Decision Execution


# Nested Decision Execution

This workflow is an example for nested decision execution in backtesting. Qlib supports nested decision execution in backtesting. It means that users can use different strategies to make trade decision in different frequencies.

## Weekly Portfolio Generation and Daily Order Execution

This workflow provides an example that uses a DropoutTopkStrategy (a strategy based on the daily frequency Lightgbm model) in weekly frequency for portfolio generation and uses SBBStrategyEMA (a rule-based strategy that uses EMA for decision-making) to execute orders in daily frequency. 

### Usage

Start backtesting by running the following command:
```bash
    python workflow.py backtest
```

Start collecting data by running the following command:
```bash
    python workflow.py collect_data
```

## Daily Portfolio Generation and Minutely Order Execution

This workflow also provides a high-frequency example that uses a DropoutTopkStrategy for portfolio generation in daily frequency and uses SBBStrategyEMA to execute orders in minutely frequency. 

### Usage

Start backtesting by running the following command:
```bash
    python workflow.py backtest_highfreq
```

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.