xemwebe / yahoo_finance_api

Simple wrapper to yahoo! finance API to retrieve latest quotes and end-of-day quote histories
Apache License 2.0
64 stars 29 forks source link

Error occurred when running get_quote_history #27

Closed z-Wind closed 1 year ago

z-Wind commented 1 year ago

Hello,

I encountered an error when running the get_quote_history from the yahoo-finance-api crate. The error message is:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` 
value: DeserializeFailed(Error("invalid type: floating point `1`, expected u64", line: 0, column: 0))', 
src\main.rs:7:65

Here is the code that caused the error:

#[tokio::main]
async fn main() {
    let conn = yahoo_finance_api::YahooConnector::new();
    let ticker = "VTI";
    let start = time::OffsetDateTime::UNIX_EPOCH;
    let end = time::OffsetDateTime::now_utc();
    let hist = conn.get_quote_history(ticker, start, end).await.unwrap();
}

Please let me know if there is anything I can do to help resolve this issue. Thank you.

Best regards,

xemwebe commented 1 year ago

Thanks for reporting this error. Apparently, numerator and denominator of Splits are some times returned as floats (here: 1.0 and 2.0). Since I could not excluded fractional numerators and denominators (though this should be rarely, if ever, the case), I have changed the definition of splits and published a new version with this fix.