Open Alton1998 opened 1 month ago
For the main.rs file:
use yahoo_finance_api as yahoo; use std::time::{Duration, UNIX_EPOCH}; use tokio_test;
fn main() { let provider = yahoo::YahooConnector::new().unwrap(); let response = tokio_test::block_on(provider.get_quote_range("GOOGL", "1d", "1mo")).unwrap(); let quotes = response.quotes().unwrap(); println!("Google's quotes of the last month: {:?}", quotes);
let first_day_quote = "es[0]; // Access the first quote (first day's data)
let high = first_day_quote.high;
let low = first_day_quote.low;
println!("High for the first day: {}", high);
println!("Low for the first day: {}", low);
}
For the cargo.toml file:
[package] name = "fetch_stock" version = "0.1.0" edition = "2021"
[dependencies] yahoo_finance_api = "2.3.0" tokio-test = "0.4.4"
Handle bad stock symbol through Results or Options