38
38
datetime .datetime (2023 , 11 , 24 , tzinfo = NY_TZ ).date (),
39
39
datetime .datetime (2024 , 7 , 3 , tzinfo = NY_TZ ).date (),
40
40
datetime .datetime (2024 , 11 , 29 , tzinfo = NY_TZ ).date (),
41
+ datetime .datetime (2024 , 12 , 24 , tzinfo = NY_TZ ).date (),
41
42
]
42
43
43
44
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:
76
77
if asset_type in ["fx" , "metal" ]:
77
78
if date in FX_METAL_HOLIDAYS and time < FX_METAL_OPEN_CLOSE_TIME :
78
79
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
79
85
# On Friday the market is closed after 5pm
80
86
if day == 4 and time >= FX_METAL_OPEN_CLOSE_TIME :
81
87
return False
@@ -85,13 +91,6 @@ def is_market_open(asset_type: str, dt: datetime.datetime) -> bool:
85
91
# On Sunday the market is closed before 5pm
86
92
if day == 6 and time < FX_METAL_OPEN_CLOSE_TIME :
87
93
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
95
94
96
95
return True
97
96
0 commit comments