pub struct EnhancedRouter { /* private fields */ }Expand description
Enhanced Strategy Router
Manages per-asset regime detectors and emits strategy recommendations based on detected market conditions.
§Example
use indicators::{EnhancedRouter, EnhancedRouterConfig, ActiveStrategy};
let mut router = EnhancedRouter::with_ensemble();
router.register_asset("BTC/USD");
// Feed OHLC data
for i in 0..300 {
let price = 50000.0 + i as f64 * 10.0;
if let Some(signal) = router.update("BTC/USD", price + 50.0, price - 50.0, price) {
if signal.strategy != ActiveStrategy::NoTrade {
println!("{}", signal);
}
}
}Implementations§
Source§impl EnhancedRouter
impl EnhancedRouter
Sourcepub fn new(config: EnhancedRouterConfig) -> Self
pub fn new(config: EnhancedRouterConfig) -> Self
Create with specific config
Sourcepub fn with_indicators() -> Self
pub fn with_indicators() -> Self
Create with indicator-based detection
Sourcepub fn with_ensemble() -> Self
pub fn with_ensemble() -> Self
Create with Ensemble detection (recommended)
Sourcepub fn register_asset(&mut self, symbol: &str)
pub fn register_asset(&mut self, symbol: &str)
Register an asset for tracking.
Creates the appropriate detector based on the configured detection method. If the asset is already registered, this is a no-op.
Sourcepub fn unregister_asset(&mut self, symbol: &str) -> bool
pub fn unregister_asset(&mut self, symbol: &str) -> bool
Unregister an asset, removing its state and detector
Sourcepub fn update(
&mut self,
symbol: &str,
high: f64,
low: f64,
close: f64,
) -> Option<RoutedSignal>
pub fn update( &mut self, symbol: &str, high: f64, low: f64, close: f64, ) -> Option<RoutedSignal>
Update with new OHLC data for an asset and get a routing signal.
If the asset isn’t registered, it will be auto-registered.
Returns None only if the detector fails internally (should not happen).
Sourcepub fn get_regime(&self, symbol: &str) -> Option<MarketRegime>
pub fn get_regime(&self, symbol: &str) -> Option<MarketRegime>
Get current regime for an asset
Sourcepub fn last_regime_confidence(&self, symbol: &str) -> Option<&RegimeConfidence>
pub fn last_regime_confidence(&self, symbol: &str) -> Option<&RegimeConfidence>
Get the most recent RegimeConfidence for an asset.
This contains the raw indicator values (ADX, BB width percentile,
trend strength) that produced the last regime classification.
Returns None if the asset hasn’t been updated yet.
Sourcepub fn atr_value(&self, symbol: &str) -> Option<f64>
pub fn atr_value(&self, symbol: &str) -> Option<f64>
Get the current ATR (Average True Range) value for an asset.
Delegates to the underlying detector regardless of detection method:
- Indicators →
RegimeDetector::atr_value() - HMM → not available (returns
None) - Ensemble → delegates to the embedded indicator detector
Returns None if the asset isn’t registered or the detector hasn’t
warmed up yet.
Sourcepub fn adx_value(&self, symbol: &str) -> Option<f64>
pub fn adx_value(&self, symbol: &str) -> Option<f64>
Get the current ADX (Average Directional Index) value for an asset.
Delegates to the underlying detector regardless of detection method:
- Indicators →
RegimeDetector::adx_value() - HMM → not available (returns
None) - Ensemble → delegates to the embedded indicator detector
Returns None if the asset isn’t registered or the detector hasn’t
warmed up yet.
Sourcepub fn get_strategy(&self, symbol: &str) -> Option<ActiveStrategy>
pub fn get_strategy(&self, symbol: &str) -> Option<ActiveStrategy>
Get current recommended strategy for an asset
Sourcepub fn detection_method(&self) -> DetectionMethod
pub fn detection_method(&self) -> DetectionMethod
Get detection method being used
Sourcepub fn regime_changes(&self, symbol: &str) -> u32
pub fn regime_changes(&self, symbol: &str) -> u32
Get regime change count for an asset
Sourcepub fn registered_assets(&self) -> Vec<&str>
pub fn registered_assets(&self) -> Vec<&str>
Get all registered asset symbols
Sourcepub fn config(&self) -> &EnhancedRouterConfig
pub fn config(&self) -> &EnhancedRouterConfig
Get the router configuration
Sourcepub fn summary(&self) -> Vec<AssetSummary>
pub fn summary(&self) -> Vec<AssetSummary>
Get a summary of all asset states