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

Support single quote query #26

Closed feliwir closed 1 year ago

feliwir commented 1 year ago

Hello.

for my project it would be great if a single quote query (without an interval) would be supported. The route for that would: /v7/finance/quote

Also i can't seem to find some fields that i need in my project:

Maybe i'm just missing something? Thanks a lot

xemwebe commented 1 year ago

Hi,

the fields currency and regularMarketPrice are returned as part of YResponse struct. To access these fields, you could for example call

let response = provider.get_latest_quotes("AAPL", "1d").unwrap();
let regular_market_price = response.chart.result[0].meta.regular_market_price;
let currency = response.chart.result[0].meta.currency;

regularMarketChance however does not seem to be part of YResponse, though it is returned by the 'v7' path you mentioned. Is there a reason why to prefer regularMarketPrice over the latest quote price?

I could also extend the interface by the path you mentioned, some of the information provided by this pass seem to be useful and not available otherwise.

xemwebe commented 1 year ago

I have just added a new method get_summary which implements the request on path /v7/finance/quote. There is also a new example demonstrating usage and output. Please let me know if this closes this issue.

feliwir commented 1 year ago

Hey, thanks a lot. I'll take a look! I think that get_summary should be the recommened / default route to get the latest quote for a symbol. Maybe changes to the README.md would be good?

xemwebe commented 1 year ago

I have added an example of get_summary to the documenation.