Closed glossner closed 2 years ago
I will have a look in the next couple of days. Although, I am not sure whether I understand your point regarding holidays correctly. Would you mind elaborating on it, and maybe giving an example? Thanks.
I've attached just the MLK holiday schedule in full and compact form. Thanks 2021-mlk-day-holiday-schedule.xls 2021-mlk-day-schedule-compact.xls .
@Stryder-Git Also, if you want to provide the framework, I'll input all the dates. I say that because the changes you made to MarketCalendar were amazing and greatly simplified exchange_calendar_nyse. If nothing appears obvious to you, then I'll just brute-force it in code. Also, no rush. I'm crazy busy right now but will try to upgrade the CME calendars on weekends when I have availability. Thanks!
@glossner, Thanks for the kind words.
My first thoughts regarding the points you raised:
From my understanding, Sunday is not a 'normal' valid day like Mon-Fri, Sunday 23:00 UTC is just when Monday starts. Simply changing the weekmask to include Sundays would lead to a an extra trading day, starting on Saturdays at 23:00. Unfortunately, with a lot of the products on the CME exchanges, open times are a day before the "TRADE DATE" (https://www.cmegroup.com/trading-hours.html#foi=O&tradeDate=2022-02-22&pageNumber=2&exchanges=CME), so I am not sure if we can or should change this...
Weekday dependent breaks could be implemented by adding an optional weekmask field to the regular_market_times dictionary (like the offset), defining on what weekdays a market_time occurs. It could be handled in days_at_time, by replacing timestamps with NaNs when they shouldn't exist.
Regarding holidays, to be sure I understand the issue correctly, see the following example:
sched = cme.schedule("2021-01-15", "2021-01-20") # dates around MLK day 2021
print(sched.to_string())
market_open break_start break_end market_close
2021-01-15 2021-01-14 23:00:00+00:00 2021-01-15 21:15:00+00:00 2021-01-15 21:30:00+00:00 2021-01-15 22:00:00+00:00
2021-01-18 2021-01-17 23:00:00+00:00 2021-01-18 18:00:00+00:00 2021-01-18 18:00:00+00:00 2021-01-18 18:00:00+00:00
2021-01-19 2021-01-18 23:00:00+00:00 2021-01-19 21:15:00+00:00 2021-01-19 21:30:00+00:00 2021-01-19 22:00:00+00:00
2021-01-20 2021-01-19 23:00:00+00:00 2021-01-20 21:15:00+00:00 2021-01-20 21:30:00+00:00 2021-01-20 22:00:00+00:00
I also have quite the to-do list for the next couple of months but I would be willing to make the time to update the framework, if we work this out more. (Taking our time and splitting this into multiple PR's might also be a good idea then)
@rsheftel, and anyone who is reading this, your thoughts would be appreciated, Thanks!
@Stryder-Git I agree we should split this. I'll leave this thread open for a bit to see if others have comments. I will open new enhancements to discuss each feature. Thanks.
@Stryder-Git I agree that Sunday is just when Monday starts. The standard in the futures market is to say that the markets are open Mon-Sat. Agree that we should not consider Sunday a trading day.
Futures are certainly more complex than equities with regards to open/close/break, but I feel we could add a lot to the community but just starting with the existing framework and getting the holidays correct. If we want to update the framework for the futures complexity, that would be great, but I think not needed first pass
I'm closing this out and will re-open on a feature-by-feature basis.
@rsheftel I started looking into the CME calendars. Times are coded with a clever offset of -1 day so that Sunday starts are observed. A problem with this approach is that if you query valid_days(), Sundays are not included. This suggests the weekmask should be changed like in NYSE to include Sundays.
Another complication is that Sunday and Friday do not have a break but M-Thu do. That can be handled in code but maybe there is a more general solution?
During holidays there are multiple pre-open/open/halt/close times. See this link for 2021 holiday trading times. Should we code multiple times on the same day when it is a holiday e.g. special_opens() + special_closes()? Or something more general?
If you, @Stryder-Git, or others have any thoughts or suggestions it would be appreciated.
Thanks.