Module Algostream_pairs.Hedge_ratio

β estimator for the spread regression y ≈ β·x + α.

Three modes (selected via Config.beta_mode):

If Rolling_var(x) < 1e-12 (a flat regressor), β is held at its previous value and beta_frozen_ticks increments — avoids divide-by-near-zero blow-ups in calm regimes.

type t
val create : Config.t -> t
val update : t -> x:float -> y:float -> float * float

Returns the updated (beta, intercept) after observing one paired sample.

val beta : t -> float
val intercept : t -> float
val beta_stdev : t -> float

Trailing standard deviation of β across the most recent beta_window/4 updates. Used by Selection to screen out pairs with an unstable hedge ratio.

val n_updates : t -> int
val beta_frozen_ticks : t -> int
val ready : t -> bool