Autoregressive Diffusion for Market Data Generation
Summary
Jane Street research indicates that while autoregressive diffusion can be used to generate synthetic market data, the process requires specific modifications to handle the "jaggedness" of financial time series. The primary takeaway is that market data exists as a hybrid of continuous values (like timing and price) and discrete actions (like order types), and standard diffusion models fail unless these discontinuities are managed via flow matching and a technique called "atom smoothing."
The Challenge of Market Data Modality
Market data is neither fully continuous nor fully discrete, creating a fundamental challenge for generative models. While an order book evolves through discrete actions—such as adding, canceling, or executing orders—the parameters of those actions often appear continuous.
Key complexities include:
- High Cardinality: Prices often have such high cardinality that they behave like continuous variables.
- Temporal Spikes: Event timing is not normally distributed; orders arrive in bursts or at whole-number intervals.
- Point Masses: "Pennying" (improving a price by a single tick) creates sharp spikes in the distribution of price changes, which standard continuous diffusion models struggle to represent.
Model Architecture and Setup
To address these challenges, the research utilized an encoder-diffuser architecture trained on four years of US equities data. The model aims to generate the next event in a stream (timestamp, price, event kind) and autoregressively append it to the sequence.
Architecture Components
- Encoder: A causally masked transformer encoder produces a latent embedding for each position in the sequence.
- Event-Kind Head: A categorical head that predicts whether the next event is a trade or a Best Bid and Offer (BBO) update.
- Diffusion Head: A head conditioned on the latent embedding and the true event-kind (using AdaLN conditioning) to generate continuous targets such as price and elapsed time.
During inference, the model samples an event from the categorical head and then uses that sampled event to condition the diffusion head for the continuous features.
Flow Matching vs. DDPM
Initial experiments using Denoising Diffusion Probabilistic Models (DDPM) proved unstable. The researchers found that DDPMs, which predict the noise added to a sample, often led to exploding denoising trajectories where 88-95% of values diverged beyond eight standard deviations from the mean.
This instability is attributed to the scaling of the noise prediction ($\epsilon$) when calculating the clean target estimate. To resolve this, the research shifted to flow matching (specifically rectified flows). Flow matching interpolates linearly between noise and data and predicts the velocity along that line, resulting in nearly straight sampled trajectories that can be integrated accurately in fewer steps and exhibit significantly higher stability out-of-the-box.
Handling Discontinuities with Atom Smoothing
Because market data contains sharp boundaries and point masses (e.g., many events arriving simultaneously at zero seconds), the researchers experimented with two primary methods to handle discontinuities:
1. Categorical Fracturing
To reduce the imbalance in categorical predictions (where BBO changes vastly outnumber trades), the researchers broke BBO changes into more granular classes (e.g., "size only" or "ask up"). This allowed them to treat certain discontinuities—like an elapsed time of zero—as their own categorical class, simplifying the targets for the diffusion head.
2. Atom Smoothing
To avoid the unscalable nature of creating a categorical class for every possible discontinuity, the research introduced "atom smoothing." This process involves smoothing out the true spiky distribution and then "re-sculpting" the spike to capture the probability mass without creating a mathematical discontinuity that would break the diffusion process.
Results and Evaluation
Performance was evaluated by comparing the marginal distribution of the model's output against true market data using Total Variational (TV) divergence.
Key Findings
- Marginal Alignment: The combination of flow matching and atom smoothing produced realistic marginal distributions for both event-kinds and continuous targets.
- Discriminator Testing: A classifier trained to distinguish between real and synthetic events found that samples optimized for atom smoothing were significantly more realistic.
- Autoregressive Rollouts: The model can produce synthetic sequences of market events, though accuracy degrades over time. For example, in synthetic rollouts of CME US data, the bid-ask spread tends to widen as the prediction horizon increases.
Community Insights and Counterpoints
Discussion among practitioners highlighted several theoretical and practical hurdles to this approach:
"There is no model of the market that can remain stably accurate because the market will inevitably incorporate the insights of any model that is accurate until those insights are no longer accurate."
Other technical observations included the suggestion that latent diffusion—using a specialized decoder trained like a GAN—might have further mitigated the pixel-level (or event-level) errors encountered during the project. Additionally, some noted that order inter-arrival times likely follow a Hawkes process (where one event increases the probability of others) rather than a normal distribution, which explains the "clumpy" nature of the data described in the research.
Sources
Related
- Dispatch
- Dispatch
- Dispatch
- Dispatch
- Dispatch