Who moves with whom: the relationship graph and lead-lag
Sector labels are a blunt description of how stocks actually trade. Two companies in the same industry can drift apart for a year, and a stock in a completely different sector can be its closest companion on the tape. If you hedge, build pairs, size risk or try to anticipate how a shock will spread, you want the relationships as they are, not as a classification system says they should be.
EquationDB keeps that picture as a relationship graph. Every night it computes how the 500 largest US stocks and the reference ETFs move together, stores a snapshot, and lets you query it with GRAPH. This article covers what is in the graph, the five questions it answers, and how to use it without over-reading it.
What the graph contains
Each nightly snapshot holds, for every symbol in the top 500 plus the reference ETFs:
- 60-day and 250-day correlations of daily returns with every other symbol;
- betas against SPY over the same two windows, and volatilities;
- lead-lag links estimated from 5-minute returns: pairs where one stock's moves tend to show up in another's a few bars later.
The lead-lag estimate is deliberately conservative. For each symbol, EquationDB looks only at its eight most correlated peers (and only those with a 60-day correlation of at least 0.4). It then measures the cross-correlation of their 5-minute regular-session returns over the last ten sessions at lags of one to six bars, never across a session boundary. A link is kept only when one direction clearly beats the reverse direction. The result is a small set of links that are relatively robust, not a dense web of coincidences.
Snapshots are kept per session, so you can also ask what the graph looked like on an earlier date by adding ASOF and a date to any GRAPH query.
1. Who really trades with this stock?
GRAPH NEIGHBORS OF NVDA
NVIDIA's 15 most correlated stocks over 60 days, each with its 250-day correlation, its beta on NVIDIA and whether it shares NVIDIA's sector. Comparing corr_60d with corr_250d is the quickest way to see whether a relationship is new or long-standing.
VIA changes the ranking. corr (the default) and corr250 rank by correlation, beta by beta, and anticorr finds the most negatively correlated names, which are natural hedge candidates:
GRAPH NEIGHBORS OF XOM VIA anticorr LIMIT 10
These are the ten stocks that moved most opposite to Exxon over 60 days.
2. Who moves first?
GRAPH LEADERS OF AMD
This returns the symbols whose 5-minute returns tend to move before AMD's, with the lag in bars and in minutes, the correlation at that lag and the correlation on the same bar. GRAPH FOLLOWERS OF asks the reverse question: who tends to move after this stock.
Two cautions. The effects are small, and they are estimated over a short recent window, so treat a leader as a hint about information flow rather than a trading signal on its own. And lead-lag here is an intraday measure. For daily lead-lag inside a basket you choose, use the analysis instead:
ANALYZE lead_lag (AAPL, MSFT, NVDA)
That computes the cross-correlation of daily returns at lags −k to +k for every pair in the basket, so you can see who leads whom over a year of daily data.
3. Which stocks trade as one?
GRAPH CLUSTERS IN top500 MIN 0.75 LIMIT 10
Clusters are groups linked by chains of pairs whose 60-day correlation is at least MIN (single linkage). Each row gives the cluster's size, its average internal correlation, the dominant sector and the members.
Single linkage means every member has at least one partner above the threshold, not that every pair is that strongly correlated, so avg_corr_60d can be lower than MIN. Raise MIN for tight groups and lower it to see how sectors merge into larger blocks. Clusters that cut across sectors are often the most informative: they show where a common factor (rates, a commodity, a single large customer) is driving stocks that a sector map would separate.
4. If this stock falls 5%, what else moves?
GRAPH PROPAGATE NVDA -5% VIA beta DEPTH 2 LIMIT 20
PROPAGATE applies a hypothetical move to one symbol and follows the strongest paths through the graph, up to DEPTH hops (one by default, at most three), to estimate the move of each affected symbol. The result lists expected_move_pct, the 60-day correlation and the path the effect travelled.
This is a linear, correlation-based "what if", and it is labelled that way for a reason: real shocks change correlations, usually by pushing them towards one. Use it to see where your exposure is concentrated and which positions are really the same bet, not to forecast a crash.
5. When relationships break
The graph also produces events. Each night, EquationDB compares every stock's recent behavior with its longer history and records two kinds of change:
corr_break: a stock that normally tracks its sector ETF (a 250-day correlation of at least 0.6) has seen its 60-day correlation fall at least 0.35 below that level. Something specific to the company, such as news, an earnings surprise or a change in business mix, has started to dominate the sector factor.beta_shift: the 60-day beta differs from the 250-day beta by at least 0.6. The stock's sensitivity to the market has changed materially.
EVENTS CATEGORY relationship LAST 5d
They land in the event index like any other event, with a magnitude (the size of the change) and forward returns as they fill in, so you can list them, measure what followed with OUTCOMES and subscribe to them with WATCH. A corr_break in a stock you hedge with its sector ETF is exactly the kind of thing you want to hear about before the hedge stops working.
Putting it together
A typical workflow for a position:
GRAPH NEIGHBORS OFthe stock to find its true peers and check whether the relationships are stable (60-day versus 250-day).GRAPH NEIGHBORS OF … VIA anticorror a sector ETF for hedge candidates.GRAPH PROPAGATEto see what else in your book is effectively the same exposure.WATCHthe relationship events for the names you hold, so a broken correlation or a beta shift reaches you as a notification.
Limits worth knowing
- The graph covers the top 500 and the reference ETFs, rebuilt nightly after the daily bars are in.
- Correlations are of daily returns over 60 and 250 sessions. They describe the recent past, not a law.
- Lead-lag needs intraday bars and covers the last ten sessions.
GRAPHand relationship events are included in the Trial, Desk Plus and Enterprise plans.
The full syntax is on GRAPH. For basket-level statistics (correlation matrices, betas, pairs and daily lead-lag), see ANALYZE.