xemwebe / yahoo_finance_api

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

Search often fails #10

Closed venil7 closed 3 years ago

venil7 commented 3 years ago

for example search term TSLA,MSFT, AAPL bitcoin fails with error deserializing response from yahoo! finance failed: missing field "longname"

xemwebe commented 3 years ago

Have you observerd any other fields that are sometimes missing? There are typically two solutions to this problem: change the field to Option or return an empty string if the field is missing the response. The first solution is more clean, but would mean a change on interface. Before I would go this path, I would like to be pretty sure that this problem does not occur with other fields, too (which would mean frequent interface changes).

venil7 commented 3 years ago

It does happen for other fields too! My preference would be "" as it doesnt change the interface

venil7 commented 3 years ago

It also seems random for examlpe i get failure deserializing response from yahoo! finance failed: missing field "shortname" for search term abc, while previously it was returning values

I guess Y! finace api itself is not guaranteeing all fields at all times, hence best to fallback to ""

xemwebe commented 3 years ago

I have implemented now both version, keeping the existing interface, but returning empty string for shortname and longname, if they missing, add added a new method (named with "_opt" at the end) that returns an Option for shortname and longname.

venil7 commented 3 years ago

Awesome, thanks, version 1.1.4-dev is not on crates.io yet, is it?

xemwebe commented 3 years ago

Not yet, I wanted to update the docs and make sure that it does work before I publish an update to crates.io, will do so soon.

xemwebe commented 3 years ago

It's now pushed to crates.io, closing issue