pub struct EnsembleRegimeDetector { /* private fields */ }Expand description
Ensemble regime detector combining indicator-based and HMM methods.
Feeds the same OHLC data to both detectors simultaneously and combines their outputs using weighted averaging with agreement bonuses/penalties.
§Example
use indicators::{EnsembleRegimeDetector, EnsembleConfig, RegimeConfig, MarketRegime};
let mut ensemble = EnsembleRegimeDetector::default_config();
// Feed OHLC bars
for i in 0..300 {
let price = 100.0 + i as f64 * 0.5;
let result = ensemble.update(price + 1.0, price - 1.0, price);
if ensemble.is_ready() {
println!("{}", result);
}
}Implementations§
Source§impl EnsembleRegimeDetector
impl EnsembleRegimeDetector
Sourcepub fn new(
ensemble_config: EnsembleConfig,
indicator_config: RegimeConfig,
) -> Self
pub fn new( ensemble_config: EnsembleConfig, indicator_config: RegimeConfig, ) -> Self
Create with specific configs for both the ensemble and the indicator detector
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create with default configs (indicator-weighted, crypto-optimized)
Sourcepub fn indicator_focused() -> Self
pub fn indicator_focused() -> Self
Create indicator-focused ensemble
Sourcepub fn hmm_focused() -> Self
pub fn hmm_focused() -> Self
Create HMM-focused ensemble
Sourcepub fn update(&mut self, high: f64, low: f64, close: f64) -> EnsembleResult
pub fn update(&mut self, high: f64, low: f64, close: f64) -> EnsembleResult
Update with new OHLC data and get the ensemble result.
Both detectors are updated with the same data. The ensemble then combines their outputs, adjusting confidence based on agreement.
Sourcepub fn current_regime(&self) -> MarketRegime
pub fn current_regime(&self) -> MarketRegime
Get current regime
Sourcepub fn agreement_rate(&self) -> f64
pub fn agreement_rate(&self) -> f64
Get agreement rate over recent history (0.0 to 1.0)
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Check if both detectors are ready.
When require_hmm_warmup is true, both must be ready.
Otherwise, only the indicator detector needs to be ready.
Sourcepub fn indicator_ready(&self) -> bool
pub fn indicator_ready(&self) -> bool
Check if only the indicator detector is ready (HMM may still be warming up)
Sourcepub fn hmm_state_probabilities(&self) -> &[f64]
pub fn hmm_state_probabilities(&self) -> &[f64]
Get HMM state probabilities
Sourcepub fn expected_regime_duration(&self) -> f64
pub fn expected_regime_duration(&self) -> f64
Get HMM expected regime duration
Sourcepub fn status(&self) -> EnsembleStatus
pub fn status(&self) -> EnsembleStatus
Get detailed status for monitoring
Sourcepub fn indicator_detector(&self) -> &RegimeDetector
pub fn indicator_detector(&self) -> &RegimeDetector
Get a reference to the underlying indicator detector
Sourcepub fn hmm_detector(&self) -> &HMMRegimeDetector
pub fn hmm_detector(&self) -> &HMMRegimeDetector
Get a reference to the underlying HMM detector
Sourcepub fn config(&self) -> &EnsembleConfig
pub fn config(&self) -> &EnsembleConfig
Get the ensemble configuration