From 8e8dc323fc356a11b60c33ff7d7173089eb71f8a Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Mon, 26 Jun 2023 13:55:32 +0800 Subject: [PATCH 1/3] refactor --- tests/test_calendar.py | 356 ++++++++++++++--------------------------- 1 file changed, 117 insertions(+), 239 deletions(-) diff --git a/tests/test_calendar.py b/tests/test_calendar.py index f9bf1a9..fb4cb92 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -1,361 +1,239 @@ import datetime from zoneinfo import ZoneInfo -import pytest - -from pythclient.calendar import ( - get_next_market_close, - get_next_market_open, - is_market_open, -) +from pythclient.calendar import (get_next_market_close, get_next_market_open, + is_market_open) NY_TZ = ZoneInfo("America/New_York") UTC_TZ = ZoneInfo("UTC") +# Define constants for equity market +EQUITY_OPEN_WED_2023_6_21_12 = datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) +EQUITY_CLOSE_WED_2023_6_21_17 = datetime.datetime(2023, 6, 21, 17, 0, 0, tzinfo=NY_TZ) +EQUITY_CLOSE_SAT_2023_6_10_17 = datetime.datetime(2023, 6, 10, 17, 0, 0, tzinfo=NY_TZ) +EQUITY_HOLIDAY_MON_2023_6_19 = datetime.datetime(2023, 6, 19, tzinfo=NY_TZ) +EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14 = datetime.datetime(2023, 11, 24, 11, 0, 0, tzinfo=NY_TZ) +EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14 = datetime.datetime(2023, 11, 24, 14, 0, 0, tzinfo=NY_TZ) -@pytest.fixture -def equity_open_weekday_datetime(): - # A weekday, within equity market hours - return datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def equity_close_weekday_datetime(): - # A weekday, out of equity market hours - return datetime.datetime(2023, 6, 21, 17, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def equity_close_weekend_datetime(): - # A weekend, out of equity market hours - return datetime.datetime(2023, 6, 10, 17, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def equity_holiday_datetime(): - # A weekday, NYSE holiday - return datetime.datetime(2023, 6, 19, tzinfo=NY_TZ) - - -@pytest.fixture -def equity_early_holiday_open_datetime(): - # A weekday, NYSE early close holiday - return datetime.datetime(2023, 11, 24, 11, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def equity_early_holiday_close_datetime(): - # A weekday, NYSE early close holiday - return datetime.datetime(2023, 11, 24, 14, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def fx_metal_open_weekday_datetime(): - # A weekday, within fx & metal market hours - return datetime.datetime(2023, 6, 21, 22, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def fx_metal_close_weekend_datetime(): - # A weekend, out of fx & metal market hours - return datetime.datetime(2023, 6, 18, 16, 0, 0, tzinfo=NY_TZ) - - -@pytest.fixture -def fx_metal_holiday_datetime(): - # CBOE holiday - return datetime.datetime(2023, 1, 1, tzinfo=NY_TZ) - - -@pytest.fixture -def crypto_open_weekday_datetime(): - return datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) - +# Define constants for fx & metal market +FX_METAL_OPEN_WED_2023_6_21_22 = datetime.datetime(2023, 6, 21, 22, 0, 0, tzinfo=NY_TZ) +FX_METAL_CLOSE_SUN_2023_6_18_16 = datetime.datetime(2023, 6, 18, 16, 0, 0, tzinfo=NY_TZ) +FX_METAL_HOLIDAY_SUN_2023_1_1 = datetime.datetime(2023, 1, 1, tzinfo=NY_TZ) -@pytest.fixture -def crypto_open_weekend_datetime(): - return datetime.datetime(2023, 6, 18, 12, 0, 0, tzinfo=NY_TZ) +# Define constants for cryptocurrency market +CRYPTO_OPEN_WED_2023_6_21_12 = datetime.datetime(2023, 6, 21, 12, 0, 0, tzinfo=NY_TZ) +CRYPTO_OPEN_SUN_2023_6_18_12 = datetime.datetime(2023, 6, 18, 12, 0, 0, tzinfo=NY_TZ) +def format_datetime_to_utc_iso_string(dt: datetime.datetime): + return dt.astimezone(UTC_TZ).strftime("%Y-%m-%dT%H:%M:%S") + "Z" def test_is_market_open( - equity_open_weekday_datetime, - equity_close_weekday_datetime, - equity_close_weekend_datetime, - equity_holiday_datetime, - equity_early_holiday_open_datetime, - equity_early_holiday_close_datetime, - fx_metal_open_weekday_datetime, - fx_metal_close_weekend_datetime, - fx_metal_holiday_datetime, - crypto_open_weekday_datetime, - crypto_open_weekend_datetime, + EQUITY_OPEN_WED_2023_6_21_12, + EQUITY_CLOSE_WED_2023_6_21_17, + EQUITY_CLOSE_SAT_2023_6_10_17, + EQUITY_HOLIDAY_MON_2023_6_19, + EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, + EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, + FX_METAL_OPEN_WED_2023_6_21_22, + FX_METAL_CLOSE_SUN_2023_6_18_16, + FX_METAL_HOLIDAY_SUN_2023_1_1, + CRYPTO_OPEN_WED_2023_6_21_12, + CRYPTO_OPEN_SUN_2023_6_18_12, ): # equity # weekday, within equity market hours - assert is_market_open("equity", equity_open_weekday_datetime) == True + assert is_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) == True # weekday, out of equity market hours - assert is_market_open("equity", equity_close_weekday_datetime) == False + assert is_market_open("equity", EQUITY_CLOSE_WED_2023_6_21_17) == False # weekend, out of equity market hours - assert is_market_open("equity", equity_close_weekend_datetime) == False + assert is_market_open("equity", EQUITY_CLOSE_SAT_2023_6_10_17) == False # weekday, NYSE holiday - assert is_market_open("equity", equity_holiday_datetime) == False + assert is_market_open("equity", EQUITY_HOLIDAY_MON_2023_6_19) == False # weekday, NYSE early close holiday - assert is_market_open("equity", equity_early_holiday_open_datetime) == True - assert is_market_open("equity", equity_early_holiday_close_datetime) == False + assert is_market_open("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) == True + assert is_market_open("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) == False # fx & metal # weekday, within fx & metal market hours - assert is_market_open("fx", fx_metal_open_weekday_datetime) == True - assert is_market_open("metal", fx_metal_open_weekday_datetime) == True + assert is_market_open("fx", FX_METAL_OPEN_WED_2023_6_21_22) == True + assert is_market_open("metal", FX_METAL_OPEN_WED_2023_6_21_22) == True # weekday, out of fx & metal market hours - assert is_market_open("fx", fx_metal_close_weekend_datetime) == False - assert is_market_open("metal", fx_metal_close_weekend_datetime) == False + assert is_market_open("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) == False + assert is_market_open("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) == False # fx & metal holiday - assert is_market_open("fx", fx_metal_holiday_datetime) == False - assert is_market_open("metal", fx_metal_holiday_datetime) == False + assert is_market_open("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) == False + assert is_market_open("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) == False # crypto - assert is_market_open("crypto", crypto_open_weekday_datetime) == True - assert is_market_open("crypto", crypto_open_weekend_datetime) == True + assert is_market_open("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == True + assert is_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == True def test_get_next_market_open( - equity_open_weekday_datetime, - equity_close_weekday_datetime, - equity_close_weekend_datetime, - equity_holiday_datetime, - equity_early_holiday_open_datetime, - equity_early_holiday_close_datetime, - fx_metal_open_weekday_datetime, - fx_metal_close_weekend_datetime, - fx_metal_holiday_datetime, - crypto_open_weekday_datetime, - crypto_open_weekend_datetime, + EQUITY_OPEN_WED_2023_6_21_12, + EQUITY_CLOSE_WED_2023_6_21_17, + EQUITY_CLOSE_SAT_2023_6_10_17, + EQUITY_HOLIDAY_MON_2023_6_19, + EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, + EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, + FX_METAL_OPEN_WED_2023_6_21_22, + FX_METAL_CLOSE_SUN_2023_6_18_16, + FX_METAL_HOLIDAY_SUN_2023_1_1, + CRYPTO_OPEN_WED_2023_6_21_12, + CRYPTO_OPEN_SUN_2023_6_18_12, ): # equity within market hours assert ( - get_next_market_open("equity", equity_open_weekday_datetime) - == datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ)) ) # equity out of market hours assert ( - get_next_market_open("equity", equity_close_weekday_datetime) - == datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_CLOSE_WED_2023_6_21_17) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 9, 30, 0, tzinfo=NY_TZ)) ) # equity weekend assert ( - get_next_market_open("equity", equity_close_weekend_datetime) - == datetime.datetime(2023, 6, 12, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_CLOSE_SAT_2023_6_10_17) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 12, 9, 30, 0, tzinfo=NY_TZ)) ) # equity holiday assert ( - get_next_market_open("equity", equity_holiday_datetime) - == datetime.datetime(2023, 6, 20, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_HOLIDAY_MON_2023_6_19) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 20, 9, 30, 0, tzinfo=NY_TZ)) ) # equity early close holiday assert ( - get_next_market_open("equity", equity_early_holiday_open_datetime) - == datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_open("equity", equity_early_holiday_close_datetime) - == datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 9, 30, 0, tzinfo=NY_TZ)) ) # fx & metal within market hours assert ( - get_next_market_open("fx", fx_metal_open_weekday_datetime) - == datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("fx", FX_METAL_OPEN_WED_2023_6_21_22) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_open("metal", fx_metal_open_weekday_datetime) - == datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("metal", FX_METAL_OPEN_WED_2023_6_21_22) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 25, 17, 0, 0, tzinfo=NY_TZ)) ) # fx & metal out of market hours assert ( - get_next_market_open("fx", fx_metal_close_weekend_datetime) - == datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_open("metal", fx_metal_close_weekend_datetime) - == datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 18, 17, 0, 0, tzinfo=NY_TZ)) ) # fx & metal holiday assert ( - get_next_market_open("fx", fx_metal_holiday_datetime) - == datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_open("metal", fx_metal_holiday_datetime) - == datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_open("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 2, 17, 0, 0, tzinfo=NY_TZ)) ) # crypto - assert get_next_market_open("crypto", crypto_open_weekday_datetime) == None - assert get_next_market_open("crypto", crypto_open_weekend_datetime) == None + assert get_next_market_open("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == None + assert get_next_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == None def test_get_next_market_close( - equity_open_weekday_datetime, - equity_close_weekday_datetime, - equity_close_weekend_datetime, - equity_holiday_datetime, - equity_early_holiday_open_datetime, - equity_early_holiday_close_datetime, - fx_metal_open_weekday_datetime, - fx_metal_close_weekend_datetime, - fx_metal_holiday_datetime, - crypto_open_weekday_datetime, - crypto_open_weekend_datetime, + EQUITY_OPEN_WED_2023_6_21_12, + EQUITY_CLOSE_WED_2023_6_21_17, + EQUITY_CLOSE_SAT_2023_6_10_17, + EQUITY_HOLIDAY_MON_2023_6_19, + EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, + EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, + FX_METAL_OPEN_WED_2023_6_21_22, + FX_METAL_CLOSE_SUN_2023_6_18_16, + FX_METAL_HOLIDAY_SUN_2023_1_1, + CRYPTO_OPEN_WED_2023_6_21_12, + CRYPTO_OPEN_SUN_2023_6_18_12, ): # equity within market hours assert ( - get_next_market_close("equity", equity_open_weekday_datetime) - == datetime.datetime(2023, 6, 21, 16, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_OPEN_WED_2023_6_21_12) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 21, 16, 0, 0, tzinfo=NY_TZ)) ) # equity out of market hours assert ( - get_next_market_close("equity", equity_close_weekday_datetime) - == datetime.datetime(2023, 6, 22, 16, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_CLOSE_WED_2023_6_21_17) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 22, 16, 0, 0, tzinfo=NY_TZ)) ) # equity weekend assert ( - get_next_market_close("equity", equity_close_weekend_datetime) - == datetime.datetime(2023, 6, 12, 16, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_CLOSE_SAT_2023_6_10_17) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 12, 16, 0, 0, tzinfo=NY_TZ)) ) # equity holiday assert ( - get_next_market_close("equity", equity_holiday_datetime) - == datetime.datetime(2023, 6, 20, 16, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_HOLIDAY_MON_2023_6_19) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 20, 16, 0, 0, tzinfo=NY_TZ)) ) # equity early close holiday assert ( - get_next_market_close("equity", equity_early_holiday_open_datetime) - == datetime.datetime(2023, 11, 24, 13, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 24, 13, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_close("equity", equity_early_holiday_close_datetime) - == datetime.datetime(2023, 11, 27, 16, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("equity", EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 11, 27, 16, 0, 0, tzinfo=NY_TZ)) ) # fx & metal within market hours assert ( - get_next_market_close("fx", fx_metal_open_weekday_datetime) - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("fx", FX_METAL_OPEN_WED_2023_6_21_22) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_close("metal", fx_metal_open_weekday_datetime) - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("metal", FX_METAL_OPEN_WED_2023_6_21_22) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) ) # fx & metal out of market hours assert ( - get_next_market_close("fx", fx_metal_close_weekend_datetime) - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("fx", FX_METAL_CLOSE_SUN_2023_6_18_16) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_close("metal", fx_metal_close_weekend_datetime) - == datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("metal", FX_METAL_CLOSE_SUN_2023_6_18_16) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 6, 23, 17, 0, 0, tzinfo=NY_TZ)) ) # fx & metal holiday assert ( - get_next_market_close("fx", fx_metal_holiday_datetime) - == datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("fx", FX_METAL_HOLIDAY_SUN_2023_1_1) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ)) ) assert ( - get_next_market_close("metal", fx_metal_holiday_datetime) - == datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ) - .astimezone(UTC_TZ) - .strftime("%Y-%m-%dT%H:%M:%S") - + "Z" + get_next_market_close("metal", FX_METAL_HOLIDAY_SUN_2023_1_1) + == format_datetime_to_utc_iso_string(datetime.datetime(2023, 1, 6, 17, 0, 0, tzinfo=NY_TZ)) ) # crypto - assert get_next_market_close("crypto", crypto_open_weekday_datetime) == None - assert get_next_market_close("crypto", crypto_open_weekend_datetime) == None + assert get_next_market_close("crypto", CRYPTO_OPEN_WED_2023_6_21_12) == None + assert get_next_market_close("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == None From fcf3adb961e6fa2e6d1ff25606aae299959fb171 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Mon, 26 Jun 2023 13:57:46 +0800 Subject: [PATCH 2/3] fix pytest failing --- tests/test_calendar.py | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/tests/test_calendar.py b/tests/test_calendar.py index fb4cb92..602c049 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -27,19 +27,7 @@ def format_datetime_to_utc_iso_string(dt: datetime.datetime): return dt.astimezone(UTC_TZ).strftime("%Y-%m-%dT%H:%M:%S") + "Z" -def test_is_market_open( - EQUITY_OPEN_WED_2023_6_21_12, - EQUITY_CLOSE_WED_2023_6_21_17, - EQUITY_CLOSE_SAT_2023_6_10_17, - EQUITY_HOLIDAY_MON_2023_6_19, - EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, - EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, - FX_METAL_OPEN_WED_2023_6_21_22, - FX_METAL_CLOSE_SUN_2023_6_18_16, - FX_METAL_HOLIDAY_SUN_2023_1_1, - CRYPTO_OPEN_WED_2023_6_21_12, - CRYPTO_OPEN_SUN_2023_6_18_12, -): +def test_is_market_open(): # equity # weekday, within equity market hours assert is_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) == True @@ -75,19 +63,7 @@ def test_is_market_open( assert is_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == True -def test_get_next_market_open( - EQUITY_OPEN_WED_2023_6_21_12, - EQUITY_CLOSE_WED_2023_6_21_17, - EQUITY_CLOSE_SAT_2023_6_10_17, - EQUITY_HOLIDAY_MON_2023_6_19, - EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, - EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, - FX_METAL_OPEN_WED_2023_6_21_22, - FX_METAL_CLOSE_SUN_2023_6_18_16, - FX_METAL_HOLIDAY_SUN_2023_1_1, - CRYPTO_OPEN_WED_2023_6_21_12, - CRYPTO_OPEN_SUN_2023_6_18_12, -): +def test_get_next_market_open(): # equity within market hours assert ( get_next_market_open("equity", EQUITY_OPEN_WED_2023_6_21_12) @@ -157,19 +133,7 @@ def test_get_next_market_open( assert get_next_market_open("crypto", CRYPTO_OPEN_SUN_2023_6_18_12) == None -def test_get_next_market_close( - EQUITY_OPEN_WED_2023_6_21_12, - EQUITY_CLOSE_WED_2023_6_21_17, - EQUITY_CLOSE_SAT_2023_6_10_17, - EQUITY_HOLIDAY_MON_2023_6_19, - EQUITY_EARLY_CLOSE_OPEN_FRI_2023_11_24_14, - EQUITY_EARLY_CLOSE_CLOSE_FRI_2023_11_24_14, - FX_METAL_OPEN_WED_2023_6_21_22, - FX_METAL_CLOSE_SUN_2023_6_18_16, - FX_METAL_HOLIDAY_SUN_2023_1_1, - CRYPTO_OPEN_WED_2023_6_21_12, - CRYPTO_OPEN_SUN_2023_6_18_12, -): +def test_get_next_market_close(): # equity within market hours assert ( get_next_market_close("equity", EQUITY_OPEN_WED_2023_6_21_12) From 1ec304fcd435db2669a8447fc7b617dcea400403 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Mon, 26 Jun 2023 14:01:47 +0800 Subject: [PATCH 3/3] bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 79b29c1..73c5d18 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='pythclient', - version='0.1.7', + version='0.1.8', packages=['pythclient'], author='Pyth Developers', author_email='contact@pyth.network',