An offline, reproducible study of cross-sectional A-share stock selection. The system combines 18 price, volatility, liquidity and technical factors with a Transformer ranking model, then evaluates a five-session Top-50 portfolio with turnover, transaction-cost and risk controls.
The public repository contains the research package, report generators, tests and the complete set of result tables and figures. Raw market data, trained models and prediction caches are intentionally excluded from version control. Once those private local artifacts are placed at the documented paths, no market-data API is required to reproduce the reports.
| Component | Specification |
|---|---|
| Data | 8,813,885 daily observations, 5,696 stocks, 2018-01-02 to 2025-12-31 |
| Training / factor selection | 2018-2021, with forward-target boundary purging |
| Validation | 2022, retained as a full bear-market evaluation segment |
| Final test | 2023-2025, excluded from model and checkpoint selection |
| Features | 18 selected reversal, momentum, volatility, liquidity and technical factors |
| Model | 20-session Transformer sequence model |
| Target | Signal after date-T close; buy at next adjusted open and exit at the sixth adjusted open |
| Portfolio | Top 50; Top-100 retention buffer; minimum 10% replacement per rebalance |
| Rebalance | Every five observed market sessions |
| Cost model | 15 bps per one-way executed turnover |
| Risk control | 15% volatility target; 10-rebalance lookback; 50% exposure cap after 15% prior drawdown |
| Benchmark | Equal-weight return of the available common stock universe |
The factor pipeline applies point-in-time time-series feature construction, cross-sectional preprocessing and market-cap neutralization before sequence inference. The portfolio engine accounts for both stock replacement and exposure resizing in executed turnover. Maximum drawdown is calculated from a wealth curve that includes initial capital of 1.0.
See methodology for the full research contract and research integrity for evaluation boundaries, uncertainty analysis and known limitations.
The primary result is the risk-controlled portfolio at 15 bps. Validation and final-test results are reported together so that the 2022 bear market remains visible rather than being omitted from the headline evidence.
| Period | Rebalances | IC | ICIR | Annualized net | Benchmark | Annualized net excess | IR | Net MDD |
|---|---|---|---|---|---|---|---|---|
| Validation 2022 | 48 | 0.0880 | 1.225 | -3.62% | -12.49% | 10.13% | 0.729 | 24.09% |
| Final test 2023-2025 | 145 | 0.0752 | 0.851 | 28.39% | 17.45% | 9.31% | 0.692 | 21.08% |
Source: backtest.csv.
| Year | Research segment | IC | Annualized net | Benchmark | Annualized net excess | IR | Net MDD |
|---|---|---|---|---|---|---|---|
| 2022 | Validation | 0.0880 | -3.62% | -12.49% | 10.13% | 0.729 | 24.09% |
| 2023 | Final test | 0.0633 | 24.27% | 5.34% | 17.96% | 1.578 | 9.52% |
| 2024 | Final test | 0.0654 | 3.41% | 2.00% | 1.38% | -0.027 | 18.07% |
| 2025 | Final test | 0.0975 | 64.80% | 51.14% | 9.04% | 0.790 | 16.49% |
IC is positive in every reported year, while portfolio-level excess performance varies materially by market regime. Source: yearly_performance.csv.
All models use the same stock-date observations, target definition, rebalance schedule and no-risk portfolio engine. The comparison isolates ranking-model behavior from the portfolio risk overlay.
| Final-test model | IC | Annualized net | IR | Net MDD |
|---|---|---|---|---|
| Equal-weight factor score | 0.0914 | -34.01% | -2.519 | 78.73% |
| Ridge (cross-sectional) | 0.0778 | 19.58% | 0.198 | 45.55% |
| Ridge (lagged) | 0.0717 | 38.27% | 0.987 | 36.93% |
| Transformer | 0.0752 | 44.06% | 1.771 | 32.51% |
The Transformer does not have the highest mean IC, but it has the strongest portfolio-level return and information ratio among the declared baselines. Source: baseline_comparison.csv.
| Final-test cost | Annualized net | Annualized net excess | IR | Net MDD |
|---|---|---|---|---|
| 15 bps | 28.39% | 9.31% | 0.692 | 21.08% |
| 25 bps | 25.17% | 6.57% | 0.487 | 21.44% |
| 35 bps | 22.02% | 3.89% | 0.280 | 21.81% |
Performance remains positive at higher assumed costs, but the declining IR shows material turnover sensitivity. Source: cost_sensitivity.csv.
| Final-test configuration | Annualized net | IR | Net MDD | Average exposure |
|---|---|---|---|---|
| No risk overlay | 44.06% | 1.771 | 32.51% | 100.0% |
| Volatility targeting only | 29.82% | 0.863 | 21.08% | 77.5% |
| Drawdown scaling only | 35.23% | 1.124 | 24.30% | 87.9% |
| Full overlay | 28.39% | 0.692 | 21.08% | 73.9% |
The overlay reduces drawdown and market exposure, but also reduces return and IR. It should therefore be interpreted as an explicit return-risk trade-off. Source: risk_ablation.csv.
Excluding the daily bottom 10% by point-in-time circulating market capitalization leaves final-test IC at 0.0734 and annualized net return at 24.74%, versus 0.0752 and 28.39% in the full universe. The result is not solely driven by the smallest stocks, although the filter increases net MDD from 21.08% to 25.31%. Source: universe_ablation.csv.
Two thousand deterministic circular moving-block bootstrap draws produce the following 95% intervals:
| Period | Net excess estimate | 95% interval | P(excess > 0) | IC estimate | 95% IC interval |
|---|---|---|---|---|---|
| Validation 2022 | 10.13% | [-13.48%, 41.32%] | 76.65% | 0.0880 | [0.0718, 0.1049] |
| Final test 2023-2025 | 9.31% | [-4.52%, 24.43%] | 89.70% | 0.0752 | [0.0602, 0.0900] |
IC intervals remain positive, while excess-return and IR intervals include zero. The evidence is stronger for persistent ranking power than for a statistically conclusive portfolio-level excess-return claim over this sample. Source: bootstrap_uncertainty.csv.
A_Share_Alpha_System/
├── data/raw/ # Local A-share daily Parquet panel
├── models/ # Factor configuration and Transformer checkpoint
├── artifacts/cache/ # Validated prediction ledger and metadata
├── reports/
│ ├── tables/ # Summary metrics and robustness tables
│ ├── ledgers/ # Rebalance-level audit trails
│ └── figures/ # Publication-ready charts
├── src/a_share_alpha/ # Research, model, backtest and reporting package
├── tests/ # Integrity and regression tests
├── docs/ # Methodology and research-integrity notes
├── pyproject.toml
└── requirements-research.txt
Generated tables use UTF-8 with BOM for convenient opening in Chinese-language spreadsheet software. Large local data and prediction-cache files are ignored by Git.
Python 3.11 is required. To create an isolated environment with uv:
uv venv --python 3.11 .venv
uv pip install --python .venv/bin/python -r requirements-research.txtThe following private artifacts are required for a full rerun and are not distributed through GitHub:
data/raw/a_share_daily_full.parquet
models/factor_config.pkl
models/transformer_alpha.pth
artifacts/cache/prediction_ledger.parquet
artifacts/cache/prediction_ledger.metadata.json
The committed result tables and figures can be inspected without these files.
Run the primary backtest and derived reports from the project root:
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.backtest
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.cost_sensitivity
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.excess_metrics
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.risk_ablation
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.universe_ablation
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.robustness_report
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.research_auditThe baseline comparison is a separate, slower full-panel run:
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src .venv/bin/python -m a_share_alpha.baseline_comparisonRun the test suite:
PYTHONDONTWRITEBYTECODE=1 .venv/bin/python -m pytest -qThese commands use only the local Parquet, model files and prediction cache.
Use a_share_alpha.backtest --rebuild-cache only after an intentional change
to source data, selected factors or the checkpoint.
- Historical ST labels, limit-up/limit-down tradability and suspension-state fields are unavailable in the local panel. ST filtering is therefore not evaluated or approximated using current security names.
- The target advances by each stock's observed rows. Its entry or exit date differs from the common market calendar for 0.61% of valid samples, including 0.55% in validation and 0.18% in the final test. See horizon_integrity.csv.
- The final test contains three calendar years. Portfolio-level bootstrap intervals remain wide.
- Results use one saved Transformer checkpoint; multi-seed training stability is not claimed.
- The benchmark is a research universe return rather than a directly investable index with constituent history and its own trading costs.
This repository documents a research backtest, not live-trading performance or investment advice.





