#![allow(unused)]
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_10() {
use finance_query::streaming::PriceStream;
use futures::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = PriceStream::subscribe(["AAPL", "NVDA", "TSLA"]).await?;
while let Some(price) = stream.next().await {
println!("{}: ${:.2} ({:+.2}%)",
price.id,
price.price,
price.change_percent
);
}
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_42() {
use finance_query::streaming::PriceStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = PriceStream::subscribe(["AAPL", "GOOGL"]).await?;
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_54() {
use finance_query::streaming::PriceStreamBuilder;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = PriceStreamBuilder::new()
.symbols(["AAPL", "MSFT", "NVDA"])
.retry(Duration::from_secs(5))
.build()
.await?;
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_73() {
use finance_query::streaming::PriceStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let stream = PriceStream::subscribe(["AAPL"]).await?;
stream.add_symbols(["NVDA", "TSLA"]).await;
stream.remove_symbols(["AAPL"]).await;
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_93() {
use finance_query::streaming::PriceStream;
use futures::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream1 = PriceStream::subscribe(["AAPL", "NVDA"]).await?;
let mut stream2 = stream1.resubscribe();
tokio::spawn(async move {
while let Some(price) = stream2.next().await {
println!("Consumer 2: {} ${:.2}", price.id, price.price);
}
});
while let Some(price) = stream1.next().await {
println!("Consumer 1: {} ${:.2}", price.id, price.price);
}
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_144() {
use finance_query::streaming::{MarketHoursType, PriceStream};
use futures::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = PriceStream::subscribe(["AAPL", "MSFT", "GOOGL"]).await?;
while let Some(price) = stream.next().await {
if price.market_hours == MarketHoursType::RegularMarket {
println!("{}: ${:.2}", price.id, price.price);
}
}
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_164() {
use finance_query::streaming::PriceStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let stream = PriceStream::subscribe(["AAPL"]).await?;
stream.close().await;
Ok(())
}
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_190() {
use finance_query::streaming::NewsStream;
use finance_query::feeds::FeedSource;
use futures::StreamExt;
#[tokio::main]
async fn main() {
let mut stream =
NewsStream::subscribe([FeedSource::Bloomberg, FeedSource::MarketWatch]).await;
while let Some(entry) = stream.next().await {
println!("[{}] {}", entry.source, entry.title);
}
}
}
#[rustfmt::skip]
#[test]
fn doc_block_line_211() {
use finance_query::streaming::NewsStreamBuilder;
use finance_query::feeds::FeedSource;
use std::time::Duration;
#[tokio::main]
async fn main() {
let stream = NewsStreamBuilder::new()
.sources(vec![FeedSource::FederalReserve, FeedSource::SecPressReleases])
.poll_interval(Duration::from_secs(60))
.build()
.await;
stream.close().await;
}
main();
}
#[rustfmt::skip]
#[allow(dead_code)]
fn doc_block_line_236() {
use finance_query::streaming::NewsStream;
use finance_query::feeds::FeedSource;
#[tokio::main]
async fn main() {
let stream = NewsStream::subscribe([FeedSource::Bloomberg]).await;
stream.add_sources([FeedSource::WsjMarkets]).await;
stream.remove_sources([FeedSource::Bloomberg]).await;
let other_consumer = stream.resubscribe();
stream.close().await;
}
}