Skip to main content

AlertExt

Trait AlertExt 

Source
pub trait AlertExt:
    Stream<Item = PriceUpdate>
    + Sized
    + Unpin {
    // Provided method
    fn alerts(
        self,
        rules: impl IntoIterator<Item = AlertRule>,
    ) -> AlertStream<Self> { ... }
}
Expand description

Adds alerts to every price stream.

§Example

use finance_query::streaming::{AlertCondition, AlertExt, AlertRule, PriceStream};
use futures::StreamExt;

let mut alerts = PriceStream::subscribe(["AAPL"])
    .await?
    .alerts([AlertRule::new("AAPL", AlertCondition::CrossesAbove(200.0))]);

while let Some(alert) = alerts.next().await {
    println!("{} crossed at {}", alert.symbol, alert.price);
}

Provided Methods§

Source

fn alerts(self, rules: impl IntoIterator<Item = AlertRule>) -> AlertStream<Self>

Yield only the ticks that trigger one of rules.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S> AlertExt for S
where S: Stream<Item = PriceUpdate> + Sized + Unpin,