Pairs Residuals and Rolling Scores
The pairs monitor ranks synthetic price pairs by the size of their current standardized residual. Its construction makes both the shared price trend and the timing of the rolling calculation explicit.
A shared trend and a stationary residual
Leg \(B\) carries a stochastic trend. Leg \(A\) shares that trend through a fixed hedge ratio \(\beta\). Their log-price residual is
\[y_{j,t}=\log A_{j,t}-\alpha_j-\beta_j\log B_{j,t}.\]
The example generates that residual with a stationary AR(1) process:
\[y_{j,t}=\phi_j y_{j,t-1}+\sigma_j\eta_{j,t}.\]
The parameters are known by construction. Cointegration is supplied by the synthetic generator rather than established by a statistical test on observed securities.
A score computed from preceding observations
The displayed score uses the preceding 20 residuals:
\[z_{j,t}=\frac{y_{j,t}-\operatorname{mean}(y_{j,t-20:t-1})} {\operatorname{sd}(y_{j,t-20:t-1})}.\]
The current residual is scored before it enters the fixed-capacity window. Including it in its own reference distribution would change the score and its interpretation. The monitor emits neutral zero until the prior window has nonzero variance.
For a positive AR(1) coefficient below one, the model half-life is
\[h_j=\frac{\log(1/2)}{\log\phi_j}.\]
This is the decay time implied by the known generator. It is distinct from the trailing empirical standardization used by the score.
Ranking the pairs
The output contains current leg prices, spread_z, half_life and opportunity_rank, defined as a cross-sectional rank-z transform of absolute spread score. The table is sorted by absolute z-score.
A positive residual marks \(A\) rich relative to hedged \(B\); a negative residual reverses that relationship. A large absolute score identifies a large standardized dislocation. It does not establish that convergence will occur within a chosen holding period or after trading costs.
Run the monitor
cargo run -p hypercube-engine --example pairs
cargo run -q -p hypercube-engine --example pairs -- \
--pairs 24 --top 10 --ticks 1 --no-color
The example fixes \(\alpha\), \(\beta\) and \(\phi\) so the calculation can be inspected. A market study would need declared estimation windows, out-of-sample pair selection, stationarity and structural-break checks, borrow, transaction costs and exposure constraints.
Source and related material
This walkthrough is for research and educational purposes. It illustrates how strategynet.ai organizes signal evidence into factors and scenarios. It provides no recommendation, investment advice, or instruction to trade any security.
Back to Insights