yahooquery icon indicating copy to clipboard operation
yahooquery copied to clipboard

yahooquery reporting EOD data for today before the EOD

Open shipmints opened this issue 5 years ago • 3 comments

Not sure if this is an issue with the Yahoo! API or with yahooquery but if one asks for a date range, say, 20200101-20200828 (today, Friday) at noon EST, there's a closing price reported for each symbol. Not sure what that price is supposed to be but it surely can't be a closing price until the exchanges report their closes, after 4pm for sure, and often up till 8pm with corrections.

Questions:

  1. What is this price? Does anyone know?

  2. Should yahooquery lie if Yahoo!'s API lies or can we rely on it to skip erroneous data, perhaps with an option to the history function? Is there a reliable way to know? It would benefit all users to have that logic in yahooquery vs. in their own code, duped throughout.

Thanks, again, for supporting this library, @dpguthrie

shipmints avatar Aug 28 '20 22:08 shipmints

  1. This is, I believe, the current price when requesting data during market hours. Make a similar request several times during market hours and you'll see that last value continue to get updated.
  2. My initial thought would be to exclude the last value during that security's market hours. But, it should probably be in the form of an option the user could supply to the method in the event that data is being utilized. I think it would be relatively straightforward to do something like that, but I'm certaintly open to suggestions if you have any.

dpguthrie avatar Aug 30 '20 19:08 dpguthrie

The Yahoo! API is definitely misleading and, if indeed asking for "closing" history is salted with non closes, that is bad. There is no special identification on the last element marking it as real time vs. close or even a timestamp. It's poor API design on Yahoo!'s part. It is surprising that if you look at their web pages they also report history during the trading day so they suffer from their own broken API.

It makes relying on the last element troublesome when accumulating a database, for example.

Perhaps the Yahoo! API has an option to suppress this behavior. If so, I'd make that the new default. If yahooquery users truly want erroneous "history," let them turn this off with an option. I'd think they'd want to make two explicit calls: one for history, one for the most recent price, or perhaps today's price action but never for erroneous data.

I suppose yahooquery users can provide a date range that goes only up until today()-1. This could also be done by the yahooquery history method. This may be what I will have to do in the meantime as a workaround.

The idea to lop off data doesn't sit quite right with me vs. using a date range or using a Yahoo! provided suppression flag.

shipmints avatar Aug 30 '20 21:08 shipmints

I'm a bit late commenting on this. I'm the author of a backtest Pinkfish (https://github.com/fja05680/pinkfish) and recently ran into the this issue. It is helpful to have the last close be the real time quote during the day, if you are using close as the basis for technical calculations and trading on the close, as you need make no exceptions in the trading/analysis code. However, my solution for populating a database is to use the previous close. Although it's easy enough for the user to do this, an option might be helpful. In any case, the default should match what yahoo finance provides.

fja05680 avatar Feb 28 '21 17:02 fja05680

I think this is out of scope for this library. I can see the case for both wanting this data and excluding it. Closing as not planned to fix.

dpguthrie avatar Oct 15 '22 20:10 dpguthrie