Formulating Financial Trading Strategies Using LLM: A DSL-Mediated Approach via in-Context Learning
Large language models (LLMs) offer the potential to streamline traditional tools through intuitive interfaces, but financial trading requires clear, interpretable solutions. Direct conversion of natural language instructions into general-purpose programming languages via LLMs often leads to redundancy and hallucination. To address these challenges, we propose a domainspecific language (DSL) as an intermediary. The proposed twostage process first converts user instructions into DSL through incontext learning (ICL), followed by conversion into general programming languages. This approach improves efficiency, reduces manual intervention, and improves interpretability, particularly for exchange-traded fund (ETF) strategies. The experimental results show an exact match rate of 0.953, demonstrating the effectiveness of translating complex trading logic into DSL. The impact of DSL design and LLM selection is also discussed, highlighting the broader potential of this technique in the development of financial strategies and its applicability in other domains. Furthermore, the Introduction briefly touches on the limitations of traditional approaches, outlining how the DSLmediated solution overcomes these challenges, offering a costeffective and efficient alternative.
Authors
- Jinheng Wu
- Di Zhang (ORCID: https://orcid.org/0000-0003-0237-2361)
- Qiang Niu (ORCID: https://orcid.org/0000-0002-6880-6874)
Institutions
- Xi’an Jiaotong-Liverpool University (CN)
Publication Details
- Published
- 2025-03-21
- DOI
- https://doi.org/10.1109/icnlp65360.2025.11108657
- Primary Topic
- Stock Market Forecasting Methods
- Type
- article
- Field-Weighted Citation Impact
- 0.00