stock-data

Crates.iostock-data
lib.rsstock-data
version0.1.0
sourcesrc
created_at2024-05-30 18:58:30.29784
updated_at2024-05-30 18:58:30.29784
descriptionA Rust crate for efficiently downloading historical stock data from Yahoo Finance, featuring asynchronous operations with reqwest and tokio for optimal performance.
homepage
repositoryhttps://github.com/AG3NTZ3R0/stock-data
max_upload_size
id1257183
size8,761
Brandon J. Lacy (AG3NTZ3R0)

documentation

README

Stock Data

Description

A Rust crate for efficiently downloading historical stock data from Yahoo Finance, featuring asynchronous operations with reqwest and tokio for optimal performance.

Example

#[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(())
}
Commit count: 10

cargo fmt