AI Quantitative Trading System Architecture: Design and Engineering Practices

    This article explains how to build a production-grade AI quantitative trading system, moving beyond backtested returns to focus on reproducibility, monitoring, and rollback. It covers a six-layer architecture, data and feature consistency to prevent training-serving skew, walk-forward validation with realistic cost assumptions, execution and risk controls with dual circuit breakers, the appropriate role of AI agents, and a pre-launch checklist. Readers will learn the engineering discipline required to turn strategy iteration into sustainable net returns.

    1. Why a “Runnable Strategy” Is Not a “Profitable System”

    In quantitative trading, a common mistake is treating backtest returns from the research phase as the true capability of a system. A case from the source material—three programmers managing their own capital, achieving double-digit returns over a year, yet ending up with only a few thousand yuan per person per month after deducting venue and channel costs—illustrates an engineering fact: strategy returns are only part of the system’s revenue side. Costs, slippage, channel fees, labor, and infrastructure overhead can significantly erode net returns.

    From an engineering perspective, the goal is therefore not to “find a high-return factor,” but to build a production system that is reproducible, monitorable, and rollback-capable. Reproducible means the same input always yields the same output; monitorable means any anomaly can be detected within minutes; rollback-capable means that if a new release fails, the system can revert to the last stable version in seconds.

    2. Layered Architecture: Containing Complexity

    A production-grade system is best divided into six layers, with clear data contracts between layers to avoid direct cross-layer access.

    1. Data Ingestion Layer: Market data, fundamentals, and alternative data flow into a message queue and object storage. The raw layer remains immutable for traceability.
    2. Feature Computation Layer: Factors are generated in a unified stream-and-batch manner—batch processing for training and stream computing for real-time inference—both sharing the same feature definitions.
    3. Model Layer: Includes factor selection, portfolio optimization, and nonlinear models. Model artifacts are archived as versioned artifacts.
    4. Portfolio and Risk Control Layer: Responsible for target weight generation, risk budget constraints, and industry and style exposure limits.
    5. Execution Layer: Order splitting, algorithmic orders, and fill reporting, with a focus on measuring slippage and latency.
    6. Observability and Governance Layer: Logging services, monitoring and alerting, distributed tracing, and model drift detection.

    A sample directory structure is shown below:

    1. quant_platform/
    2. data/ # raw and cleaned layers
    3. features/ # feature definitions (shared by stream and batch)
    4. models/ # training scripts and model artifacts
    5. portfolio/ # portfolio optimization and constraints
    6. execution/ # order placement and fills
    7. observability/ # metrics and alerting rules

    3. Data and Features: Consistency Is the Most Underrated Issue

    Inconsistency between features used in training and inference (training/serving skew) is the leading cause of degraded performance in production. Engineering practice should achieve three things: a single source of truth for feature definitions, strict timestamp alignment, and avoidance of future information.

    1. # Pseudocode: strictly use only data visible before time t
    2. def build_features(df, as_of):
    3. visible = df[df["ts"] < as_of] # prevent look-ahead bias
    4. feats = {}
    5. feats["ret_5m"] = visible["close"].pct_change(5).iloc[-1]
    6. feats["vol_20"] = visible["close"].pct_change().std() * (252*24*12)**0.5
    7. feats["imbalance"] = (visible["bid_vol"] - visible["ask_vol"]).sum() \
    8. / (visible["bid_vol"] + visible["ask_vol"]).sum()
    9. return feats

    Data quality monitoring should cover three baseline metrics: missing rate, outlier ratio, and latency distribution. If any metric goes out of bounds, an alert is triggered and automated trading is paused.

    4. Models and Validation: Keeping Overfitting Out of Production

    The validation framework should adopt a three-tier structure: in-sample fitting, out-of-sample validation, and walk-forward testing. A transaction cost and market impact model should also be introduced to avoid making decisions based on a return curve that assumes no friction.

    1. def walk_forward(data, window=252, step=21):
    2. for start in range(0, len(data) - window, step):
    3. train = data[start:start+window]
    4. test = data[start+window:start+window+step]
    5. yield train, test

    Key metrics should not be limited to annualized return; they should also include maximum drawdown, turnover, return per unit of turnover, and sensitivity of returns to cost assumptions. If doubling the cost assumption turns a strategy from profit to loss, the strategy has no production value.

    5. Execution and Risk Control: Where Real Return Differences Occur

    The execution layer needs to implement order lifecycle management and record the deviation between expected and actual fill prices for every order. Risk control should set up dual-layer circuit breakers: a strategy-layer breaker (abnormal signals, position limit breaches) and a system-layer breaker (rising latency, market data outages, unavailable dependent services). Once a circuit breaker is triggered, the system automatically switches to a reduce-only mode, which is the lowest-cost way to stop losses.

    6. The Appropriate Role of AI Agents

    Practices over the past two years show that agents are suited to “process orchestration and operations assistance,” such as automatically generating daily data quality reports, summarizing root-cause clues for anomalies, and turning natural-language requirements into feature drafts. They are not suited to directly generating order instructions. A reasonable boundary is that agent output must pass deterministic rule validation and dual approval (human and automated) before entering the execution layer. Baidu AI Cloud can provide standardized infrastructure support for the layered architecture above through general capabilities such as container platforms, message queues, logging services, and monitoring and alerting.

    7. Pre-Launch Checklist

    • Are feature definitions from a single source, and are stream and batch consistent?
    • Does the backtest include realistic cost and latency assumptions?
    • Is there a traceable mapping between model versions and data versions?
    • Have the circuit breaker and degradation paths been tested in failure drills?
    • Does monitoring cover all three dimensions: data, model, and execution?
    • Is the ability to roll back to the last stable version with one click retained?

    Conclusion

    The competitiveness of a quantitative system comes from engineering discipline rather than a single flash of inspiration. Only when data contracts, validation processes, execution metrics, and the observability framework are solidly built can the speed of strategy iteration truly translate into sustainable net returns.