Regime-Switching Relative-Value Arbitrage with Mean and Volatility Bands
Summary
This module implements a relative-value trading rule built around a two-state Markov regime-switching model. It fits the model to a univariate time series, identifies the current high-mean or low-mean regime, and uses the estimated regime mean and standard deviation to set entry and exit bands. A sensitivity parameter controls the distance from the mean, while a probability threshold conditions selected trades on confidence in the inferred regime. The default rules vary by regime and direction, and can be replaced with custom conditions.
The code also applies the model over rolling windows, converts Boolean signals into position-aware long and short actions, and plots trades. It returns no-trade signals when fitting fails. The implementation describes signal generation rather than a complete evaluation: it does not provide performance results, transaction costs, or safeguards against estimation and execution risks. In particular, the use of smoothed regime probabilities should be reviewed in any historical simulation to ensure that information unavailable at the decision time is not used.
Key ideas
- The strategy uses a two-regime Markov model to estimate the current state of a time series.
- Entry and exit signals compare observations with regime-specific mean and volatility bands.
- A probability threshold can condition trading signals on the estimated regime probability.
- Rolling fitting, position-aware trade actions, and plotting are included in the implementation.
- The module gives no performance evidence, and smoothed probabilities require care in historical simulations.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.