You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like market holydays are not taken into account. For example, Thanksgiving 2024 was on Nov.28th, 2024. There was no market.
Downloading the daily NQ future from TV, I get a candle on 2024-11-28 and I'm missing the candle on 2024-11-29 which was the real open market day as follows:
symbol open high low close volume
datetime
2024-11-04 CME_MINI:NQZ2024 20138.00 20248.50 20013.00 20086.00 520521.0
....
2024-11-26 CME_MINI:NQZ2024 20906.25 21024.75 20755.00 20993.50 505254.0
2024-11-27 CME_MINI:NQZ2024 20990.75 21019.00 20675.00 20813.00 520026.0
2024-11-28 CME_MINI:NQZ2024 20813.00 21017.50 20805.50 20993.50 339955.0
The data for 2024-11-28 should actually be the candle of 2024-11-29 (OHLCV values are correct for the 2024-11-29 date).
Further, looking at the TradingView Chart, i can confirm that the Candle for 2024-11-28 is missing, and the data is present only for 2024-11-27 and 2024-11-29.
My guess (to be verified) is that the same issue occurs on all market holidays and the data is shifted.
EDIT: Verifying the data that comes from TV, I see that the json value contains:
This means that, assuming the TV data is correct, some offset/timezone mangling is necessary to properly align the timestamp to a correct date.
A proposed fix:
Digging further, my guess is that:
The timestamp returned by TV is localized in your particular timezone.
The timestamp is for the beginning of the business day, and if the timestamp happens on a holiday, then it must be moved to the next business day.
With these assumpions, he below proposed fix produces the correct timestamps:
from datetime import datetime, timedelta
import pytz
# Define the timestamp
timestamp = 1732748400 # 2024-11-28 00:00:00
tz = pytz.timezone("<your-local-timezone>")
dt = datetime.fromtimestamp(timestamp,tz).date()
print(f"Unadjusted date : {dt}")
if not is_business_day(dt):
dt = next_business_day(dt)
print(f"UAdjusted date : {dt}")
the two functions is_business_day and next_business_day can be implemented using the pypi "holidays" package or the pandas_market_calendars package. your-local-timezone is the timezone of your TV account, or the default timezone if not using an account.
With this proposed fix, here's the corrected dates from the NQZ2024 contact:
I'm still working on this issue, and unfortunately uncovered more timestamp troubles. Here's an example, using the same NQZ2024 contract. The timestamps returned by TV seem to not account for the specific day the day savings time start and end. Below is an extract from the returned data as a Timestamp and as a number. The data was downloaded from the Europe/Paris timezone (GMT+1 and GMT+2 when on day savings time).
The day savings end on Oct 27th, but the timestamp returned by TV seems to only change on Nov.1st. This results in a one-day jump and the weird timestamps on Oct 27 (sunday) at 23:00PM.
When changing the time zone from which you download data (like when using a VPN), the timestamps returned change as well, and they follow the local timezone from which you're downloading. However, the issue with the wrong day of DST end persists.
The problem seems to lie in the TV data itself and will require an ugly patch to fix, unless I am missing something, like perhaps a way to request timestamps explicitly in UTC.
It looks like market holydays are not taken into account. For example, Thanksgiving 2024 was on Nov.28th, 2024. There was no market.
Downloading the daily NQ future from TV, I get a candle on 2024-11-28 and I'm missing the candle on 2024-11-29 which was the real open market day as follows:
The data for 2024-11-28 should actually be the candle of 2024-11-29 (OHLCV values are correct for the 2024-11-29 date).
Further, looking at the TradingView Chart, i can confirm that the Candle for 2024-11-28 is missing, and the data is present only for 2024-11-27 and 2024-11-29.
My guess (to be verified) is that the same issue occurs on all market holidays and the data is shifted.
EDIT: Verifying the data that comes from TV, I see that the json value contains:
This means that, assuming the TV data is correct, some offset/timezone mangling is necessary to properly align the timestamp to a correct date.
A proposed fix:
Digging further, my guess is that:
With these assumpions, he below proposed fix produces the correct timestamps:
the two functions
is_business_day
andnext_business_day
can be implemented using the pypi "holidays" package or thepandas_market_calendars
package.your-local-timezone
is the timezone of your TV account, or the default timezone if not using an account.With this proposed fix, here's the corrected dates from the NQZ2024 contact:
The text was updated successfully, but these errors were encountered: