Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
Spread Convergence
Track the price spread between two correlated markets. Enter when the spread deviates beyond a z-score threshold, exit when it reverts to the mean.How It Works
- Compute
spread = price_a - price_beach cycle - Maintain a rolling window of spread values
- Compute z-score of current spread vs historical mean/std
- Enter when
|z| > entry_zscore, exit when|z| < exit_zscore
Pipeline: spread_convergence
SpreadSignal
Stored inctx.params["last_spread_signal"].
Signal Logic
Example
For more rigorous pairs trading with cointegration testing and half-life filtering, see Statistical Arb.