TL;DR
TradeGrad is a novel framework that leverages Large Language Models (LLMs) to optimize quantitative trading strategies using "textual gradients"—natural language feedback that diagnoses code weaknesses and suggests improvements. By incorporating a global optimization memory and a tail-risk-focused objective, it overcomes the common pitfalls of overfitting and myopic search, significantly outperforming existing automated strategy design methods in both Chinese and U.S. markets.
What Problem Does This Paper Address?
Designing a quantitative trading strategy is essentially a black-box program optimization problem: you want to find a piece of code that maps market data to profitable decisions. Traditionally, this required intense human expertise. While recent efforts have tried to automate this using LLMs and evolutionary algorithms, they face two major hurdles:
- Myopia: Most iterative refinement methods only look at the current step. They "forget" past failures and successes, leading to redundant exploration and unstable optimization.
- Lack of Temporal Robustness: Financial markets are non-stationary. A strategy might look like a genius move because it performed exceptionally well during a specific bull market, but it might be fragile and "overfit" to those specific conditions, failing miserably when market regimes shift.
Methods
The authors introduce TradeGrad, which moves beyond simple stochastic mutations by using semantic feedback. Its architecture consists of three core innovations:
- Experience-Guided Textual Gradients: Instead of just asking an LLM to "fix this code," TradeGrad maintains a Periodic Global Optimization Memory. This memory distills successful and failed patterns from all previous iterations. When estimating a "gradient" (the direction for improvement), the LLM compares the current strategy against a performance-biased set of reference strategies from its archive, using past experience to avoid repeating mistakes.
- Multi-Scale Strategy Revision: The framework balances exploration and refinement. It samples a revision scale: "Large" for structural rewrites of the core logic, and "Small" for localized code edits (like tweaking a threshold).
- Cross-Period Robust Objective (CPRO): To ensure the strategy isn't just "getting lucky" in specific years, CPRO partitions historical data into yearly windows. Inspired by Conditional Value-at-Risk (CVaR), it optimizes for the mean of the lowest 30% of these window scores. This forces the model to improve performance in unfavorable periods rather than letting a few stellar periods mask underlying weaknesses.
Datasets
The framework was evaluated on two major markets using daily data from 2018 to 2025:
- Chinese A-share Market: Using constituents of the CSI 300 index.
- U.S. Equity Market: Using constituents of the S&P 500 index. The data was split chronologically (3:1 ratio) into an In-Sample (IS) period for optimization and a strictly held-out Out-of-Sample (OOS) period for final evaluation.
Key Insights and Ideas
- Semantic Direction Matters: Unlike genetic algorithms that mutate code randomly, textual gradients provide a "why" and "how." For example, the LLM might suggest: "This momentum strategy fails during volatile reversals; try normalizing momentum by recent volatility."
- Optimizing for the Tail: The "aha moment" here is that optimizing for average performance leads to overfitting. By focusing on the "worst" historical periods (via CPRO), the resulting strategies are significantly more robust when they encounter unseen future data.
- Non-Monotonic Evolution: The ancestral lineage of a successful strategy often includes steps where performance temporarily drops. This suggests that maintaining a flexible search space—where a "bad" intermediate step can introduce logic that becomes powerful after further refinement—is crucial.
Key Results
TradeGrad consistently achieved the highest scores across all tested settings:
- Chinese Cross-Sectional Trading: It achieved a 27.99% annualized return with a Sharpe ratio of 1.63, outperforming the CSI 300 benchmark by approximately 68% in risk-adjusted terms.
- U.S. Market Robustness: In the S&P 500 cross-sectional setting, it maintained a positive return with a remarkably low maximum drawdown of only 3.93%.
- Sustained Gains: Unlike baselines like TextGrad or Island Algorithms, which often plateaued or deteriorated in out-of-sample tests, TradeGrad showed a steady upward trend in both in-sample and out-of-sample performance throughout the optimization process.
Limitations and Future Work
While powerful, the authors note a few areas for growth:
- Frequency and Assets: The current study focuses on daily equity data. Future work could extend this to high-frequency trading or other asset classes like commodities and forex.
- Information Richness: The textual gradient estimation could be improved by feeding the LLM even richer market context, such as macroeconomic indicators or news sentiment.
- Distribution Shifts: While CPRO handles temporal non-stationarity well, further research is needed to investigate robustness against more extreme or diverse forms of market distribution shifts.
Summary updated