Building an AI Quantitative Trading System for China's A-Share Market
This article explains why China's A-share market requires a localized AI approach and walks through a full-pipeline architecture built around six modules: data engineering, factor engineering, backtesting, strategy optimization, portfolio construction, and risk control with live feedback. It covers handling unstructured data with RAG and fine-tuned financial LLMs, preventing look-ahead bias, embedding trading rules such as T+1 settlement and price limits into backtests, and calibrating cost models with live execution data. Readers will find design principles, practical engineering constraints, and illustrative Python code snippets for a deployable system.
1. Why A-Share Quant Trading Needs a Localized AI Approach
The A-share market differs structurally from mature capital markets. The T+1 settlement cycle makes intraday open-and-close strategies impossible to apply directly. Price limits can truncate fills during extreme moves, making backtested execution prices unachievable. A high proportion of retail investors creates noisy signals and rapid style rotation. Policy and regulatory news often has a stronger marginal impact on sectors than financial data does. Rising factor crowding has significantly shortened the half-life of effective factors.
These characteristics mean overseas frameworks cannot be migrated directly. The value of large AI models lies not in “predicting price direction” but in three things: turning unstructured information into computable features, performing robust selection in high-dimensional noise, and explicitly encoding trading rules and costs into the optimization objective.
Five design principles are essential: prioritize interpretability, strictly avoid look-ahead bias, internalize trading rules, ensure live deployability, and balance returns against costs.
2. Full-Pipeline Architecture: A Closed Loop of Six Modules
The overall pipeline is: data engineering → factor engineering → strategy backtesting → strategy optimization → portfolio construction → risk control → live execution → feedback loop. The feedback loop is the key to closing the cycle: live slippage and order-rejection data must be written back to refine the cost model.
3. Module 1: Data Engineering
The core pain points are heterogeneous data sources, a high proportion of unstructured data, widespread missing and anomalous values, and price distortion caused by trading halts and price limits.
- Structuring unstructured data: Use a fine-tuned financial-domain large model combined with retrieval-augmented generation (RAG) to extract entities and relationships from announcements, research reports, investor Q&A, regulatory letters, and policy documents, outputting fields such as earnings-forecast revisions, management confidence, and policy sensitivity. Extraction results must retain source-text references for manual review.
- Anomaly detection: Combine isolation forests, clustering-based density methods, variational autoencoders, and time-series anomaly models, making the system more sensitive to sudden changes in volume and turnover.
- Missing-value imputation: Time-series generative models and temporal fusion structures preserve sequence dependencies, avoiding the distribution distortion caused by simple interpolation.
- Dimensionality reduction and selection: Combine sparse autoencoders with tree-model feature-importance ranking to compress first, then select.
- Engineering foundation: A distributed computing framework, a vector retrieval library, and a feature platform (offline/online consistency). On the cloud side, use general-purpose capabilities such as object storage, message queues, container platforms, and logging with monitoring and alerting.
Illustrative code (enforcing the point-in-time constraint at the data access layer):
def get_panel(fields, start, end, universe, as_of_time="15:00"):# Only data publicly available before time t is alloweddf = store.read(fields, start, end, universe)df = df[df["publish_time"] <= df["trade_date"] + as_of_time]# Align financial data by announcement date, not reporting periodreturn align_by_announcement(df)
4. Module 2: Factor Engineering and Preventing Look-Ahead Bias
Look-ahead bias usually comes from three sources: aligning financial data by reporting period, using future information in adjustment factors and index constituents, and label computation windows that cross the sample split point. Engineering practice should be driven uniformly by a “data availability timestamp” and use out-of-sample time-based splitting (walk-forward) rather than random splitting.
Factor discovery can use large models to generate hypotheses, expression-tree search to combine them, and symbolic regression to reduce complexity. Evaluation should look at layered monotonicity, turnover, crowding, and decay speed, not IC alone.
# Label computation must reserve a future window, and the training split point moves forwardlabel = forward_return(close, horizon=5) / (volatility + 1e-8)train, test = walk_forward_split(panel, embargo=horizon)
5. Module 3: Backtesting with Internalized Trading Rules
The backtesting engine must model T+1 position locking, non-executable fills at price limits, skipping halted stocks, differences between call auction and continuous trading, and commissions, stamp duty, and impact costs. Impact cost is best modeled with a nonlinear form related to order size, volatility, and liquidity, calibrated by regressing on live data.
6. Module 4: Strategy Optimization and Portfolio Construction
The objective function should be written as “net return − risk penalty − cost,” with constraints including turnover caps, industry and style exposure limits, and single-stock weight limits. In environments with rapid style rotation, it is better to switch risk budgets using a regime-identification model (such as hidden Markov-type methods) than to frequently retrain factors.
7. Module 5: Risk Control and Live Feedback
The solution to lagging risk control is to move it forward into constraints and real-time circuit breakers: intraday drawdown thresholds, liquidity coverage ratios, and near-price-limit warnings. Attribution of live-versus-backtest deviations should trace back to the cost model and fill assumptions, forming a monthly iteration cycle.
8. Implementation Recommendations
Start by validating cost assumptions with a small amount of capital, then scale up gradually. Make interpretability and reproducibility the acceptance criteria. Model deployment must retain complete data lineage and version records. Large AI models are production tools for features and hypotheses; in the end, strict engineering constraints are what make a strategy trustworthy.
