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
4344FX_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