← All work
06 · In progress

Spatio-temporal forecasting for equity markets

In one line

Forecasting stock returns as a spatio-temporal problem, with the market’s own structure built into the model instead of left for it to learn.

Type
Independent research
Period
Sep 2026 – present
Builds on
MASTER (AAAI 2024)
Stack
PyTorch
01

The problem

A market is a spatio-temporal system: hundreds of return series, linked through relationships that shift over time. Most of what moves any one stock is shared with others, the market as a whole, its sector, its suppliers. Forecasting well means separating that shared structure from what is specific to one company.

Most recent models learn the structure from scratch. This research asks where it actually lives, and builds what finance already knows about it into the model: how correlation matrices behave, what the market factor is, which data existed at each point in time.

02

Two kinds of structure

Structure over time and structure across stocks are different axes, and methods that sound alike often work on different ones.

  • Across time. Wavelets split each stock’s series into frequency bands. The filters can be learned in training, as STEAM’s are, but once trained they’re the same for every input.
  • Across stocks. The eigenvectors of the stock-to-stock correlation matrix, or of a graph over stocks, give a basis that changes when the market’s structure changes. Spectral graph methods such as Specformer work here.

Both get called spectral. They’re orthogonal, and a model can use both.

The graph over stocks can come from three places: given in advance (GAT), learned once and then fixed (MTGNN), or recomputed at every step (MASTER). The last adapts best but is dense, every stock attending to every other, at a cost that grows with the square of the number of stocks.

03

Starting point

MASTER splits the problem along the two axes this research cares about. Within each stock, attention runs across its own time steps. Across stocks, attention runs at every time step. Earlier models estimated how stocks relate from a whole window at once, which only captures an average relationship. Running cross-stock attention at every step catches relationships that exist only at a particular moment, and alternating the two axes lets one stock’s past reach another stock’s present. On top of that, a vector describing the market’s state gates which features the model pays attention to.

04

What I’m testing

Do stocks relate differently at different time scales? Two stocks can move together week to week while ignoring each other day to day. Splitting each series into frequency bands with a wavelet transform that uses only past data, then running MASTER’s cross-stock attention separately within each band, tests that directly. The experiments are ordered so the cheap explanation is ruled out first.

  1. 1MASTER on Korean data, as the baseline.
  2. 2Plus rolling features over windows matched to the same time scales. If this does as well as the wavelet version, the gain was just more history.
  3. 3Plus wavelet band features, with cross-stock attention unchanged.
  4. 4Plus cross-stock attention within each band. This is the core hypothesis.
  5. 5Plus interaction between bands, then a basis conditioned on the state of the market.

Alongside it, four questions from the spectral side:

  • Two ways of computing the same thing. MASTER’s market vector is built by hand from 63 index price and volume statistics. The largest eigenmode of the stock correlation matrix is, by definition, the market factor. Comparing the two directly is the cleanest experiment available.
  • A bottleneck with a principled size. Crossformer replaces all-to-all attention with a small number of learned routers that gather from every series and redistribute. How many routers is normally a tuned hyperparameter. Random matrix theory suggests an answer: the number of eigenvalues above the Marchenko–Pastur edge, the point past which a correlation matrix’s eigenvalues stop being noise.
  • Learned eigenvalue cleaning. Cleaning a correlation matrix by clipping its noisy eigenvalues depends on the whole spectrum, since where the noise ends depends on all of it. Specformer’s filter looks at the full set of eigenvalues at once, which makes it a learnable generalization of clipping. The design starts it at the Marchenko–Pastur edge and lets it learn from there.
  • How finely to select inputs. MASTER applies one gate across its features; the Temporal Fusion Transformer selects per variable and per time step. Whether the finer granularity helps is testable.
One correctionThe Marchenko–Pastur argument doesn’t apply to attention weights directly, because they aren’t a sample covariance. It applies to correlation estimates fed into the model as priors, and to labels built from returns with the top eigenmodes removed.
05

What reading closely turned up

Wavelets make leakage easy. Decomposing a whole series at once lets each point’s features depend on values that come after it. Before relying on wavelets, I measured how much that matters. On 300 pure random walks, where the future is unpredictable by construction, a trend read from a full-sample decomposition predicted next-day returns with an information coefficient of 0.273 (t ≈ 136). The same decomposition computed from past data only scored −0.002. Every decomposition in this research uses past data only.

