-
Notifications
You must be signed in to change notification settings - Fork 28
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
add test for full 2024 interval for is_market_open #48
Conversation
(datetime.date(2024, 12, 22), "1700-0000"), | ||
(datetime.date(2024, 12, 23), "0000-0000"), | ||
(datetime.date(2024, 12, 24), "0000-1700"), | ||
(datetime.date(2024, 12, 25), "1700-000"), |
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.
according to Cboe FX a trade date start time is 5pm ET, this logic is inline with 25 Dec 2023 where 24 was a Sunday so for 25 Dec 2024 it's a Wednesday which means using the same logic, market should be closed from Tuesday 24 Dec 5pm to Wed 25 Dec 5pm
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.
I called CBOE.
They will announce 2024 holidays for FX here in early Jan: https://www.cboe.com/global/fx/
Assuming it's their usual Christmas and New Year's holiday, then @cctdaniel your 24 Dec 5PM ET - 25 Dec 5PM ET holiday is correct.
On 24 Dec 2024 5PM ET they'd close and they'd reopen 25 Dec 2025 5PM.
But let's wait for Jan 2024's announcement to confirm this.
Also, you missed a zero:
(datetime.date(2024, 12, 25), "1700-000"),
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.
thank you @ndiakom!
import datetime | ||
|
||
EQUITY_2024_INTERVALS = [ | ||
(datetime.date(2024, 1, 1), None), |
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.
fwiw i think you could have done this with less code by doing it in terms of weeks, then having a variable for like a "standard week". then you'd only need to vary from that for the weeks with holidays.
same comment for FX
not a big deal though since you've done it now
start_time, end_time = [datetime.datetime.strptime(t, "%H%M").time() for t in interval.split('-')] | ||
if start_time < end_time: | ||
should_be_open = start_time <= current_date.time() < end_time | ||
else: # Over midnight |
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.
fwiw i think it would be better to specify midnight as 2400 so that start_time is always < end_time
this logic would do something odd if someone specified an invalid interval like 0200-0100
add exhaustive test every minute of 2024 for every asset type and test
is_market_open
against a list of hardcoded expected intervals