Crates.io | stock-data |
lib.rs | stock-data |
version | 0.1.0 |
source | src |
created_at | 2024-05-30 18:58:30.29784 |
updated_at | 2024-05-30 18:58:30.29784 |
description | A Rust crate for efficiently downloading historical stock data from Yahoo Finance, featuring asynchronous operations with reqwest and tokio for optimal performance. |
homepage | |
repository | https://github.com/AG3NTZ3R0/stock-data |
max_upload_size | |
id | 1257183 |
size | 8,761 |
A Rust crate for efficiently downloading historical stock data from Yahoo Finance, featuring asynchronous operations with reqwest and tokio for optimal performance.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let msg = "Failed to generate date";
let date1 = NaiveDate::from_ymd_opt(2023, 01, 01).expect(msg);
let date2 = NaiveDate::from_ymd_opt(2024, 01, 01).expect(msg);
let url = build_yahoo_finance_url_from_dates("AMZN", date1, date2, "1d", true);
let bytes = download_stock_data(&url).await?;
let path = "output/stock_data.csv";
write_stock_data(&bytes, &path).await?;
Ok(())
}