Reading STEAM closely turned up three things that shaped the design.

  • Its wavelet transform pads each 30-day window circularly, as if the window wrapped around. The most recent day sits at that boundary, so the coefficients the forecast depends on most are built partly from the window’s oldest values.
  • It compresses cross-stock interaction with a linear layer over a fixed list of stocks. The model is tied to the universe and ordering it was trained on, and can’t take a newly listed stock.
  • Its headline gains rest on thin evaluation. Almost all of the Sharpe improvement comes from one index; each market is tested on a single year, where a Sharpe ratio’s standard error is about 1.0; and two of its five datasets overlap, so they can’t be averaged as independent samples.

The useful ideas, splitting by frequency and passing cross-stock interaction through a few tokens, carry over without those constraints: a past-only decomposition, and compression that doesn’t depend on which stocks are in the universe. A test on stocks absent from training checks the second directly.

06

Validation, decided first

  1. 1Synthetic data from a known data-generating process, with a planted signal the model has to recover.
  2. 2Walk-forward testing on chronological splits, with purging and an embargo around each boundary, combinatorial purged cross-validation, and the probability of backtest overfitting measured rather than assumed, following López de Prado.
  3. 3A final holdout, touched once.

Random train and test splits are ruled out. On financial time series they leak the future into training.

07

Two versions

The version written up as a paper and the version that runs inside Eureka will differ in structure. The Eureka version has to decide at fixed times each morning on whatever data has arrived, carries Korean market specifics, and feeds a trading layer. Neither is settled.

08

Reading

Grouped by what each contributes here, not by publication.

Relations between stocks

  • GAT. Attention over the edges of a graph that’s already given. It re-weights neighbours but can’t create an edge, which makes it the baseline for “the structure is known.”
  • MASTER. Two axes, alternated: attention within each stock across time, then across stocks at every time step, so it catches relationships that exist only at a moment or run from one stock’s past to another’s present. A market-state gate selects features on top.

Learning the graph, and graphs that change

  • MTGNN. Learns a directed graph from node embeddings and keeps only each node’s top-k edges. The graph is fixed once learned, but the explicit sparsity is exactly what MASTER lacks, and MASTER’s own attention maps suggest little would be lost by adding it.
  • TGN. For relationships that arrive as events: each node keeps a memory updated as events come in. Fits links that appear as disclosures or contracts rather than as correlations.
  • MST-GAT. Separate attention within one kind of series and across kinds, over a learned graph, built for anomaly detection. The within-and-across split maps onto Korean stocks, their overseas peers and macro series sitting in one model.

Dependencies across variables

  • Crossformer. Attention in two stages, across time and then across variables. The second stage passes everything through a small set of routers instead of all-to-all, which is where the router-count hypothesis comes from.
  • TFT. Selects variables separately at every time step, encodes static attributes, and outputs quantiles over several horizons. Its fine-grained selection is the comparison point for MASTER’s single gate.

Spectral structure

  • Specformer. Encodes the full set of a graph’s eigenvalues and runs attention over them, so the filter applied to one eigenvalue depends on all the others. That’s what makes it a learnable form of eigenvalue clipping.
  • Bun, Bouchaud and Potters. The Marchenko–Pastur law and how to clean large correlation matrices: where the noise in a spectrum ends and the signal begins.

State-space models for markets

  • STEAM. Splits each stock’s 30-day series into frequency bands with a learnable wavelet transform, treats every stock-and-band pair as a token, and runs cross-stock attention through a small set of relay tokens, with the market index added as an extra token. That block replaces the convolution inside a Mamba-2 layer, so cross-stock mixing and the temporal state-space model share one block.
  • FinMamba. Builds a correlation graph between stocks, prunes it by a sparsity level set from market indices, and feeds state-space blocks at several time scales. Its market-driven pruning is a learned answer to a question random matrix theory answers directly: which correlations are noise.

iTransformer is deliberately off the list. It changes which axis attention runs over, which MASTER already does.

09

Limits

  • Nothing has been trained yet. These are hypotheses, not results.
  • MASTER’s public benchmark is Chinese (CSI 300), while Eureka is Korean. Whether findings transfer between the two is a question of its own.
Read previousPower-system stability & oscillation predictionRead nextEureka