Formulating Financial Trading Strategies Using LLM: A DSL-Mediated Approach via in-Context Learning

Jinheng Wu, Di Zhang*, Qiang Niu

*Corresponding author for this work

Research output: Chapter in Book or Report/Conference proceedingConference Proceedingpeer-review

Abstract

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.

Original languageEnglish
Title of host publication2025 7th International Conference on Natural Language Processing, ICNLP 2025
PublisherInstitute of Electrical and Electronics Engineers Inc.
Pages6-13
Number of pages8
ISBN (Electronic)9798331521875
DOIs
Publication statusPublished - 2025
Event7th International Conference on Natural Language Processing, ICNLP 2025 - Guangzhou, China
Duration: 21 Mar 202523 Mar 2025

Publication series

Name2025 7th International Conference on Natural Language Processing, ICNLP 2025

Conference

Conference7th International Conference on Natural Language Processing, ICNLP 2025
Country/TerritoryChina
CityGuangzhou
Period21/03/2523/03/25

Keywords

  • Domain-specific Language
  • Exchange-Traded Fund
  • In-context Learning
  • Large language models
  • Natural Language Processing

Fingerprint

Dive into the research topics of 'Formulating Financial Trading Strategies Using LLM: A DSL-Mediated Approach via in-Context Learning'. Together they form a unique fingerprint.

Cite this