nhedlund / qdownload

IQFeed CSV market data download tool
MIT License
24 stars 14 forks source link

one hour shift when downloading with different timezones #4

Closed lo-zed closed 2 years ago

lo-zed commented 2 years ago

problem

When downloading the same data from iqfeed with different timezones, e.g. -z UTC vs without option, there is a one hour time difference.

architecture

Ubuntu 20.04 LTS minimal, x86_64

steps to reproduce

qdownload -o EST --start 20210515 interval 300 seconds AAL
qdownload -z UTC -o UTC --start 20210515 interval 300 seconds AAL

and run attached python script.

sample output

Difference
TimedeltaIndex(['0 days 01:00:00', '0 days 01:00:00', '0 days 01:00:00',
                '0 days 01:00:00', '0 days 01:00:00', '0 days 01:00:00',
                '0 days 01:00:00', '0 days 01:00:00', '0 days 01:00:00',
                '0 days 01:00:00'],

               dtype='timedelta64[ns]', name='datetime', freq=None)

tz_investigation.zip

nhedlund commented 2 years ago

I looked at the CSV output files from qdownload you provided with EST and UTC and they have a 4 hour difference, and it seems that this is the correct time zone offset for EST at that date: https://www.timeanddate.com/worldclock/converter.html?iso=20210517T080000&p1=179&p2=tz_gmt

Maybe the compare code use the wrong time zone?

lo-zed commented 2 years ago

You're right. My mistake was to use pytz.timezone('EST') instead of pytz.timezone('America/New_York') which contains DST (daylight saving transitions) information, whereas EST doesn't. Changing the code to that timezone produces correct results.