|
1 | 1 | import datetime
|
2 | 2 | from zoneinfo import ZoneInfo
|
3 | 3 |
|
4 |
| -import pytest |
5 |
| - |
6 |
| -from pythclient.calendar import ( |
7 |
| - get_next_market_close, |
8 |
| - get_next_market_open, |
9 |
| - is_market_open, |
10 |
| -) |
| 4 | +from pythclient.calendar import (get_next_market_close, get_next_market_open, |
| 5 | + is_market_open) |
11 | 6 |
|
12 | 7 | NY_TZ = ZoneInfo("America/New_York")
|
13 | 8 | UTC_TZ = ZoneInfo("UTC")
|
14 | 9 |
|
| 10 | +# Define constants for equity market |
| 11 | +EQUITY_OPEN_WED_2023_6_21_12 = datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) |
| 12 | +EQUITY_CLOSE_WED_2023_6_21_17 = datetime.datetime(2023, 6, 21, 17, 0, 0, tzinfo=NY_TZ) |
| 13 | +EQUITY_CLOSE_SAT_2023_6_10_17 = datetime.datetime(2023, 6, 10, 17, 0, 0, tzinfo=NY_TZ) |
| 14 | +EQUITY_HOLIDAY_MON_2023_6_19 = datetime.datetime(2023, 6, 19, tzinfo=NY_TZ) |
| 15 | +EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14 = datetime.datetime(2023, 11, 24, 11, 0, 0, tzinfo=NY_TZ) |
| 16 | +EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14 = datetime.datetime(2023, 11, 24, 14, 0, 0, tzinfo=NY_TZ) |
15 | 17 |
|
16 |
| -@pytest.fixture |
17 |
| -def equity_open_weekday_datetime(): |
18 |
| - # A weekday, within equity market hours |
19 |
| - return datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) |
20 |
| - |
21 |
| - |
22 |
| -@pytest.fixture |
23 |
| -def equity_close_weekday_datetime(): |
24 |
| - # A weekday, out of equity market hours |
25 |
| - return datetime.datetime(2023, 6, 21, 17, 0, 0, tzinfo=NY_TZ) |
26 |
| - |
27 |
| - |
28 |
| -@pytest.fixture |
29 |
| -def equity_close_weekend_datetime(): |
30 |
| - # A weekend, out of equity market hours |
31 |
| - return datetime.datetime(2023, 6, 10, 17, 0, 0, tzinfo=NY_TZ) |
32 |
| - |
33 |
| - |
34 |
| -@pytest.fixture |
35 |
| -def equity_holiday_datetime(): |
36 |
| - # A weekday, NYSE holiday |
37 |
| - return datetime.datetime(2023, 6, 19, tzinfo=NY_TZ) |
38 |
| - |
39 |
| - |
40 |
| -@pytest.fixture |
41 |
| -def equity_early_holiday_open_datetime(): |
42 |
| - # A weekday, NYSE early close holiday |
43 |
| - return datetime.datetime(2023, 11, 24, 11, 0, 0, tzinfo=NY_TZ) |
44 |
| - |
45 |
| - |
46 |
| -@pytest.fixture |
47 |
| -def equity_early_holiday_close_datetime(): |
48 |
| - # A weekday, NYSE early close holiday |
49 |
| - return datetime.datetime(2023, 11, 24, 14, 0, 0, tzinfo=NY_TZ) |
50 |
| - |
| 18 | +# Define constants for fx & metal market |
| 19 | +FX_METAL_OPEN_WED_2023_6_21_22 = datetime.datetime(2023, 6, 21, 22, 0, 0, tzinfo=NY_TZ) |
| 20 | +FX_METAL_CLOSE_SUN_2023_6_18_16 = datetime.datetime(2023, 6, 18, 16, 0, 0, tzinfo=NY_TZ) |
| 21 | +FX_METAL_HOLIDAY_SUN_2023_1_1 = datetime.datetime(2023, 1, 1, tzinfo=NY_TZ) |
51 | 22 |
|
52 |
| -@pytest.fixture |
53 |
| -def fx_metal_open_weekday_datetime(): |
54 |
| - # A weekday, within fx & metal market hours |
55 |
| - return datetime.datetime(2023, 6, 21, 22, 0, 0, tzinfo=NY_TZ) |
| 23 | +# Define constants for cryptocurrency market |
| 24 | +CRYPTO_OPEN_WED_2023_6_21_12 = datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) |
| 25 | +CRYPTO_OPEN_SUN_2023_6_18_12 = datetime.datetime(2023, 6, 18, 12, 0, 0, tzinfo=NY_TZ) |
56 | 26 |
|
| 27 | +def format_datetime_to_utc_iso_string(dt: datetime.datetime): |
| 28 | + return dt.astimezone(UTC_TZ).strftime("%Y-%m-%dT%H:%M:%S") + "Z" |
57 | 29 |
|
58 |
| -@pytest.fixture |
59 |
| -def fx_metal_close_weekend_datetime(): |
60 |
| - # A weekend, out of fx & metal market hours |
61 |
| - return datetime.datetime(2023, 6, 18, 16, 0, 0, tzinfo=NY_TZ) |
62 |
| - |
63 |
| - |
64 |
| -@pytest.fixture |
65 |
| -def fx_metal_holiday_datetime(): |
66 |
| - # CBOE holiday |
67 |
| - return datetime.datetime(2023, 1, 1, tzinfo=NY_TZ) |
68 |
| - |
69 |
| - |
70 |
| -@pytest.fixture |
71 |
| -def crypto_open_weekday_datetime(): |
72 |
| - return datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) |
73 |
| - |
74 |
| - |
75 |
| -@pytest.fixture |
76 |
| -def crypto_open_weekend_datetime(): |
77 |
| - return datetime.datetime(2023, 6, 18, 12, 0, 0, tzinfo=NY_TZ) |
78 |
| - |
79 |
| - |
80 |
| -def test_is_market_open( |
81 |
| - equity_open_weekday_datetime, |
82 |
| - equity_close_weekday_datetime, |
83 |
| - equity_close_weekend_datetime, |
84 |
| - equity_holiday_datetime, |
85 |
| - equity_early_holiday_open_datetime, |
86 |
| - equity_early_holiday_close_datetime, |
87 |
| - fx_metal_open_weekday_datetime, |
88 |
| - fx_metal_close_weekend_datetime, |
89 |
| - fx_metal_holiday_datetime, |
90 |
| - crypto_open_weekday_datetime, |
91 |
| - crypto_open_weekend_datetime, |
92 |
| -): |
| 30 | +def test_is_market_open(): |
93 | 31 | # equity
|
94 | 32 | # weekday, within equity market hours
|
95 |
| - assert is_market_open("equity", equity_open_weekday_datetime) == True |
| 33 | + assert is_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) == True |
96 | 34 |
|
97 | 35 | # weekday, out of equity market hours
|
98 |
| - assert is_market_open("equity", equity_close_weekday_datetime) == False |
| 36 | + assert is_market_open("equity", EQUITY_CLOSE_WED_2023_6_21_17) == False |
99 | 37 |
|
100 | 38 | # weekend, out of equity market hours
|
101 |
| - assert is_market_open("equity", equity_close_weekend_datetime) == False |
| 39 | + assert is_market_open("equity", EQUITY_CLOSE_SAT_2023_6_10_17) == False |
102 | 40 |
|
103 | 41 | # weekday, NYSE holiday
|
104 |
| - assert is_market_open("equity", equity_holiday_datetime) == False |
| 42 | + assert is_market_open("equity", EQUITY_HOLIDAY_MON_2023_6_19) == False |
105 | 43 |
|
106 | 44 | # weekday, NYSE early close holiday
|
107 |
| - assert is_market_open("equity", equity_early_holiday_open_datetime) == True |
108 |
| - assert is_market_open("equity", equity_early_holiday_close_datetime) == False |
| 45 | + assert is_market_open("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) == True |
| 46 | + assert is_market_open("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) == False |
109 | 47 |
|
110 | 48 | # fx & metal
|
111 | 49 | # weekday, within fx & metal market hours
|
112 |
| - assert is_market_open("fx", fx_metal_open_weekday_datetime) == True |
113 |
| - assert is_market_open("metal", fx_metal_open_weekday_datetime) == True |
| 50 | + assert is_market_open("fx", FX_METAL_OPEN_WED_2023_6_21_22) == True |
| 51 | + assert is_market_open("metal", FX_METAL_OPEN_WED_2023_6_21_22) == True |
114 | 52 |
|
115 | 53 | # weekday, out of fx & metal market hours
|
116 |
| - assert is_market_open("fx", fx_metal_close_weekend_datetime) == False |
117 |
| - assert is_market_open("metal", fx_metal_close_weekend_datetime) == False |
| 54 | + assert is_market_open("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) == False |
| 55 | + assert is_market_open("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) == False |
118 | 56 |
|
119 | 57 | # fx & metal holiday
|
120 |
| - assert is_market_open("fx", fx_metal_holiday_datetime) == False |
121 |
| - assert is_market_open("metal", fx_metal_holiday_datetime) == False |
| 58 | + assert is_market_open("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) == False |
| 59 | + assert is_market_open("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) == False |
122 | 60 |
|
123 | 61 | # crypto
|
124 |
| - assert is_market_open("crypto", crypto_open_weekday_datetime) == True |
125 |
| - assert is_market_open("crypto", crypto_open_weekend_datetime) == True |
126 |
| - |
127 |
| - |
128 |
| -def test_get_next_market_open( |
129 |
| - equity_open_weekday_datetime, |
130 |
| - equity_close_weekday_datetime, |
131 |
| - equity_close_weekend_datetime, |
132 |
| - equity_holiday_datetime, |
133 |
| - equity_early_holiday_open_datetime, |
134 |
| - equity_early_holiday_close_datetime, |
135 |
| - fx_metal_open_weekday_datetime, |
136 |
| - fx_metal_close_weekend_datetime, |
137 |
| - fx_metal_holiday_datetime, |
138 |
| - crypto_open_weekday_datetime, |
139 |
| - crypto_open_weekend_datetime, |
140 |
| -): |
| 62 | + assert is_market_open("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == True |
| 63 | + assert is_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == True |
| 64 | + |
| 65 | + |
| 66 | +def test_get_next_market_open(): |
141 | 67 | # equity within market hours
|
142 | 68 | assert (
|
143 |
| - get_next_market_open("equity", equity_open_weekday_datetime) |
144 |
| - == datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ) |
145 |
| - .astimezone(UTC_TZ) |
146 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
147 |
| - + "Z" |
| 69 | + get_next_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) |
| 70 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ)) |
148 | 71 | )
|
149 | 72 |
|
150 | 73 | # equity out of market hours
|
151 | 74 | assert (
|
152 |
| - get_next_market_open("equity", equity_close_weekday_datetime) |
153 |
| - == datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ) |
154 |
| - .astimezone(UTC_TZ) |
155 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
156 |
| - + "Z" |
| 75 | + get_next_market_open("equity", EQUITY_CLOSE_WED_2023_6_21_17) |
| 76 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ)) |
157 | 77 | )
|
158 | 78 |
|
159 | 79 | # equity weekend
|
160 | 80 | assert (
|
161 |
| - get_next_market_open("equity", equity_close_weekend_datetime) |
162 |
| - == datetime.datetime(2023, 6, 12, 9, 30, 0, tzinfo=NY_TZ) |
163 |
| - .astimezone(UTC_TZ) |
164 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
165 |
| - + "Z" |
| 81 | + get_next_market_open("equity", EQUITY_CLOSE_SAT_2023_6_10_17) |
| 82 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 12, 9, 30, 0, tzinfo=NY_TZ)) |
166 | 83 | )
|
167 | 84 |
|
168 | 85 | # equity holiday
|
169 | 86 | assert (
|
170 |
| - get_next_market_open("equity", equity_holiday_datetime) |
171 |
| - == datetime.datetime(2023, 6, 20, 9, 30, 0, tzinfo=NY_TZ) |
172 |
| - .astimezone(UTC_TZ) |
173 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
174 |
| - + "Z" |
| 87 | + get_next_market_open("equity", EQUITY_HOLIDAY_MON_2023_6_19) |
| 88 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 20, 9, 30, 0, tzinfo=NY_TZ)) |
175 | 89 | )
|
176 | 90 |
|
177 | 91 | # equity early close holiday
|
178 | 92 | assert (
|
179 |
| - get_next_market_open("equity", equity_early_holiday_open_datetime) |
180 |
| - == datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ) |
181 |
| - .astimezone(UTC_TZ) |
182 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
183 |
| - + "Z" |
| 93 | + get_next_market_open("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) |
| 94 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ)) |
184 | 95 | )
|
185 | 96 | assert (
|
186 |
| - get_next_market_open("equity", equity_early_holiday_close_datetime) |
187 |
| - == datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ) |
188 |
| - .astimezone(UTC_TZ) |
189 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
190 |
| - + "Z" |
| 97 | + get_next_market_open("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) |
| 98 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ)) |
191 | 99 | )
|
192 | 100 |
|
193 | 101 | # fx & metal within market hours
|
194 | 102 | assert (
|
195 |
| - get_next_market_open("fx", fx_metal_open_weekday_datetime) |
196 |
| - == datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ) |
197 |
| - .astimezone(UTC_TZ) |
198 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
199 |
| - + "Z" |
| 103 | + get_next_market_open("fx", FX_METAL_OPEN_WED_2023_6_21_22) |
| 104 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ)) |
200 | 105 | )
|
201 | 106 | assert (
|
202 |
| - get_next_market_open("metal", fx_metal_open_weekday_datetime) |
203 |
| - == datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ) |
204 |
| - .astimezone(UTC_TZ) |
205 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
206 |
| - + "Z" |
| 107 | + get_next_market_open("metal", FX_METAL_OPEN_WED_2023_6_21_22) |
| 108 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ)) |
207 | 109 | )
|
208 | 110 |
|
209 | 111 | # fx & metal out of market hours
|
210 | 112 | assert (
|
211 |
| - get_next_market_open("fx", fx_metal_close_weekend_datetime) |
212 |
| - == datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ) |
213 |
| - .astimezone(UTC_TZ) |
214 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
215 |
| - + "Z" |
| 113 | + get_next_market_open("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) |
| 114 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ)) |
216 | 115 | )
|
217 | 116 | assert (
|
218 |
| - get_next_market_open("metal", fx_metal_close_weekend_datetime) |
219 |
| - == datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ) |
220 |
| - .astimezone(UTC_TZ) |
221 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
222 |
| - + "Z" |
| 117 | + get_next_market_open("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) |
| 118 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ)) |
223 | 119 | )
|
224 | 120 |
|
225 | 121 | # fx & metal holiday
|
226 | 122 | assert (
|
227 |
| - get_next_market_open("fx", fx_metal_holiday_datetime) |
228 |
| - == datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ) |
229 |
| - .astimezone(UTC_TZ) |
230 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
231 |
| - + "Z" |
| 123 | + get_next_market_open("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) |
| 124 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ)) |
232 | 125 | )
|
233 | 126 | assert (
|
234 |
| - get_next_market_open("metal", fx_metal_holiday_datetime) |
235 |
| - == datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ) |
236 |
| - .astimezone(UTC_TZ) |
237 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
238 |
| - + "Z" |
| 127 | + get_next_market_open("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) |
| 128 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ)) |
239 | 129 | )
|
240 | 130 |
|
241 | 131 | # crypto
|
242 |
| - assert get_next_market_open("crypto", crypto_open_weekday_datetime) == None |
243 |
| - assert get_next_market_open("crypto", crypto_open_weekend_datetime) == None |
244 |
| - |
245 |
| - |
246 |
| -def test_get_next_market_close( |
247 |
| - equity_open_weekday_datetime, |
248 |
| - equity_close_weekday_datetime, |
249 |
| - equity_close_weekend_datetime, |
250 |
| - equity_holiday_datetime, |
251 |
| - equity_early_holiday_open_datetime, |
252 |
| - equity_early_holiday_close_datetime, |
253 |
| - fx_metal_open_weekday_datetime, |
254 |
| - fx_metal_close_weekend_datetime, |
255 |
| - fx_metal_holiday_datetime, |
256 |
| - crypto_open_weekday_datetime, |
257 |
| - crypto_open_weekend_datetime, |
258 |
| -): |
| 132 | + assert get_next_market_open("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == None |
| 133 | + assert get_next_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == None |
| 134 | + |
| 135 | + |
| 136 | +def test_get_next_market_close(): |
259 | 137 | # equity within market hours
|
260 | 138 | assert (
|
261 |
| - get_next_market_close("equity", equity_open_weekday_datetime) |
262 |
| - == datetime.datetime(2023, 6, 21, 16, 0, 0, tzinfo=NY_TZ) |
263 |
| - .astimezone(UTC_TZ) |
264 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
265 |
| - + "Z" |
| 139 | + get_next_market_close("equity", EQUITY_OPEN_WED_2023_6_21_12) |
| 140 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 21, 16, 0, 0, tzinfo=NY_TZ)) |
266 | 141 | )
|
267 | 142 |
|
268 | 143 | # equity out of market hours
|
269 | 144 | assert (
|
270 |
| - get_next_market_close("equity", equity_close_weekday_datetime) |
271 |
| - == datetime.datetime(2023, 6, 22, 16, 0, 0, tzinfo=NY_TZ) |
272 |
| - .astimezone(UTC_TZ) |
273 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
274 |
| - + "Z" |
| 145 | + get_next_market_close("equity", EQUITY_CLOSE_WED_2023_6_21_17) |
| 146 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 16, 0, 0, tzinfo=NY_TZ)) |
275 | 147 | )
|
276 | 148 |
|
277 | 149 | # equity weekend
|
278 | 150 | assert (
|
279 |
| - get_next_market_close("equity", equity_close_weekend_datetime) |
280 |
| - == datetime.datetime(2023, 6, 12, 16, 0, 0, tzinfo=NY_TZ) |
281 |
| - .astimezone(UTC_TZ) |
282 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
283 |
| - + "Z" |
| 151 | + get_next_market_close("equity", EQUITY_CLOSE_SAT_2023_6_10_17) |
| 152 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 12, 16, 0, 0, tzinfo=NY_TZ)) |
284 | 153 | )
|
285 | 154 |
|
286 | 155 | # equity holiday
|
287 | 156 | assert (
|
288 |
| - get_next_market_close("equity", equity_holiday_datetime) |
289 |
| - == datetime.datetime(2023, 6, 20, 16, 0, 0, tzinfo=NY_TZ) |
290 |
| - .astimezone(UTC_TZ) |
291 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
292 |
| - + "Z" |
| 157 | + get_next_market_close("equity", EQUITY_HOLIDAY_MON_2023_6_19) |
| 158 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 20, 16, 0, 0, tzinfo=NY_TZ)) |
293 | 159 | )
|
294 | 160 |
|
295 | 161 | # equity early close holiday
|
296 | 162 | assert (
|
297 |
| - get_next_market_close("equity", equity_early_holiday_open_datetime) |
298 |
| - == datetime.datetime(2023, 11, 24, 13, 0, 0, tzinfo=NY_TZ) |
299 |
| - .astimezone(UTC_TZ) |
300 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
301 |
| - + "Z" |
| 163 | + get_next_market_close("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) |
| 164 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 24, 13, 0, 0, tzinfo=NY_TZ)) |
302 | 165 | )
|
303 | 166 | assert (
|
304 |
| - get_next_market_close("equity", equity_early_holiday_close_datetime) |
305 |
| - == datetime.datetime(2023, 11, 27, 16, 0, 0, tzinfo=NY_TZ) |
306 |
| - .astimezone(UTC_TZ) |
307 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
308 |
| - + "Z" |
| 167 | + get_next_market_close("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) |
| 168 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 16, 0, 0, tzinfo=NY_TZ)) |
309 | 169 | )
|
310 | 170 |
|
311 | 171 | # fx & metal within market hours
|
312 | 172 | assert (
|
313 |
| - get_next_market_close("fx", fx_metal_open_weekday_datetime) |
314 |
| - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) |
315 |
| - .astimezone(UTC_TZ) |
316 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
317 |
| - + "Z" |
| 173 | + get_next_market_close("fx", FX_METAL_OPEN_WED_2023_6_21_22) |
| 174 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) |
318 | 175 | )
|
319 | 176 | assert (
|
320 |
| - get_next_market_close("metal", fx_metal_open_weekday_datetime) |
321 |
| - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) |
322 |
| - .astimezone(UTC_TZ) |
323 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
324 |
| - + "Z" |
| 177 | + get_next_market_close("metal", FX_METAL_OPEN_WED_2023_6_21_22) |
| 178 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) |
325 | 179 | )
|
326 | 180 |
|
327 | 181 | # fx & metal out of market hours
|
328 | 182 | assert (
|
329 |
| - get_next_market_close("fx", fx_metal_close_weekend_datetime) |
330 |
| - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) |
331 |
| - .astimezone(UTC_TZ) |
332 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
333 |
| - + "Z" |
| 183 | + get_next_market_close("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) |
| 184 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) |
334 | 185 | )
|
335 | 186 | assert (
|
336 |
| - get_next_market_close("metal", fx_metal_close_weekend_datetime) |
337 |
| - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) |
338 |
| - .astimezone(UTC_TZ) |
339 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
340 |
| - + "Z" |
| 187 | + get_next_market_close("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) |
| 188 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) |
341 | 189 | )
|
342 | 190 |
|
343 | 191 | # fx & metal holiday
|
344 | 192 | assert (
|
345 |
| - get_next_market_close("fx", fx_metal_holiday_datetime) |
346 |
| - == datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ) |
347 |
| - .astimezone(UTC_TZ) |
348 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
349 |
| - + "Z" |
| 193 | + get_next_market_close("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) |
| 194 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ)) |
350 | 195 | )
|
351 | 196 | assert (
|
352 |
| - get_next_market_close("metal", fx_metal_holiday_datetime) |
353 |
| - == datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ) |
354 |
| - .astimezone(UTC_TZ) |
355 |
| - .strftime("%Y-%m-%dT%H:%M:%S") |
356 |
| - + "Z" |
| 197 | + get_next_market_close("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) |
| 198 | + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ)) |
357 | 199 | )
|
358 | 200 |
|
359 | 201 | # crypto
|
360 |
| - assert get_next_market_close("crypto", crypto_open_weekday_datetime) == None |
361 |
| - assert get_next_market_close("crypto", crypto_open_weekend_datetime) == None |
| 202 | + assert get_next_market_close("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == None |
| 203 | + assert get_next_market_close("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == None |
0 commit comments