Skip to content

Conversation

cctdaniel
Copy link
Contributor

@cctdaniel cctdaniel commented Dec 27, 2023

add exhaustive test every minute of 2024 for every asset type and test is_market_open against a list of hardcoded expected intervals

(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"),
Copy link
Contributor Author

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

Copy link

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"),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @ndiakom!

@cctdaniel cctdaniel enabled auto-merge (squash) January 9, 2024 02:19
import datetime

EQUITY_2024_INTERVALS = [
(datetime.date(2024, 1, 1), None),
Copy link
Contributor

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
Copy link
Contributor

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

@cctdaniel cctdaniel merged commit 9e6842c into main Jan 9, 2024
@cctdaniel cctdaniel deleted the calendar branch January 9, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants