pub trait Condition:
Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn evaluate(&self, ctx: &StrategyContext<'_>) -> bool;
fn required_indicators(&self) -> Vec<(String, Indicator)>;
fn description(&self) -> String;
// Provided methods
fn and<C: Condition>(self, other: C) -> And<Self, C>
where Self: Sized { ... }
fn or<C: Condition>(self, other: C) -> Or<Self, C>
where Self: Sized { ... }
fn not(self) -> Not<Self>
where Self: Sized { ... }
}Expand description
A condition that can be evaluated on each candle.
Conditions are the building blocks of trading strategies.
They can be combined using and(), or(), and not() operations.
§Example
ⓘ
use finance_query::backtesting::condition::Condition;
fn my_custom_condition(ctx: &StrategyContext) -> bool {
// Custom logic here
true
}Required Methods§
Sourcefn evaluate(&self, ctx: &StrategyContext<'_>) -> bool
fn evaluate(&self, ctx: &StrategyContext<'_>) -> bool
Evaluate the condition with the current strategy context.
Returns true if the condition is met, false otherwise.
Sourcefn required_indicators(&self) -> Vec<(String, Indicator)>
fn required_indicators(&self) -> Vec<(String, Indicator)>
Get the indicators required by this condition.
The backtest engine will pre-compute these indicators before running the strategy.
Sourcefn description(&self) -> String
fn description(&self) -> String
Get a human-readable description of this condition.
This is used for logging, debugging, and signal reporting.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.