Beyond Point Estimates
Generative AI isn't just for image generation. We recently experimented with using Denoising Diffusion Probabilistic Models (DDPMs) to generate future price trajectories for algorithmic trading.
Traditional models like LSTMs or Transformers output a single point estimate (or a simple Gaussian distribution). A diffusion model, however, generates a highly complex, non-Gaussian distribution of possible future paths by learning to reverse a noise-adding process.
The Implementation
We trained a conditional 1D U-Net architecture on a massive Kaggle limit order book dataset. We condition the reverse diffusion process on the past 60 minutes of price action and volume profiles.
import torch.nn as nn
class ConditionalUNet1D(nn.Module):
def __init__(self):
super().__init__()
# 1D convolutions for time-series data
self.inc = DoubleConv1D(1, 64)
self.down1 = Down1D(64, 128)
# Condition embedding layers for historical price context
self.cond_emb = nn.Linear(context_dim, 128)
# ...The inference is slow because we have to run 50 denoising steps per prediction. However, generating 100 parallel samples gives us a built-in, incredibly well-calibrated confidence interval. If the generated trajectories diverge wildly, our execution engine knows to reduce position sizing due to high uncertainty.