Crates.io | stocks_api |
lib.rs | stocks_api |
version | 0.1.6 |
source | src |
created_at | 2023-04-09 01:26:42.346005 |
updated_at | 2023-04-19 09:27:15.902193 |
description | A library to get finance data using YahooFinanceAPI |
homepage | |
repository | https://github.com/Byte-Forge/stocks-api-rs |
max_upload_size | |
id | 833877 |
size | 42,212 |
Retrieve finance data using YahooFinanceAPI
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)
}
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(",")
);
}