Skip to main content

EnhancedRouter

Struct EnhancedRouter 

Source
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

Source

pub fn new(config: EnhancedRouterConfig) -> Self

Create with specific config

Source

pub fn with_indicators() -> Self

Create with indicator-based detection

Source

pub fn with_hmm() -> Self

Create with HMM-based detection

Source

pub fn with_ensemble() -> Self

Create with Ensemble detection (recommended)

Source

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.

Source

pub fn unregister_asset(&mut self, symbol: &str) -> bool

Unregister an asset, removing its state and detector

Source

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).

Source

pub fn get_regime(&self, symbol: &str) -> Option<MarketRegime>

Get current regime for an asset

Source

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.

Source

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:

  • IndicatorsRegimeDetector::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.

Source

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:

  • IndicatorsRegimeDetector::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.

Source

pub fn get_strategy(&self, symbol: &str) -> Option<ActiveStrategy>

Get current recommended strategy for an asset

Source

pub fn is_ready(&self, symbol: &str) -> bool

Check if detector is warmed up for an asset

Source

pub fn detection_method(&self) -> DetectionMethod

Get detection method being used

Source

pub fn regime_changes(&self, symbol: &str) -> u32

Get regime change count for an asset

Source

pub fn registered_assets(&self) -> Vec<&str>

Get all registered asset symbols

Source

pub fn config(&self) -> &EnhancedRouterConfig

Get the router configuration

Source

pub fn summary(&self) -> Vec<AssetSummary>

Get a summary of all asset states

Trait Implementations§

Source§

impl Debug for EnhancedRouter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.