JoinQuant research backtest, benchmark 399101.XSHE, initial capital ¥100,000, 2024-11-15 → 2025-11-15.
v2: Sharpe 2.499, return 70.90%, annualized 73.56%, excess 37.00% against a benchmark return of 24.74%, alpha 0.521, beta 0.810, max drawdown 20.11%.
v1 on the same window: Sharpe 2.033, return 58.49%, annualized 60.69%, excess 27.05%, max drawdown 23.49%.
v1 to v2 on one research window: Sharpe 2.033 to 2.499, return 58.49% to 70.90%, excess 27.05% to 37.00%, max drawdown 23.49% to 20.11%. Five-model rolling ensemble (LightGBM, XGBoost, SVR, Random Forest, Linear), about 79 factors, regime windows of 24 / 36 / 48 months, retrain every ~60 trading days (≈ quarterly), rebalance every 10 trading days, top 5 names.
The strategy runs on JoinQuant (jqdata, jqfactor). Screenshots: v2.0.png, v1.0.png. CI compiles main.py and scripts/ with python -m py_compile and stays off JoinQuant credentials.
The strategy runs on JoinQuant (jqdata, jqfactor). A local research runtime pairs a data provider with the same rebalance clock.
This project implements a multi-model, dynamically weighted ensemble stock-picking system on JoinQuant.
Train 5 machine-learning models on a rolling window:
- LightGBM
- XGBoost
- SVR
- Random Forest
- Linear Regression
Train 5 machine-learning models on a rolling window, then compute a combined loss (future-return MSE + 3-class accuracy term) for each model and use it for dynamic ensemble weighting:
- Lower combined loss → higher weight
- Persistently poor models → penalized
Rebalance every 10 trading days, holding top 5 high-scoring stocks, with risk filters on ST names, new listings, and boards.
This is a framework-oriented strategy emphasizing:
- Rolling training pipeline design
- Multi-model dynamic weighting
- JoinQuant periodic rebalancing workflow
The strategy runs on JoinQuant (jqdata, jqfactor):
from jqdata import *
from jqfactor import get_factor_valuesAccess to:
- Price data
- Factor data
- Index constituents
- Trading calendar
- Strategy lifecycle APIs (
initialize,run_daily,order_target_value, etc.)
A local research runtime pairs a data provider and a backtest loop with these APIs.
- Set benchmark: 399101.XSHE (SZSE SME Composite)
- Configure slippage & transaction cost
- Instantiate
MonthlyRolling5ModelStrategy - Load or train model
Register callbacks:
| Time | Task | Function |
|---|---|---|
| 09:00 | Retrain check (~60 trading days) | check_monthly_retraining |
| 09:05 | Select universe | prepare_stock_list |
| 09:30 | Trading/rebalancing | trading_logic |
- Uses a dynamic training window (24 / 36 / 48 months) based on recent HS300 volatility; 36 months is the default regime.
- Compute combined loss (future-return MSE + 3-class accuracy term)
- Update rolling combined-loss window
- Apply penalty for weak models
- Save model files
- Filter universe
- Fetch factor values
- Score via weighted ensemble on rebalancing days, every 10 trading days
- Sell dropped names
- Buy/hold top N stocks
- Basic risk filters
- Retrain every ~60 trading days (≈ quarterly) (configurable)
- Window: Uses a dynamic training window (24 / 36 / 48 months) based on recent HS300 volatility; 36 months is the default regime.
- Universe filters:
- Remove ST stocks
- Remove ChiNext/STAR/BSE boards
- Remove newly listed stocks (< 90 days) in the training universe
Categories:
- Fundamental
- Valuation
- Technical
- Risk
- Regression: future return
- Binary: above/below cross-section median
- 3-class: return quantiles (25% / 75%)
- Median fill
- Replace inf
- Outlier clipping
- RobustScaler normalization
- Correlation graph (|corr| > 0.6)
- Keep 1 factor per correlated cluster
Models trained on identical features:
| Model | Advantage |
|---|---|
| LightGBM | Non-linear boosting |
| XGBoost | Stable boosting variant |
| SVR | High-dimensional boundaries |
| Random Forest | Robust ensembles |
| Linear Regression | Stabilizes ensemble |
Each model is evaluated using a combined loss (regression MSE on future return + 3-class accuracy), and the dynamic weights are computed from this rolling loss.
- Keep last 3 rounds
- Use average as rolling combined loss
If recent rolling combined loss > 1.5 × mean → penalty = 0.5
weight_i ∝ (1 / rolling combined loss_i) × penalty_i
Lower combined loss → larger weight
Weak models → explicit penalty
- Index constituents (399101.XSHE)
Remove:
- ChiNext / STAR / BSE
- ST stocks
- Suspended stocks
The training universe applies the newly listed filter. Live stock selection on each rebalance applies the ST, suspension, and ChiNext / STAR / BSE board filters.
- Fetch using
get_factor_values - Run ensemble to generate score
- Higher score → better expected return
- Sort by score
- Select Top 5 stocks
- If model untrained → fallback baseline selection
- First day → always
- Then every 10 trading days
- Names outside the target list are sold
- Equal-weight among target holdings
- Check liquidity/risk
- Fixed number of holdings
- Low turnover
- Benchmark tracking
Rebalancing stays on a fixed 10-trading-day clock, so the research backtest measures the ensemble score.
v1 to v2 on one research window: Sharpe 2.033 to 2.499, return 58.49% to 70.90%, excess 27.05% to 37.00%, max drawdown 23.49% to 20.11%. Five-model rolling ensemble (LightGBM, XGBoost, SVR, Random Forest, Linear), about 79 factors, regime windows of 24 / 36 / 48 months, retrain every ~60 trading days (≈ quarterly), rebalance every 10 trading days, top 5 names, benchmark 399101.XSHE, initial capital ¥100,000.
The strategy runs on JoinQuant (jqdata, jqfactor).
- Log into JoinQuant research environment
- Create a new strategy
- Copy the entire code into the script
- Ensure you have:
jqdata&jqfactorpermissions- Read/write local file access
- An empty model store on the first run triggers full training
- Then rolling training automatically happens per schedule
The research program ahead builds on the v2 result above.
- Industry-neutral factors
- Style factors
- Alternative data
- CatBoost and neural-net members in the ensemble
- Cross-validation on the rolling window
- Hyperparameter search inside the same retrain clock
- Industry diversification
- Volatility-based allocation
- Dynamic stop-loss
- Slippage model aligned to the printed commission and impact settings
- Intraday modeling
- Liquidity constraints
- Data provider beside the JoinQuant research APIs
- Backtest loop for the same 10-trading-day rebalance clock
- JoinQuant official API for data access

