0

I am searching through a dataframe with years of hourly data, looking at certain market opening hours.

I read that I can use EST, which works fine for looking at London & New York market hours, but when looking at Sydney & Tokyo, whether it is GMT or EST, the hours change due to DST.

I looked at this question/answer: Pandas DataFrame Daylight Savings adjustment is wrong during the transition weeks?

And I am looking at the market hours here:

U.S Spring / Summer Session        U.S Autumn / Winter Session
Session         GMT     EST        Session          GMT     EST
Sydney Open     22:00   18:00      Sydney Open      21:00   16:00
Sydney Close    07:00   03:00      Sydney Close     06:00   01:00
Tokyo Open      23:00   19:00      Tokyo Open       23:00   18:00
Tokyo Close     08:00   04:00      Tokyo Close      08:00   03:00
London Open     07:00   03:00      London Open      08:00   03:00
London Close    16:00   12:00      London Close     17:00   12:00
New York Open   12:00   08:00      New York Open    13:00   08:00
New York Close  21:00   17:00      New York Close   22:00   17:00

Currently my code just looks like this:

# london hours in US spring/summer session = (GMT) 07:00 -> 16:00
start_time1 = ('07:00:00')
end_time1 = ('16:00:00')

print("London Market Hours 07:00 - 16:00")
print(df1H.between_time(start_time1,end_time1)

#outputs all rows between these hours (not accounting for DST!)

How can I account for the change in opening hours when pulling out the selected market hours?

EDIT:

If i were to use these hours listed in UTC here: https://www.liteforex.com/blog/for-beginners/time-at-forex/ , Would I not have to worry about DST?

  • 2
    Much better to get the hours in local time and then use the time zones to move it UTC. https://stackoverflow.com/questions/79797/how-to-convert-local-time-string-to-utc. Note that the day will change when comparing the US close to the Aussie open... – Paul Brennan Feb 04 '21 at 14:04
  • So convert the existing GMT dataframe into copies with the respective time zones for the market open hours, and then convert each dataframe with the different time zones to UTC? Because UTC is constant and is not effected by DST? – helloworldnoob Feb 04 '21 at 14:24
  • 1
    try to work with UTC (==GMT) as long as you can - for user output, you can still convert that to specific time zones (see [tz_convert](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.tz_convert.html)) – FObersteiner Feb 04 '21 at 14:29
  • If i were to use these hours listed in UTC here: https://www.liteforex.com/blog/for-beginners/time-at-forex/ , Would I not have to worry about DST? (also updating my question with this) – helloworldnoob Feb 04 '21 at 17:16
  • 1
    @helloworldnoob: no. UTC has no DST. that's one of the reasons you should use it as the basis of time series analysis. And if somebody wants e.g. trading times in their local tz, just convert to that tz from UTC - the result will also show DST changes if applicable for the tz you convert to. – FObersteiner Feb 05 '21 at 07:18

0 Answers0