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

Institutions

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
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

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

Jinheng Wu, Di Zhang, Qiang Niu
Stock Market Forecasting Methods
article

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

Jinheng Wu, Di Zhang, Qiang Niu
article en

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.

Xi’an Jiaotong-Liverpool University (CN)
Decent work and economic growth
Openalex Percentile: Top 75%
Stock Market Forecasting Methods
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.