xemwebe / yahoo_finance_api

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

Before and after day trading data #36

Closed satvikpendem closed 1 month ago

satvikpendem commented 6 months ago

Looks like you can get pre- and post-day trading data via the curling the URL below, specifically the includePrePost parameter with the value set to true. Could this be added as a parameter in the code as well? I am thinking in both the get quote range and the get latest quotes methods, if there could be a parameter to include pre- and post-day trading data.

https://query1.finance.yahoo.com/v8/finance/chart/AAPL?interval=1m&period=1d&includePrePost=true

I found this out via the Python yfinance library which has this parameter.

xemwebe commented 6 months ago

I was quite busy the last two weeks and will be for the next two, therefore I can't promise when I will be able to look into it, but it doesn't seem to be a big issue.

satvikpendem commented 6 months ago

Sounds good, have a happy holidays!

xemwebe commented 5 months ago

I have analyzed the response of this query and unfortunately, the response is just such a tiny bit different (apparently only TradingPeriod changes slightly) that the existing data structure could not be used. There seems to be no simple way to adjust the data structure to accept both variants. Alternatively, we would need to duplicate almost the complete YResponse structure, which isn't ideal either.

I think the best solution is probably to write a custom deserializer for TradingPeriod to handle both cases.

satvikpendem commented 5 months ago

Sounds good, would that be included in the crate itself? Would be a good feature to have.

xemwebe commented 5 months ago

Yes, of course, I would put it in the same crate.

xemwebe commented 5 months ago

I have just pushed and update, enabling optionally pre or post regular trading hours quotes. See the new example examples/get_quote_period_interval.rs. Have not done so far an extensive testing, please let me know if this solves your issue. I will than prepare a new release version.

satvikpendem commented 5 months ago

Thanks, I'll take a look