Large Language Models (LLMs) offer a promising approach to enhancing traditional financial tools with intuitive interfaces. However, in financial trading, particularly in Exchange-Traded Fund (ETF) strategies, the need for precision, interpretability, and reliability limits their direct application due to challenges like inefficiencies and hallucinations. This study introduces a two-stage framework that uses a domain-specific language (DSL) as an intermediary. Natural language inputs are converted into DSL through in-context learning (ICL) and then translated into general-purpose programming languages. This method improves computational efficiency, reduces manual intervention, and ensures clear interpretability. Experiments show the framework achieves a 95.3% match rate in mapping trading logic to DSL. The study also explores the impact of DSL design and LLM selection, demonstrating the framework’s applicability beyond finance. By integrating ICL and DSL, this framework offers a scalable, cost-effective solution for linking natural language processing with financial strategy execution, advancing automated trading systems.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Designing Trading Strategies with LLMs: A DSL-Driven Framework Using In-Context Learning

  • Jinheng Wu,
  • Di Zhang,
  • Qiang Niu

摘要

Large Language Models (LLMs) offer a promising approach to enhancing traditional financial tools with intuitive interfaces. However, in financial trading, particularly in Exchange-Traded Fund (ETF) strategies, the need for precision, interpretability, and reliability limits their direct application due to challenges like inefficiencies and hallucinations. This study introduces a two-stage framework that uses a domain-specific language (DSL) as an intermediary. Natural language inputs are converted into DSL through in-context learning (ICL) and then translated into general-purpose programming languages. This method improves computational efficiency, reduces manual intervention, and ensures clear interpretability. Experiments show the framework achieves a 95.3% match rate in mapping trading logic to DSL. The study also explores the impact of DSL design and LLM selection, demonstrating the framework’s applicability beyond finance. By integrating ICL and DSL, this framework offers a scalable, cost-effective solution for linking natural language processing with financial strategy execution, advancing automated trading systems.