Building a Z-Score Pairs Trade with Staged Entries and Exits
Summary
This article walks through implementing a price-spread pairs trade in Zorro using GDX and GLD as an example. It defines the spread as one asset’s price minus a hedge-ratio-adjusted price of the other, then standardises the spread with a rolling z-score. The trading rules add positions in stages when the z-score crosses increasingly distant positive or negative levels, with orders on both assets sized according to the chosen hedge ratio. Positions are reduced as the z-score moves back toward the centre and closed when it crosses zero.
The article provides example implementation logic and identifies parameters to explore, including the z-score window, spacing between entry levels, hedge ratio, simulation period, and asset pair. It does not present performance results or establish that the example pair has a stable relationship. The fixed hedge ratio and price-based spread are simplifying choices; readers are encouraged to test alternatives and assess transaction costs rather than assume mean reversion will hold.
Key ideas
- A price spread can be formed by subtracting a hedge-ratio-adjusted asset price from another asset’s price.
- A rolling z-score provides a standardised measure for spread-based entry and exit rules.
- Staged entries and partial exits let exposure change as the spread moves farther from or back toward its centre.
- The hedge ratio, z-score window, entry spacing, and selected assets all require testing.
- The example does not establish that the chosen pair is cointegrated or profitable.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.