Skip to content

Commit 9e6842c

Browse files
authored
add test for full 2024 interval for is_market_open (#48)
* add test for full 2024 interval for is_market_open * fix typo * update 24 dec market close time for equity and rate * bump
1 parent 786bb58 commit 9e6842c

File tree

3 files changed

+1156
-7
lines changed

3 files changed

+1156
-7
lines changed

pythclient/calendar.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
datetime.datetime(2023, 11, 24, tzinfo=NY_TZ).date(),
3939
datetime.datetime(2024, 7, 3, tzinfo=NY_TZ).date(),
4040
datetime.datetime(2024, 11, 29, tzinfo=NY_TZ).date(),
41+
datetime.datetime(2024, 12, 24, tzinfo=NY_TZ).date(),
4142
]
4243

4344
FX_METAL_OPEN_CLOSE_TIME = datetime.time(17, 0, 0, tzinfo=NY_TZ)
@@ -76,6 +77,11 @@ def is_market_open(asset_type: str, dt: datetime.datetime) -> bool:
7677
if asset_type in ["fx", "metal"]:
7778
if date in FX_METAL_HOLIDAYS and time < FX_METAL_OPEN_CLOSE_TIME:
7879
return False
80+
# If the next day is a holiday, the market is closed at 5pm ET
81+
if (
82+
date + datetime.timedelta(days=1) in FX_METAL_HOLIDAYS
83+
) and time >= FX_METAL_OPEN_CLOSE_TIME:
84+
return False
7985
# On Friday the market is closed after 5pm
8086
if day == 4 and time >= FX_METAL_OPEN_CLOSE_TIME:
8187
return False
@@ -85,13 +91,6 @@ def is_market_open(asset_type: str, dt: datetime.datetime) -> bool:
8591
# On Sunday the market is closed before 5pm
8692
if day == 6 and time < FX_METAL_OPEN_CLOSE_TIME:
8793
return False
88-
# On Sunday the market is closed after 5pm if the next day is a holiday
89-
if (
90-
day == 6
91-
and time >= FX_METAL_OPEN_CLOSE_TIME
92-
and (date + datetime.timedelta(days=1) in FX_METAL_HOLIDAYS)
93-
):
94-
return False
9594

9695
return True
9796

0 commit comments

Comments
 (0)