Quant Memo
Core

Online Learning and Regret Bounds

An online learner updates itself one observation at a time, forever, rather than training once on a fixed batch — and instead of asking "how accurate is it," the theory asks "how much worse did it do, in total, than the best fixed strategy in hindsight."

Prerequisites: Gradient Descent, Stochastic Gradient Descent

Most machine-learning training happens once, on a fixed batch of historical data, and then the model is frozen and deployed. Online learning instead updates the model after every single new observation, forever — a market-making quote model that revises itself after every fill, or a spread-prediction model that adjusts after every tick. There's no "training set" and "test set" in the usual sense; there's just a stream, and the question becomes how to measure whether the ongoing stream of decisions was any good.

Online learning theory scores an algorithm by its regret: the total gap between the loss it actually accumulated and the loss the single best fixed strategy, chosen with hindsight, would have accumulated over that same stream. A good online algorithm has regret that grows slower than the number of rounds — its average per-round disadvantage shrinks toward zero even though it never got to see the future.

What "regret" actually measures

After TT rounds, define regret as RT=t=1Tt(θt)minθt=1Tt(θ)R_T = \sum_{t=1}^{T} \ell_t(\theta_t) - \min_{\theta} \sum_{t=1}^{T} \ell_t(\theta), where t\ell_t is the loss suffered in round tt, θt\theta_t is the parameter the algorithm actually used at round tt, and θ\theta ranges over every fixed parameter choice you could have committed to from the start. In words: add up how much loss the algorithm actually incurred, subtract how much loss the single best strategy in hindsight would have incurred over that entire stretch, and the difference is regret. A standard result for online gradient descent on convex losses is RT=O(T)R_T = O(\sqrt{T}) — regret grows, but slower than TT itself, so average regret per round, RT/TR_T / T, shrinks toward zero as more rounds accumulate.

rounds (T) cumulative loss best fixed strategy online learner, regret O(√T) bad algorithm, regret O(T)
A good online learner's gap to the best fixed strategy widens more slowly than time itself — its per-round disadvantage vanishes.

Worked example

A spread-quoting model updates its bid-ask width after every trade using online gradient descent, and over T=10,000T = 10{,}000 trades its regret bound guarantees RTcT=c×100R_T \le c\sqrt{T} = c \times 100 for some constant cc tied to the loss's smoothness. Suppose c=2c = 2, so RT200R_T \le 200 — the model's cumulative loss across all 10,000 trades is at most 200 loss-units worse than the single best fixed spread width chosen with full hindsight of every trade that would occur. That may sound unimpressive in absolute terms, but per-trade it's an average disadvantage of at most 200/10,000=0.02200/10{,}000 = 0.02 loss-units — and if the stream ran to 1,000,000 trades instead, the bound only grows to 100×\sqrt{100}\times larger (2,0002{,}000), while the number of trades grew 100×100\times, so the average disadvantage per trade falls to 0.0020.002: the online learner is closing in on hindsight-optimal performance as it sees more data, without ever needing to re-solve from scratch.

What this means in practice

Online learning fits any setting where the environment keeps changing and a batch-trained model would go stale — adaptive market-making, real-time fraud scoring, order-routing that adjusts to shifting venue liquidity. Regret bounds are a guarantee about the worst case over the sequence actually observed, not a promise about future accuracy in some absolute sense, and they typically assume the loss functions are convex; regret bounds for the non-convex losses that show up with neural networks are much weaker or unavailable.

A sublinear regret bound compares only against a single fixed strategy in hindsight — it says nothing about how a strategy that itself changes over time (like a strategy that adapts to a regime shift) would have done. Beating "the best constant spread over 10,000 trades" is a much lower bar than beating "the best possible adaptive strategy," so don't over-read a good regret bound as proof the algorithm is close to optimal in any absolute sense.

Related concepts

Practice in interviews

Further reading

  • Cesa-Bianchi & Lugosi, Prediction, Learning, and Games (2006)
  • Hazan, Introduction to Online Convex Optimization (2016)
ShareTwitterLinkedIn