Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Shiyu coder Kronos Qlib Backtesting

From Leeroopedia


Field Value
principle_name Qlib_Backtesting
repository https://github.com/shiyu-coder/Kronos
domains Backtesting, Portfolio_Management, Financial_Evaluation
implemented_by Implementation:Shiyu_coder_Kronos_QlibBacktest_Usage
last_updated 2026-02-09 14:00 GMT

Summary

Evaluating model predictions by running simulated portfolio trading using Qlib's backtesting framework with configurable trading strategies.

Concept

The Qlib Backtesting principle describes how model-generated prediction signals are evaluated through realistic simulated trading. Rather than measuring model accuracy solely through statistical metrics (MSE, correlation), this approach tests whether the predictions lead to profitable trading when combined with a portfolio management strategy.

The backtesting pipeline bridges the gap between model quality and practical trading performance, accounting for real-world constraints such as transaction costs, position limits, and execution delays.

Theory

Backtest Loop

The evaluation follows a standard quantitative finance backtesting pipeline:

  1. Prediction signals: Model outputs are converted to per-symbol, per-day score values that indicate expected returns
  2. Portfolio strategy: Signals are consumed by a TopkDropoutStrategy that selects which symbols to hold:
    • Holds the top-K symbols by predicted score
    • Drops the bottom-N symbols from the current portfolio each period
    • Enforces a minimum holding period to reduce turnover
  3. Simulated execution: Orders generated by the strategy are executed through Qlib's SimulatorExecutor with realistic constraints:
    • Day-frequency execution
    • Delayed execution (trade on next bar)
    • Price limit thresholds (9.5% for Chinese A-shares)
    • Transaction costs: 0.1% open cost, 0.15% close cost, minimum 5 units
  4. Performance metrics: Results are analyzed using Qlib's risk_analysis:
    • Excess return without cost (raw alpha)
    • Excess return with cost (net alpha after transaction costs)
    • Cumulative return curves for visualization

Benchmark Comparison

All returns are measured relative to a benchmark index:

  • CSI 300 (SH000300) for the csi300 universe
  • CSI 800 (SH000906) for the csi800 universe
  • CSI 1000 (SH000852) for the csi1000 universe

The excess return (alpha) isolates the model's predictive contribution from general market movements.

Multiple Signal Evaluation

The framework supports evaluating multiple signal types simultaneously (e.g., mean prediction, last-day prediction, max prediction). Each signal is backtested independently and results are plotted on the same chart for comparison.

Key Configuration Parameters

  • backtest_n_symbol_hold: Number of symbols in the portfolio (default: 50)
  • backtest_n_symbol_drop: Number of symbols to drop per rebalance (default: 5)
  • backtest_hold_thresh: Minimum holding period in days (default: 5)
  • backtest_time_range: Start and end dates for the simulation
  • account: Initial portfolio value (100,000,000 units)

Domains

  • Backtesting: Simulated historical trading evaluation
  • Portfolio_Management: Top-K dropout portfolio construction strategy
  • Financial_Evaluation: Risk analysis and performance attribution

External References

See Also

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment