pub struct RegimeConditionalSignal { /* private fields */ }Expand description
A wrapper that selects different RSI periods depending on the active regime.
This is the canonical implementation of regime-conditional signal adaptation:
- In
Trendingmarkets: short-period RSI is more responsive - In
MeanRevertingmarkets: longer-period RSI reduces noise - In
HighVolatilityorCrisis: signal is suppressed (returnsNone) - In other regimes: uses the neutral period
§Example
use fin_primitives::regime::{RegimeConditionalSignal, MarketRegime};
use fin_primitives::signals::BarInput;
use rust_decimal_macros::dec;
let mut signal = RegimeConditionalSignal::new(14, 21, 14).unwrap();
let bar = BarInput::new(dec!(100), dec!(102), dec!(98), dec!(100), dec!(1000));
// During warm-up, regime is Unknown → signal suppressed
let val = signal.update(&bar, MarketRegime::Unknown);
assert!(val.is_none());Implementations§
Source§impl RegimeConditionalSignal
impl RegimeConditionalSignal
Sourcepub fn new(
trending_period: usize,
mean_reverting_period: usize,
neutral_period: usize,
) -> Result<Self, FinError>
pub fn new( trending_period: usize, mean_reverting_period: usize, neutral_period: usize, ) -> Result<Self, FinError>
Constructs a new RegimeConditionalSignal.
trending_period: RSI period for trending regime (e.g. 14).mean_reverting_period: RSI period for mean-reverting regime (e.g. 21).neutral_period: RSI period for all other regimes (e.g. 14).
§Errors
Returns FinError::InvalidPeriod if any period is zero.
Auto Trait Implementations§
impl Freeze for RegimeConditionalSignal
impl RefUnwindSafe for RegimeConditionalSignal
impl Send for RegimeConditionalSignal
impl Sync for RegimeConditionalSignal
impl Unpin for RegimeConditionalSignal
impl UnsafeUnpin for RegimeConditionalSignal
impl UnwindSafe for RegimeConditionalSignal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more