Skip to main content
Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
What is this? Some markets move before others. Lead-lag detection finds these relationships - for example, a Polymarket contract that consistently reacts to news 30 seconds before a Kalshi contract on the same event. Use it to build cross-market signals or identify which feeds to watch for early information.

Lead-Lag Networks

Horizon provides Rust-native tools for detecting which prediction markets lead or lag others. These relationships are fundamental to cross-market arbitrage, informed order routing, and signal extraction from related markets.

Hayashi-Yoshida

Asynchronous tick-by-tick correlation that handles irregular timestamps without synchronization bias.

Cross-Correlation

Multi-lag cross-correlation analysis to identify optimal lead/lag offsets.

Granger Causality

Statistical test for whether past values of one market predict another.

Lead-Lag Network

Build a directed network of lead-lag relationships across many markets.

hz.hayashi_yoshida

Compute the Hayashi-Yoshida estimator for asynchronous correlation between two tick streams. Unlike standard Pearson correlation, this does not require synchronized timestamps and avoids the Epps effect (correlation attenuation from data aggregation).

LeadLagResult Type


hz.cross_correlation_lags

Compute cross-correlation between two synchronized series at multiple lags to identify the optimal lead-lag offset.

Cross-Correlation Result Type

A positive best_lag means series_x leads series_y by that many observations. A negative best_lag means series_y leads series_x.

hz.granger_causality

Test whether past values of series X help predict series Y beyond what series Y’s own past values provide. Uses an F-test on a bivariate VAR model.

GrangerResult Type


hz.lead_lag_network

Build a directed network of lead-lag relationships across multiple markets. Computes pairwise Hayashi-Yoshida correlations at multiple lags and constructs a graph where edges point from leaders to followers.

LeadLagNetwork Type

GraphNode Type

GraphEdge Type


Pipeline Integration

hz.lead_lag_detector

Creates a pipeline function that tracks lead-lag relationships between feeds and injects leadership scores into ctx.params.

Mathematical Background

The HY estimator computes the realized covariance between two asynchronously observed processes. For each pair of return intervals that overlap in time, it accumulates the product of the returns. This avoids synchronization (e.g., previous-tick interpolation) which attenuates correlation at high frequencies (the Epps effect).HY_cov = sum over overlapping intervals (delta_X_i * delta_Y_j)
X Granger-causes Y if past values of X improve the prediction of Y beyond what past values of Y alone provide. The test compares two VAR regressions:
  • Restricted: Y_t = c + sum(a_i * Y_{t-i})
  • Unrestricted: Y_t = c + sum(a_i * Y_{t-i}) + sum(b_i * X_{t-i})
An F-test on the incremental explanatory power of X determines significance.
In prediction markets, lead-lag relationships arise because:
  1. Correlated events: Related markets (e.g., presidency and Senate) share underlying information
  2. Liquidity differences: More liquid markets incorporate information faster
  3. Attention asymmetry: High-profile markets attract faster traders
Detecting these relationships enables cross-market signal extraction and early positioning.