JAX-LOB: A GPU-Accelerated limit order book simulator to unlock large scale reinforcement learning for trading

—

JAX-LOB: A GPU-Accelerated limit order book simulator to unlock large scale reinforcement learning for trading

Sascha Frey
Kang Li
Peer Nagy
Silvia Sapora
Chris Lu
Stefan Zohren
Jakob Foerster
Anisoara Calinescu
Published on 8/25/2023
Equities
Derivatives
High frequency trading
Reinforcement learning
Machine learning
AI

This paper introduces JAX-LOB, the first GPU-accelerated limit order book simulator built using JAX, designed to enable large-scale reinforcement learning for trading. The simulator addresses the low signal-to-noise ratio and overfitting issues in high-frequency trading by massively parallelizing order book processing across thousands of books on a single GPU. Key design decisions include using fixed-size arrays for order storage, avoiding continuous sorting, and leveraging JAX's vmap operator to parallelize message processing, which transforms conditional branches into select statements that execute all branches at runtime. The simulator supports limit orders, cancellations, and market orders with price-time priority matching, and can replay historical data from sources like LOBSTER.

The authors integrate JAX-LOB with the gymnax RL framework and PureJaxRL to create an end-to-end GPU-based training pipeline for optimal trade execution. The execution environment features a continuous action space with four price levels (far touch, mid-price, near touch, passive) and an observation space including intra-step L1 data, time, and execution progress. Using recurrent PPO, they demonstrate a 7x speedup in training (550 vs 74 steps per second) compared to CPU-based simulators on the same hardware. The work also provides detailed benchmarks of basic operations (add, cancel, match) and message processing times, showing that vmap eliminates runtime variance across message types. JAX-LOB is open-sourced and promises to unlock new research in agent-based models, generative models, and RL for trading by enabling massive parallel simulation and potentially differentiable LOB models for calibration.

Highlights

  • 1First GPU-accelerated limit order book simulator using JAX, enabling massive parallelization across thousands of books.
  • 2At least 7x speedup in reinforcement learning training compared to CPU-based LOB simulators (550 vs 74 steps per second).
  • 3Integration with JAX-native RL frameworks (gymnax, PureJaxRL) for end-to-end GPU training without CPU-GPU bottlenecks.
  • 4Design choices to overcome JAX constraints (fixed arrays, pure functions) while maintaining realistic LOB mechanics.

Methods

  • M
    Array-based order book representation with fixed-size arrays for ask and bid sides, avoiding tree structures and continuous sorting.
  • M
    JAX vmap operator for parallel processing of multiple order books, transforming control-flow into select statements.
  • M
    Recurrent Proximal Policy Optimization (PPO) for training an optimal execution agent in a gymnax environment.
  • M
    Market replay using LOBSTER data with pre-loaded fixed-size time windows and variable episode lengths.

Results

  • R
    Per-message processing time of 2.6 microseconds for limit, cancel, and cross orders when parallelizing 1000 books on GPU.
  • R
    Matching operation time increases with order size: from 0.206 ms (Q=10) to 2.326 ms (Q=10,000) for N=100 capacity.
  • R
    RL training speedup of 7x: 550 steps per second on GPU vs 74 steps per second on CPU for the same hardware.
  • R
    vmap eliminates runtime variance across message types, with processing time depending only on book capacity.
0/5

Analyze Paper

Generate insights from "JAX-LOB: A GPU-Accelerated limit order book simulator to unl...".

Suggested Actions