7 releases
0.1.6 | Apr 19, 2023 |
---|---|
0.1.5 | Apr 12, 2023 |
#194 in Finance
35 downloads per month
12KB
234 lines
stocks_api
Retrieve finance data using YahooFinanceAPI
Examples
Get a single quote
use stocks_api::YahooFinanceAPI;
use tokio::runtime::Runtime;
fn main() {
let rt = Runtime::new().unwrap();
let api = YahooFinanceAPI::new();
let quote = rt.block_on(api.get_quote("AAPL")).unwrap();
print!("Current AAPL price: {}", quote.regular_market_price)
}
Search for symbols
use stocks_api::YahooFinanceAPI;
use tokio::runtime::Runtime;
fn main() {
let rt = Runtime::new().unwrap();
let api = YahooFinanceAPI::new();
let symbols = rt.block_on(api.search_symbols("Microsoft")).unwrap();
println!("Search results for: Microsoft");
println!(
"{}",
symbols
.into_iter()
.map(|symbol| symbol.symbol)
.collect::<Vec<String>>()
.join(",")
);
}
Dependencies
~7–19MB
~253K SLoC