TL;DR
JaxMARL-HFT is the first open-source, fully GPU-accelerated multi-agent reinforcement learning (MARL) environment designed for high-frequency trading (HFT). By keeping both the limit order book simulation and policy updates entirely on the GPU, it achieves up to a 240x training speedup over traditional CPU-based baselines, making large-scale hyperparameter sweeps on years of granular financial data finally practical.
What Problem Does This Paper Address?
Simulating high-frequency financial markets is notoriously difficult. Prices emerge endogenously from the micro-level interactions of millions of participants submitting orders to a Limit Order Book (LOB). Traditional Agent-Based Models (ABMs) rely on hand-crafted, fixed-policy agents that fail to capture complex, adaptive market dynamics like indirect price impact.
While Multi-Agent Reinforcement Learning (MARL) offers a path toward more realistic, co-evolving agent behaviors, its computational overhead has been a massive roadblock. High-frequency trading requires processing massive streams of market-by-order (MBO) data. Existing trading simulation frameworks typically run environment rollouts on the CPU and policy updates on the GPU. This constant shuffling of data back and forth creates a severe bottleneck, limiting MARL research in finance to small-scale or highly simplified setups.
Methods
The authors introduce JaxMARL-HFT, an environment built on top of the JAX-LOB simulator and fully integrated with the JaxMARL framework.
To maximize throughput, the framework leverages JAX’s just-in-time (JIT) compilation and hardware acceleration, implementing a two-level parallelization architecture:
- Across Episodes: The historical dataset is partitioned into individual episodes that are processed in parallel across thousands of GPU threads using JAX’s vectorised mapping (
vmap). - Across Agents: Within each episode, the environment parallelizes operations across multiple instances of the same agent type.
A key challenge in JAX is that arrays must have identical shapes, which usually makes simulating heterogeneous agents (with different observation and action spaces) highly inefficient due to required padding. JaxMARL-HFT elegantly solves this by running a standard Python outer loop over distinct agent types (e.g., Market Makers vs. Order Executioners), while maintaining high-efficiency vmap vectorization within each type.
For training, the authors extended the Independent Proximal Policy Optimization (IPPO) algorithm to natively support these heterogeneous agent populations.
Datasets
The environment is trained and evaluated using a massive, real-world financial dataset: one full year of LOBSTER market-by-order data for Amazon (AMZN) from 2024, comprising roughly 400 million orders.
To make this feasible on standard hardware, the authors optimized memory management by loading the entire dataset contiguously into GPU memory and tracking episode start indices at runtime. This optimization allows a full year of granular HFT data to occupy just 4GB of GPU memory.
Key Insights and Ideas
- Bypassing the JAX Uniformity Constraint: The hybrid parallelization approach (outer loop for agent types, inner
vmapfor agent instances) provides a blueprint for building highly flexible, heterogeneous MARL environments without sacrificing GPU performance. - The "Never Trade" Trap: The authors observed that under standard reward formulations (like the Spooner or BuySell rewards), market-making agents often learn to trade very infrequently to avoid inventory risk. This highlights a fundamental challenge in financial ML: reward functions must be carefully normalized by traded volume to prevent agents from converging on trivial, risk-averse behaviors.
- Co-learning Reveals Market Impact: When agents are trained concurrently, an execution agent's performance degrades when facing a smarter, learned market-making opponent compared to a static baseline. This underscores why single-agent RL is insufficient for financial modeling—markets are inherently adversarial.
Key Results
- Up to 240x Speedup: In end-to-end MARL training loops, JaxMARL-HFT achieved a 200x to 240x speed improvement over CPU-based MARL setups as the number of learning agents scaled.
- Throughput Scaling: Even when processing 100 LOB messages per RL step, the framework achieved tens of thousands of steps per second, vastly outperforming existing toolkits like ABIDES-gym and PyMarketSim.
- Benchmark Outperformance: The learned agents successfully outperformed classic financial baselines. The execution agent reduced transaction slippage costs by up to 20% of a tick compared to a standard Time-Weighted Average Price (TWAP) strategy, while the market maker outperformed the traditional Avellaneda-Stoikov optimal control model.
Limitations and Future Work
While a major leap forward, the authors note a few limitations in the current design:
- Order Cancellation Artifacts: Currently, unmatched orders from previous steps are automatically cancelled at each RL step. In a real price-time priority queue, this penalizes the agent, an issue the authors plan to address in future environment iterations.
- Simplified Action Spaces: To maintain training stability in a notoriously low signal-to-noise ratio environment, the action spaces were heavily discretized. Scaling this to continuous, general-purpose action spaces remains an open problem.
- Generative Market Replays: Future work includes replacing historical data streams with generative AI models to simulate entirely synthetic, yet realistic, interactive market participants.
Summary updated