Skip to main content

detect_regime

Function detect_regime 

Source
pub fn detect_regime(
    regime_rules: &[RegimeRule],
    default_regime: &str,
    indicators: &TechnicalIndicators,
    current_state: &mut RegimeState,
    hysteresis: &HysteresisConfig,
    now: u64,
) -> String
Expand description

Detect current market regime based on regime rules, with hysteresis.

Hysteresis logic:

  1. If current regime held < min_hold_secs -> ignore new regime signals
  2. If pending_switch exists and target matches -> confirmation_count += 1
  3. If confirmation_count >= hysteresis.confirmation_count -> switch
  4. Else record pending_switch, wait for next confirmation