Crates.io | yahoo-finance |
lib.rs | yahoo-finance |
version | 0.3.0 |
source | src |
created_at | 2020-03-28 13:37:57.569013 |
updated_at | 2020-09-09 12:51:59.879213 |
description | An API to get financial data from Yahoo. |
homepage | https://github.com/fbriden/yahoo-finance-rs |
repository | https://github.com/fbriden/yahoo-finance-rs |
max_upload_size | |
id | 223811 |
size | 83,950 |
A Rust library for getting financial information from Yahoo!
use yahoo_finance::history;
fn main() {
// retrieve 6 months worth of data for Apple
let data = history::retrieve("AAPL").unwrap();
// print the date and closing price for each day we have data
for bar in &data {
println!("On {} Apple closed at ${:.2}", bar.timestamp.format("%b %e %Y"), bar.close)
}
}
use futures::{ future, StreamExt };
use yahoo_finance::Streamer;
#[tokio::main]
async fn main() {
let mut streamer = Streamer::new(vec!["AAPL", "^DJI", "^IXIC"]);
streamer.stream().await
.for_each(|quote| {
println!("At {}, {} is trading for ${} [{}]", quote.timestamp, quote.symbol, quote.price, quote.volume);
future::ready(())
})
.await;
}
use futures::{ future, StreamExt };
use yahoo_finance::Streamer;
#[tokio::main]
async fn main() {
let mut streamer = Streamer::new(vec!["AAPL", "^DJI", "^IXIC"]);
streamer.stream().await
.for_each(|quote| {
println!("At {}, {} is trading for ${} [{}]", quote.timestamp, quote.symbol, quote.price, quote.volume);
future::ready(())
})
.await;
}
Add this to your Cargo.toml
:
yahoo-finance = "0.3"