finnhubio / Finnhub-API

Finnhub API provides institutional-grade financial data to investors, fintech startups and investment firms. We support real-time stock price, global fundamentals and alternative data. https://finnhub.io/docs/api
97 stars 6 forks source link

Inconsistent timestamps on daily data #387

Open stephenrs opened 3 years ago

stephenrs commented 3 years ago

What is the issue ? Plz describe in details

This is a pretty subtle issue, but it has become problematic for my implementation, so I'm curious to hear your thoughts....

In general, daily price data includes a timestamp that appears to represent the opening time of a particular symbol/exchange on a given day, however, sometimes the timestamp is set to midnight. This can cause problems, such as date/data duplication, for API consumers.

How to reproduce the error ?

I can't tell exactly what conditions cause this to happen, but it might only happen on Mondays...and it appears to "fix itself" over time, but the URL below produced the following output when hit at 3:44pm CST on Monday, January 4th 2021:

Screen Shot 2021-01-04 at 4 07 20 PM

All of the timestamps in the series have a time part of 03:45 UTC, except the last timestamp (highlighted in blue), which has a time part of 00:00.

Typically this will "fix itself" by tomorrow, so if the fetch is repeated tomorrow, the time of the last timestamp noted above will also have a time part of 03:45, like the other previous dates.

https://finnhub.io/api/v1/stock/candle?symbol=RELIANCE.NS&resolution=D&from=1566585790&to=1609785790&adjusted=true&token=[API_KEY]

What is the expected result and why do you think it's the correct result ?

For consistency, a particular datapoint should always have the same timestamp, regardless of when it is fetched from the API.

stephenrs commented 3 years ago

Just following up on this, and it has become a little more mysterious...

The data returned at the link above still sets the time part of the last data point to Jan 4th, 2021 at 00:00, however, if you change the "to" parameter to a date further in the future, the time part of the Jan 4th 2021 data point is set to 03:45.

For example:

https://finnhub.io/api/v1/stock/candle?symbol=RELIANCE.NS&resolution=D&from=1608921859&to=1709785790&adjusted=true&token=[API_KEY]

Also, the last data point returned from this link (Jan 5th, 2021) also has a time part of 03:45.

So, it appears that depending on how and when you fetch daily data, the returned timestamps can be different, at least for some exchanges. Also, as far as I've been able to observe, this seems to only affect the last data point in the series.

Any thoughts?

MrNightSky commented 3 years ago

Are you sure that it is not a days with post-market and pre-market? I don't know what market is for RELIANCE.NS, but "For Nasdaq, pre-market trading hours are 4:00 am to 9:30 am, Eastern Time Zone. After hours runs from 4:00 pm to 8:00 pm, Eastern Time Zone." - citation from https://www.nasdaq.com/stock-market-trading-hours-for-nasdaq. So sometimes there is data in this time sometimes not. Why it isn't permanent I don't know.

stephenrs commented 3 years ago

Are you sure that it is not a days with post-market and pre-market? I don't know what market is for RELIANCE.NS, but "For Nasdaq, pre-market trading hours are 4:00 am to 9:30 am, Eastern Time Zone. After hours runs from 4:00 pm to 8:00 pm, Eastern Time Zone." - citation from https://www.nasdaq.com/stock-market-trading-hours-for-nasdaq. So sometimes there is data in this time sometimes not. Why it isn't permanent I don't know.

Thanks for your input, but that's not the problem. Extended hours trading should not affect fetches for daily data...and daily data points should always have the same timestamp, regardless of when they are fetched.