Table of Contents
Fetching ...

From Natural Language to Executable Option Strategies via Large Language Models

Haochen Luo, Zhengzhao Lai, Junjie Xu, Yifan Li, Tang Pok Hin, Yuan Zhang, Chen Liu

Abstract

Large Language Models (LLMs) excel at general code generation, yet translating natural-language trading intents into correct option strategies remains challenging. Real-world option design requires reasoning over massive, multi-dimensional option chain data with strict constraints, which often overwhelms direct generation methods. We introduce the Option Query Language (OQL), a domain-specific intermediate representation that abstracts option markets into high-level primitives under grammatical rules, enabling LLMs to function as reliable semantic parsers rather than free-form programmers. OQL queries are then validated and executed deterministically by an engine to instantiate executable strategies. We also present a new dataset for this task and demonstrate that our neuro-symbolic pipeline significantly improves execution accuracy and logical consistency over direct baselines.

From Natural Language to Executable Option Strategies via Large Language Models

Abstract

Large Language Models (LLMs) excel at general code generation, yet translating natural-language trading intents into correct option strategies remains challenging. Real-world option design requires reasoning over massive, multi-dimensional option chain data with strict constraints, which often overwhelms direct generation methods. We introduce the Option Query Language (OQL), a domain-specific intermediate representation that abstracts option markets into high-level primitives under grammatical rules, enabling LLMs to function as reliable semantic parsers rather than free-form programmers. OQL queries are then validated and executed deterministically by an engine to instantiate executable strategies. We also present a new dataset for this task and demonstrate that our neuro-symbolic pipeline significantly improves execution accuracy and logical consistency over direct baselines.
Paper Structure (59 sections, 17 equations, 4 figures, 13 tables)

This paper contains 59 sections, 17 equations, 4 figures, 13 tables.

Figures (4)

  • Figure 1: Taxonomy of option strategies in trading.
  • Figure 2: This figure illustrates the complete workflow of the Options Query Language (OQL) system, from intent to executable option strategies. Top: the OQL pipeline collects trading intent from human users or intelligent agents, translates high-level intent into formal OQL queries, and executes them to retrieve candidate strategies. Bottom: the deterministic OQL compiler $P_{\phi}$ processes each query through parsing and semantic validation, vectorized filtering over option-chain data, and combinatorial leg assembly with aggregate constraints, producing a ranked set of valid option strategies. The full OQL grammar, formal definitions and backend are provided in Appendix \ref{['app:oql']}.
  • Figure 3: Dataset construction workflow. We segment historical price data into distinct market regimes, align natural-language trading intents with regime-consistent option strategy labels, and finalize JSON samples with backtesting windows aligned to regime boundaries, producing a grounded dataset of intents, strategies, and market regimes.
  • Figure 4: The LLM-as-a-Judge prompt used to evaluate Semantic Accuracy (SA). It distinguishes between hard and soft constraints to ensure fair evaluation of the generated OQL code.