Module Algostream_pairs.Mean_reversion

Mean-reversion signal classifier + half-life estimator.

The classifier is a stateful band crossover over the spread z-score:

The half-life estimator runs OLS of Δr_t on r_{t-1} with intercept: φ̂ = 1 + slope; half-life = -ln 2 / ln |φ̂|. Returns `Non_reverting if |φ̂| ≥ 1.

type signal =
  1. | Long_spread
  2. | Short_spread
  3. | Exit
  4. | Hold
type t
val create : entry_z:float -> exit_z:float -> stop_z:float -> t
val update : t -> z:float -> signal
val position : t -> [ `Flat | `Long | `Short ]
type half_life_error = [
  1. | `Insufficient_data of int * int
  2. | `Non_reverting
  3. | `Ols of Ols.error
]
val half_life : residuals:float array -> (float, half_life_error) Stdlib.result
type significance =
  1. | Significant of float
  2. | Marginal
  3. | Non_reverting
val significance : Adf.result -> significance
val signal_to_string : signal -> string