Trading Strategy Optimization via Textual Gradient
Organizations: National University of Singapore
Abstract
Quantitative trading strategy design aims to discover trading programs from historical data that remain effective in future markets, which can be viewed as a black-box program optimization problem. LLM-based textual gradients offer a promising approach by providing explicit optimization directions for iterative strategy refinement. However, directly applying textual gradients faces two challenges: (1) optimization is myopic, underutilizing experience from previous evaluations; and (2) aggregate backtest feedback overlooks temporal robustness, potentially favoring strategies that perform well only in specific market periods. To address these challenges, we propose TradeGrad, an experience-guided textual-gradient framework for robust trading strategy optimization. TradeGrad leverages accumulated optimization experience to estimate textual gradients and employs multi-scale revisions for both strategy exploration and refinement. It further introduces the Cross-Period Robust Objective (CPRO), which emphasizes performance in unfavorable historical periods to promote temporal robustness. Experiments on cross-sectional and time-series strategy design in Chinese A-share and U.S. equity markets show that TradeGrad achieves the best in-sample and out-of-sample performance across all four settings. Notably, its Chinese cross-sectional strategy achieves 27.99% annualized return, 12.19% maximum drawdown, and a Sharpe ratio of 1.63, approximately 68% higher than the CSI 300 benchmark. Further analyses validate the proposed components and show consistent improvements in both in-sample and out-of-sample performance throughout optimization. The code is available at https://github.com/transcend-0/TradeGrad.
Figures & tables
| CSI 300 | S&P 500 | ||||||||||
| Setting | Method | IS Score | OOS Score | AR | MDD | SR | IS Score | OOS Score | AR | MDD | SR |
| Market Index Reference | 1.63 | 45.01 | 17.69 | 15.66 | 0.97 | 5.44 | 39.38 | 20.76 | 18.90 | 1.26 | |
| Cross-Sectional Strategies | |||||||||||
| Classical | Momentum | 0.52 | 9.19 | 5.76 | 28.49 | 0.35 | 9.02 | 2.37 | -15.35 | 31.13 | -1.58 |
| Reversal | 0.28 | 14.51 | 17.80 | 28.59 | 0.74 | 5.12 | 26.76 | 0.56 | 11.59 | 0.11 | |
| Volatility | 7.56 | 60.69 | 18.59 | 8.74 | 1.41 | 4.41 | 6.93 | -9.38 | 23.79 | -0.79 | |
| Method | IS Score | OOS Score | AR | MDD | SR |
| Full Method | |||||
| w/o Memory | |||||
| w/o Sampling | |||||
| w/o MSR (Diff) | |||||
| w/o MSR (Rewrite) |
| Objective | IS OV | IS Score | OOS Score | AR | MDD | SR |
| CPRO | ||||||
| CPRO w/o Freq Gate | ||||||
| Mean-Period Objective | ||||||
| Aggregate Objective |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| CSI 300 | S&P 500 | |||||||||
| Method | IS Score | OOS Score | AR | MDD | SR | IS Score | OOS Score | AR | MDD | SR |
| Cross-Sectional Strategies | ||||||||||
| Island Algorithm | 0.02 | 0.52 | 2.01 | 11.26 | 0.06 | 1.12 | 0.13 | 3.37 | 15.03 | 0.44 |
| QuantEvolve | 0.31 | 0.94 | 0.84 | 11.04 | 0.02 | 0.03 | 0.03 | 4.02 | 18.54 | 0.24 |
| Vanilla TextGrad | 0.01 | 0.97 | 1.21 | 11.50 | 0.04 | 0.10 | 0.74 | 2.23 | 10.09 | 0.27 |
| Ours | 1.06 | 12.15 | 4.19 | 4.65 | 0.17 | 2.67 | 8.39 | 0.94 | 1.50 | 0.11 |
Algorithmic Trading
Algorithmic trading uses computational models to generate signals, allocate portfolios, and execute orders across financial markets.
See all 149 papers