MacroHFT: Memory Augmented Context-aware Reinforcement Learning On High Frequency Trading

Chuqiao Zong, Chaojie Wang, Molei Qin, Lei Feng, Xinrun Wang, Bo An · DOI

Introduction

High-frequency trading (HFT) in the cryptocurrency market is often likened to "picking up pennies in front of a steamroller." While the potential for profit is substantial, the extreme volatility and non-stationary nature of digital assets mean that a strategy successful in one minute can lead to catastrophic losses the next. Traditional Reinforcement Learning (RL) models often struggle to adapt to these rapid regime shifts.

To address these challenges, researchers from Nanyang Technological University and Skywork AI have developed MacroHFT, a hierarchical reinforcement learning framework. MacroHFT is designed to navigate market fluctuations by decomposing complex market data into specialized contexts and utilizing a memory-augmented "hyper-agent" to orchestrate trading decisions.

The Challenges of HFT in Crypto

Reinforcement Learning is theoretically well-suited for trading as it treats the market as a sequential decision-making problem. However, standard RL agents face three significant hurdles in high-frequency environments:

  1. Overfitting: Agents frequently latch onto stochastic noise rather than identifying broader market contexts.
  2. Context Blindness: Many models focus exclusively on price trends while ignoring volatility—a critical factor for effective risk management.
  3. One-sided Bias: Most hierarchical models use a "router" to select a single expert agent for a given moment. If that specific agent is biased or incorrect, the resulting loss can be severe.

MacroHFT bridges the gap between low-level execution (the "how") and high-level strategy (the "when" and "why") to overcome these limitations.

Methodology: A Two-Phase Hierarchical Approach

The MacroHFT framework operates through a two-phase hierarchical Markov Decision Process (MDP) that emphasizes both specialization and integration.

Phase I: Sub-agent Training with Conditional Adaptation

Instead of training a single monolithic model, MacroHFT decomposes the market into six distinct categories based on two dimensions: Trend (Bull, Medium, Bear) and Volatility (Volatile, Medium, Stable).

  • The Backbone: The system utilizes Double Deep Q-Networks (DDQN) with a dueling architecture.
  • Conditional Adapter: Inspired by the "Adaptive Layer Norm" found in Diffusion Transformers, the researchers implemented a mechanism that scales and shifts the hidden representations of the network based on the current market context (positioning and technical indicators). This allows sub-agents to specialize their policies for specific "market vibes."

Phase II: Hyper-agent Training with Memory Augmentation

Rather than simply switching between sub-agents, MacroHFT trains a hyper-agent to produce a "policy mixture."

  • Softmax Weighting: The hyper-agent assigns weights to all sub-agents, blending their outputs into a single meta-policy. This avoids the "jitter" and bias associated with hard-switching between models.
  • Episodic Memory: To manage sudden or rare market shocks, the hyper-agent utilizes a table-based memory module. It stores recent successful experiences and uses an L2-distance-based lookup (similar to k-Nearest Neighbors) to retrieve relevant past Q-values. This ensures the agent remains consistent even during anomalous market behavior.

Experimental Setup

The model was rigorously evaluated using minute-level data for four major cryptocurrency pairs from Binance: BTC/USDT, ETH/USDT, DOT/USDT, and LTC/USDT. The dataset included both OHLCV (Open-High-Low-Close-Volume) and Limit Order Book (LOB) information, spanning from early 2022 to late 2023 to capture diverse market cycles.

Key Results and Insights

MacroHFT was benchmarked against eight baselines, including standard RL algorithms (DQN, PPO) and specialized trading models like EarnHFT.

  • Superior Profitability: On the ETH/USDT pair, MacroHFT achieved a Total Return (TR) of 39.28%, nearly doubling the performance of the next best baseline (EarnHFT at 18.02%).
  • Robust Risk Management: During the testing period, the DOT and LTC markets experienced heavy "bear" phases. MacroHFT was one of the few models to remain significantly profitable while maintaining a low Maximum Drawdown (MDD).
  • The Importance of Volatility: The research demonstrates that explicitly accounting for volatility during market decomposition—rather than just price trends—significantly improves risk-adjusted returns.
  • Ablation Success: Removing either the Conditional Adapter or the Memory module led to significant performance degradation, confirming that both context-awareness and experience retention are vital for HFT success.

Limitations and Future Directions

While MacroHFT represents a significant advancement, the authors identified areas for further refinement. The current market decomposition relies on fixed-length data chunks, which may not perfectly capture fluid regime shifts. Additionally, training multiple specialized sub-agents alongside a hyper-agent introduces higher computational overhead than single-agent approaches. Future work may explore dynamic chunking or the application of this hierarchical approach to multi-asset portfolio management.

Summary updated

BibTeX
@inproceedings{zong2024macrohft,
  author = {Chuqiao Zong and Chaojie Wang and Molei Qin and Lei Feng and Xinrun Wang and Bo An},
  title = {{MacroHFT: Memory Augmented Context-aware Reinforcement Learning On High Frequency Trading}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
  url = {https://openreview.net/forum?id=l3sujW5Lu8},
}
Figure