TL;DR
Moira introduces a language-driven Hierarchical Reinforcement Learning (HRL) framework for pair trading that orchestrates large language models (LLMs) to handle both high-level asset selection and low-level trade execution. By optimizing entirely in prompt space using textual feedback, Moira elegantly solves the classic reinforcement learning credit assignment problem without requiring any gradient-based fine-tuning.
What Problem Does This Paper Address?
In sequential decision-making, many real-world problems are inherently hierarchical: high-level strategic choices constrain low-level tactical execution. Pair trading—a financial strategy that involves identifying two historically correlated assets and trading their price divergence—is a perfect example. It requires long-horizon semantic reasoning to pick the right stock pairs, combined with short-horizon precision to execute trades under high market noise.
When an end-to-end trading system loses money, it suffers from an ambiguous credit assignment problem: Did the strategy fail because the fundamental relationship between the two stocks broke down (bad abstraction), or because the entry/exit timing was poor (bad execution)? Traditional "flat" models entangle these layers, making it incredibly difficult to diagnose and correct failures based purely on delayed, scalar rewards (like net profit or loss).
Methods
Moira addresses this challenge by formulating pair trading as an HRL problem and using language as a shared semantic interface across both levels of the hierarchy. Both the high-level "Selector" and the low-level "Trader" are parameterized by prompt-conditioned LLMs (specifically using DeepSeek-V3) with frozen weights.
Instead of updating model weights via gradients, the system optimizes behavior entirely through prompt updates driven by an asymmetric adaptation schedule:
- Low-Level Optimization (Trader): Operating at an intra-episode scale (e.g., weekly), the Trader receives short-horizon market inputs and outputs market-neutral actions (long, short, hold, close). At the end of a sub-episode, a Critic LLM reviews the trajectory and generates a natural-language critique (a "textual gradient"). An updater prompt then revises the Trader's execution rules.
- High-Level Optimization (Selector): Operating at an episodic scale (e.g., monthly), the Selector analyzes long-horizon price trends and news summaries to choose an asset pair. It is optimized only after the episode concludes, receiving aggregated performance feedback to refine its pair-selection thesis.
This separation of time scales and explicit textual feedback allows the framework to isolate whether a failure was due to a bad pair selection or poor trade timing.
Datasets
The authors evaluated Moira using real-world U.S. equity market data from January 1, 2025, to June 1, 2025.
- Stock Universe: A fixed portfolio of 10 highly liquid U.S. stocks spanning multiple sectors: AAPL, ADBE, AMZN, BMRN, CRM, GOOGL, META, MSFT, NVDA, and TSLA.
- Data Streams: Daily adjusted closing prices combined with unstructured textual market data (news articles and sentiment indicators) scraped from OpenAI Web Search, Finnhub, NewsData, and yfinance. These text streams were consolidated into daily summaries using GPT5-nano.
Key Insights and Ideas
- Language as a Textual Gradient: Unlike scalar rewards, text can explicitly articulate why an action failed. Textual feedback acts as a low-dimensional, semantically rich control surface that prevents cross-level interference during optimization.
- Emergent Risk Management: As the Trader prompt undergoes iterative critiques, it naturally transitions from basic entry/exit rules to discovering sophisticated risk-management behaviors entirely from scratch—such as implementing trailing stops, partial profit-taking, and trading cooldown periods.
- Robustness to Prompt Engineering: Prompt sensitivity analysis revealed that even when starting with different paraphrased initial prompts, the optimization process consistently converged toward profitable trading rules, proving the framework doesn't rely on brittle, hand-crafted prompt engineering.
Key Results
Moira significantly outperformed traditional statistical methods, reinforcement learning baselines, and non-hierarchical LLM agents across all major financial metrics:
- Profitability & Risk-Adjusted Return: Moira achieved an Annualized Return (AR) of 59.11% and a stellar Sharpe Ratio (SR) of 3.791. In comparison, the best statistical baseline (Correlation/Cointegration) managed a 21.38% AR and 1.218 SR, while a non-hierarchical "Flat-LLM" approach lost money (-7.69% AR).
- Downside Protection: Moira reduced the Maximum Drawdown (MDD) to just 1.70%, compared to 5.11% for traditional cointegration and 8.69% for the Flat-LLM.
Ablation studies confirmed that both the hierarchical structure and the prompt-tuning mechanism are strictly necessary; removing either component caused performance to degrade drastically.
Limitations and Future Work
While promising, the authors note a few key limitations:
- Scale: The experiments were confined to a relatively small universe of 10 stocks. Scaling up to hundreds of assets will introduce substantial computational and token-cost overhead.
- Regime Shifts: The framework was not explicitly tested against extreme market anomalies or black swan events.
- Theoretical Foundations: While "textual gradients" work well empirically, their formal convergence properties and theoretical bounds remain an open question.
Future work will focus on context compression to reduce token costs, expanding the framework to larger asset universes, and applying language-driven HRL to non-financial hierarchical domains.
Summary updated