Algostream_analytics.RegimeThreshold-based market regime detector.
Four states with asymmetric dwell-time hysteresis: Crisis is sticky on entry and slow to leave (false-negative on Crisis is much worse than false-positive on Calm). All time arithmetic is in event-time (i.e. tick.timestamp_ns), never wall-clock — required for deterministic replay.
val to_string : t -> stringval update :
detector ->
ts_ns:int64 ->
ewma_vol:float ->
vol_band_median:float ->
drawdown_from_peak:float ->
return_run_length:int ->
return_run_sign:int ->
tUpdate the detector with the latest tick observations. Returns the current regime AFTER any transition. Time fields are in event-time nanoseconds; pass tick.timestamp_ns from the incoming tick. Never read wall-clock time inside the analytics path — replay determinism requires it.
val dwell_ns : detector -> int64Nanoseconds spent in the current state, in event-time.
val transitions : detector -> intNumber of state transitions since detector creation.