pub struct EnsembleStrategy { /* private fields */ }Expand description
A strategy that aggregates signals from multiple sub-strategies.
Build with the fluent builder methods add, mode,
then finalise with build.
All six SignalDirection variants are
fully supported. In EnsembleMode::WeightedMajority, ScaleIn and ScaleOut
participate in the vote with the same position guard as Exit — they are only
tallied when a position is open. In Unanimous, AnySignal, and
StrongestSignal modes they are treated like any other non-Hold direction.
Implementations§
Source§impl EnsembleStrategy
impl EnsembleStrategy
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new ensemble with the given name.
The default voting mode is EnsembleMode::WeightedMajority.
Sourcepub fn add<S: Strategy + 'static>(self, strategy: S, weight: f64) -> Self
pub fn add<S: Strategy + 'static>(self, strategy: S, weight: f64) -> Self
Add a sub-strategy with the given weight.
Weight is only meaningful for EnsembleMode::WeightedMajority; other
modes ignore it. Negative weights are treated as zero.
Sourcepub fn mode(self, mode: EnsembleMode) -> Self
pub fn mode(self, mode: EnsembleMode) -> Self
Set the voting mode.
Trait Implementations§
Source§impl Debug for EnsembleStrategy
impl Debug for EnsembleStrategy
Source§impl Strategy for EnsembleStrategy
impl Strategy for EnsembleStrategy
Source§fn required_indicators(&self) -> Vec<(String, Indicator)>
fn required_indicators(&self) -> Vec<(String, Indicator)>
Required indicators this strategy needs. Read more
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Optional: minimum candles required before strategy can generate signals.
Default is 1 (strategy can run from first candle).
Source§fn on_candle(&self, ctx: &StrategyContext<'_>) -> Signal
fn on_candle(&self, ctx: &StrategyContext<'_>) -> Signal
Called on each candle to generate a signal. Read more
Source§fn htf_requirements(&self) -> Vec<HtfIndicatorSpec>
fn htf_requirements(&self) -> Vec<HtfIndicatorSpec>
Higher-timeframe indicators required by this strategy. Read more
Auto Trait Implementations§
impl Freeze for EnsembleStrategy
impl !RefUnwindSafe for EnsembleStrategy
impl Send for EnsembleStrategy
impl Sync for EnsembleStrategy
impl Unpin for EnsembleStrategy
impl UnsafeUnpin for EnsembleStrategy
impl !UnwindSafe for EnsembleStrategy
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more