Skip to main content

AlertCondition

Enum AlertCondition 

Source
#[non_exhaustive]
pub enum AlertCondition {
Show 15 variants StrategyFills(String), Crossing(f64), CrossingUp(f64), CrossingDown(f64), Above(f64), Below(f64), EnteringChannel { lower: f64, upper: f64, }, ExitingChannel { lower: f64, upper: f64, }, InsideChannel { lower: f64, upper: f64, }, OutsideChannel { lower: f64, upper: f64, }, MovingBy { value: f64, bars: u32, }, MovingByPercent { percent: f64, bars: u32, }, Compare { other: AlertSource, comparison: AlertComparison, }, Channel { boundaries: [AlertSource; 2], comparison: AlertChannelComparison, }, VolumeAboveAverage { multiplier: f64, bars: u32, },
}
Expand description

When an alert fires, judged on its source for each subject symbol. Each variant states its rule so that a host and a server evaluate it alike. Levels are finite and in the symbol’s price units.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

StrategyFills(String)

Each fill of the host’s uniquely named strategy run. Feed Backtest::update results to AlertEngine::strategy_fills with the same run id. Uses the price source, no additional rules, and frequency EveryTime (the constructor default) or Once. No bars evaluate it.

§

Crossing(f64)

The previous value was strictly below or above the level and the current value reaches or passes it, in either direction.

§

CrossingUp(f64)

The previous price was below the level and the current price is at or above it.

§

CrossingDown(f64)

The previous price was above the level and the current price is at or below it.

§

Above(f64)

The price is above the level.

§

Below(f64)

The price is below the level.

§

EnteringChannel

Previous value was outside the inclusive channel, current value is inside it.

Fields

§lower: f64

Inclusive lower boundary, strictly below upper.

§upper: f64

Inclusive upper boundary.

§

ExitingChannel

Previous value was inside the inclusive channel, current value is outside it.

Fields

§lower: f64

Inclusive lower boundary, strictly below upper.

§upper: f64

Inclusive upper boundary.

§

InsideChannel

The current value is inside the inclusive channel, lower <= value <= upper, whatever the previous value was.

Fields

§lower: f64

Inclusive lower boundary, strictly below upper.

§upper: f64

Inclusive upper boundary.

§

OutsideChannel

The current value is outside the inclusive channel, below lower or above upper, whatever the previous value was.

Fields

§lower: f64

Inclusive lower boundary, strictly below upper.

§upper: f64

Inclusive upper boundary.

§

MovingBy

Signed change from bars bars ago reaches value: at least for positive, at most for negative.

Fields

§value: f64

Signed, nonzero change in source units.

§bars: u32

Number of bars back, at least one.

§

MovingByPercent

Signed percentage change, 100 * (current - previous) / abs(previous), over bars bars. A zero previous value cannot satisfy this condition.

Fields

§percent: f64

Signed, nonzero percentage, with 1 meaning 1%.

§bars: u32

Number of bars back, at least one.

§

Compare

Compare against another output on the same bar, using its previous value for crossings.

Fields

§other: AlertSource

The second output on the same symbol and bar.

§comparison: AlertComparison

The required relationship between the outputs.

§

Channel

Test against two boundaries resolved on each evaluated bar. The boundaries may change order; their minimum and maximum define the inclusive channel. Missing, non-finite or coincident boundaries cannot satisfy the condition. On a new bar, transitions resolve the source and both boundaries at the preceding bar again. Within a bar they compare with the previous evaluation, just as a crossing does.

Fields

§boundaries: [AlertSource; 2]

Stable sources of the two boundary lines, retained through drawing edits and storage.

§comparison: AlertChannelComparison

State or transition to test.

§

VolumeAboveAverage

Current volume exceeds multiplier times the mean of the preceding bars completed volumes.

Fields

§multiplier: f64

Positive, finite multiple of the preceding mean volume.

§bars: u32

Number of preceding bars in the mean, at least one.

Implementations§

Source§

impl AlertCondition

Source

pub fn is_valid(&self) -> bool

Whether levels are finite and ordered, lookbacks positive, and referenced ids nonempty.

Source

pub fn level(&self) -> Option<f64>

The single horizontal threshold, if the condition has one.

Trait Implementations§

Source§

impl Clone for AlertCondition

Source§

fn clone(&self) -> AlertCondition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlertCondition

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AlertCondition

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for AlertCondition

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AlertCondition

Source§

fn eq(&self, other: &AlertCondition) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AlertCondition

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AlertCondition

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.