New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add breaks to TradingCalendar #154
Conversation
FYI @rsheftel - breaks here should be functionally similar to |
@gerrymanoim you may want to add the lunch break to the XSHG calendar as well. It is 11:30 AM - 1:00 PM Asia/Shanghai |
I was going to go through and add lunch breaks after the functional pieces of this PR were approved, happy to take care of it. |
@gerrymanoim makes sense. Once this lands on master I will look to add the CME specific calendars that require this feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming the boundary conditions and any other issues are all set, I'm a bit concerned about this as a behavior change for consumers (of all_minutes
, is_open_on_minute
, minute_to_session_label
, etc.). Should we try this out with any tests downstream?
return False | ||
else: | ||
return True | ||
|
||
else: | ||
try: | ||
# if they are the same, it might be the first minute of a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this case? Does it apply to the re-open minute after the break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now handled in the check above:
if break_start_on_open_dt <= minute_val < break_end_on_open_dt:
# we're in the middle of a break
return False
else:
return True
If minute_val==break_end_on_open_dt
we'll return True
.
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
What do you mean by that? There's a test in XHKG that tests if breaks are working correctly. |
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements! Added some suggestions. The preprocess change looked like the only breaking change.
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
Co-authored-by: Richard Frank <richafrank@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just had one suggestion.
Adds
break_start_times
andbreak_end_times
toTradingCalendar
to model intraday lunch breaks. These work as vectors of values, similarly to howopen_times
andclose_times
work so we can model break times changing over time.Threads the breaks through necessary methods.
Adds breaks to XHKG.
Items with
TODO
I'd especially like feedback on