pub struct StopLoss {
pub pct: f64,
}Expand description
Condition: position P/L is at or below the stop-loss threshold.
§Execution Model
This condition evaluates at bar close: it fires when the closing price
implies a loss ≥ pct. The resulting exit signal is deferred to the next
bar’s open (identical to all strategy-signal exits).
For intrabar detection (fill same bar at min(open, stop_level)), use
[BacktestConfig::stop_loss_pct] instead. A −10% intraday move that closes
at −3% will be caught by the config field but missed by this condition.
§Example
ⓘ
use finance_query::backtesting::condition::*;
let exit = stop_loss(0.05); // Exit if loss >= 5% at bar closeFields§
§pct: f64Stop-loss percentage (e.g., 0.05 for 5%)
Implementations§
Trait Implementations§
Source§impl Condition for StopLoss
impl Condition for StopLoss
Source§fn evaluate(&self, ctx: &StrategyContext<'_>) -> bool
fn evaluate(&self, ctx: &StrategyContext<'_>) -> bool
Evaluate the condition with the current strategy context. Read more
Source§fn required_indicators(&self) -> Vec<(String, Indicator)>
fn required_indicators(&self) -> Vec<(String, Indicator)>
Get the indicators required by this condition. Read more
Source§fn description(&self) -> String
fn description(&self) -> String
Get a human-readable description of this condition. Read more
Source§fn htf_requirements(&self) -> Vec<HtfIndicatorSpec>
fn htf_requirements(&self) -> Vec<HtfIndicatorSpec>
Get any higher-timeframe indicators required by this condition. Read more
Source§fn and<C: Condition>(self, other: C) -> And<Self, C>where
Self: Sized,
fn and<C: Condition>(self, other: C) -> And<Self, C>where
Self: Sized,
Combine this condition with another using AND logic. Read more
impl Copy for StopLoss
Auto Trait Implementations§
impl Freeze for StopLoss
impl RefUnwindSafe for StopLoss
impl Send for StopLoss
impl Sync for StopLoss
impl Unpin for StopLoss
impl UnsafeUnpin for StopLoss
impl UnwindSafe for StopLoss
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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