Hi everyone,

I'm excited to share a strategy that replicates and validates a Qlib-based cross-sectional stock selection model using the QuantConnect platform for independent backtesting.

Strategy Overview

This strategy originates from Microsoft’s Qlib, an open-source framework for high-frequency and daily alpha research. Qlib provides a complete data-handling and model training pipeline and is widely used for cross-sectional ranking-based prediction — commonly known as "alpha modeling".

Core Logic – Qlib Cross-Sectional Stock Ranking

The upstream model performs the following steps:

  1. Universe: S&P500 constituents
  2. Feature Engineering: Alpha158.
  3. Model Training: LightGBM trained to rank stocks daily by expected return
  4. Signal Output: Each day, the top-k stocks (e.g., 5-50) are selected 
  5. Rebalancing Rule: Drop ndrop names (e.g., 1-5) and replace with new names based on updated rankings.

 

The Qlib backtest simulates trading at daily close (T), building the target portfolio from top-ranked stocks with initially equal weights. The portfolio is held until the next day’s close (T+1), when a new list is generated and a new rebalance is made.

This QuantConnect Strategy – External Signal Follower

To verify the Qlib strategy externally, I exported the daily stock lists (tickers and weights) into a simple Python dictionary file (signaltable_sp500.py).

This QuantConnect strategy:

  1. Reads the daily stock list
  2. Executes one rebalance per day, 1 minutes after market close
  3. Initial Build: Equal-weight buy of the 5 tickers on first valid signal day
  4. Daily Rebalance:
  • Sell one name from yesterday’s portfolio (not in today’s list)
  • Buy one new name from today’s list (not in yesterday’s portfolio)

 

This mimics Qlib’s close-to-close holding period and provides a second-platform verification of signal consistency.

Backtest Summary 

  • Backtest Period: 2024-01-01 to 2026-01-09
  • Capital: $ 20,000
  • Portfolio: 5 stocks each day
  • Turnover: very low (only 1 in/out per day)
  • Execution: End of day (delayed 1 mins after close)
  • Signal Source: Qlib, imported via signaltable_sp500_symbol.py

(Backtest charts and statistics below)

Why Use QuantConnect Here?

While Qlib is great for model training, but QuantConnect offers:

  • Independent execution environment
  • Slippage/fee modeling
  • Visual performance dashboards
  • Live trading integration

 

By importing the signal file into QuantConnect, I was able to double-check portfolio behavior and ensure robustness across platforms — a crucial step before real deployment.

 

Live Trading Ready

This strategy is now also running live via Collective2. Check it out here: SP500RelativeStrength.

Let’s Collaborate

If you’re working on:

  • Cross-platform signal execution (Qlib & QuantConnect)
  • Alpha research using LightGBM or deep learning
  • Cross-sectional models
  • End-of-day or close-to-close strategies
  • Deploying to Collective2, IBKR, or other live platforms

 

I'd love to connect, exchange ideas, or optimize together!