Deep learning in finance.
Neural networks are not a magic answer in finance - they are a magic answer to the moments when you can put real structure into the architecture or the loss. This page collects an entire graduate course built on that principle: an autoencoder that learns market structure well enough to flag crises, a CNN that reads the roughness of a path better than the textbook statistic, pricing networks taught no-arbitrage, and the sequence and generative models that round out the toolbox.
Compressing the market: autoencoders
An autoencoder squeezed through a -dimensional bottleneck is forced to learn whatever structure lets it reconstruct its input cheaply. Feed it the daily cross-section of returns across many assets, and that structure is exactly what a risk model wants: a handful of latent factors (market, sectors) that explain most of the co-movement. Three uses fall out of the same trained network:
Categorisation. With a 2-D bottleneck the latent codes cluster sector-like groups with no labels at all - the network rediscovers "tech" and "energy" purely from correlated returns. Market states. Encode whole days instead of single stocks, and the bottleneck separates calm regimes from stressed ones. Anomaly detection. The reconstruction error is a built-in surprise detector: a day the network cannot reconstruct well is a day that broke the usual factor structure.
The figure below is that last use case, trained from scratch in your browser: 16 synthetic assets driven by two factors, standardised, with three crisis days secretly injected (a common shock plus an idiosyncratic vol burst). A tiny autoencoder with a bottleneck trains by full-batch gradient descent on the reconstruction MSE. Watch the loss fall and the error bars separate: the injected crises (marked ▲) climb to the top of the daily reconstruction-error ranking without ever being labelled as special.
Try : a single latent factor cannot represent the underlying two-factor structure, so the overall training loss settles visibly higher. Push up to 4-6 and the network fits the calm days markedly better. The crisis days in this demo are injected loudly enough to dominate the ranking regardless of ; in a real cross-section the margin is nowhere near as generous, which is exactly why picking matters in practice - too small underfits the calm-day structure, too large and the network memorises noise instead of factors.
How rough is a price path? CNNs vs the textbook
A narrower question with a famous answer: how rough is a given path? Fractional Brownian motion compresses the memory of a path into one number, the Hurst exponent :
is ordinary Brownian motion, is persistent and trending, is anti-persistent and jagged. The empirical bombshell of the last decade (Gatheral-Jaisson-Rosenbaum) is that realised volatility itself is rough, - which is what bends the short-maturity smile that classical stochastic-vol models cannot reproduce.
Estimating from a short sample is the hard part. The figure below generates exact fBm (Hosking's recursion) and applies the classical variance-scaling estimator: regress on , slope . Re-roll a few paths at fixed and watch wobble and bias up near the edges - fragile exactly in the rough regime that matters.
The CNN estimator
The course's answer: generate thousands of fBm paths across a grid of values, standardise them, and train networks to read straight off the path. A dense network already competes with the classical statistic; a 1-D CNN - whose convolution filters see local increment patterns directly - beats both in bias and mean absolute error across the whole range, and stays robust near where variance-scaling degrades. It is a clean case of learning a statistic that is awkward to write down by hand: the estimator exists, the network just finds a better one.
Teaching a network no-arbitrage
Third project: learn the pricing map from market option quotes. A feed-forward network trained on quotes learns well inside the data cloud - but nothing stops it from pricing a call and a put that violate put-call parity with each other. The fix is a joint loss over both heads with a parity penalty:
Three findings from the lab. Feeding implied volatility as an input feature (rather than asking the network to rediscover it from moneyness and maturity) does most of the heavy lifting. The parity penalty regularises the learned surface and speeds up convergence. And the honest metric is not MSE but the fraction of predictions landing inside the market bid-ask spread - which the parity-constrained network wins.
Sequence models and generative models
The rest of the course rounds out the toolbox with three exercises:
LSTM return prediction. Stacked LSTMs trained to predict the sign of next-day returns, evaluated honestly against the roughly 52% accuracy that is actually attainable on daily equity data - a useful antidote to overclaiming accuracy on a near-efficient market.
Sharpe-loss portfolios. Instead of forecasting returns and then optimising a portfolio on top, a network trained with the Sharpe ratio itself as the loss function - differentiating straight through the portfolio construction step, so the network never has to get an intermediate return forecast right, only the final risk-adjusted P&L.
GANs for synthetic markets. Generator/discriminator pairs (an MLP conditional GAN and a relativistic GAN with a Gaussian-mixture discriminator loss) trained to produce synthetic univariate return paths indistinguishable from real ones - heavy tails, volatility clustering, all reproduced without hand-coding a single stylised fact. The natural use is stress-testing a strategy on markets that never happened but statistically could have.