From 12783dc984f2cad9a42a28e78395d7a8eca62430 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Tue, 10 Jan 2023 13:50:07 +0100 Subject: [PATCH] Fix fx/metal calendar open time (#49) --- pyproject.toml | 2 +- pyth_observer/calendar.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d7e7d17..9cc29fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ignore_missing_imports = true [tool.poetry] name = "pyth-observer" -version = "0.1.3" +version = "0.1.4" description = "Alerts and stuff" authors = [] readme = "README.md" diff --git a/pyth_observer/calendar.py b/pyth_observer/calendar.py index 071bf24..7f0d8be 100644 --- a/pyth_observer/calendar.py +++ b/pyth_observer/calendar.py @@ -28,6 +28,9 @@ datetime.datetime(2023, 11, 24, tzinfo=TZ).date(), ] +FX_METAL_CLOSE_TIME = datetime.time(17, 0, 0, tzinfo=TZ) +FX_METAL_OPEN_TIME = datetime.time(12, 0, 0, tzinfo=TZ) + class HolidayCalendar: def is_market_open(self, asset_type: str, dt: datetime.datetime): @@ -48,16 +51,15 @@ def is_market_open(self, asset_type: str, dt: datetime.datetime): if asset_type in ["FX", "Metal"]: # The market for FX and Metal is closed from Friday 5pm to Sunday 5pm - close_or_open_time = datetime.time(17, 0, 0, tzinfo=TZ) # Friday the market is close after 5pm - if day == 4 and time > close_or_open_time: + if day == 4 and time > FX_METAL_CLOSE_TIME: return False # Saturday the market is closed all the time if day == 5: return False # Sunday the market is closed before 5pm - if day == 6 and time < close_or_open_time: + if day == 6 and time < FX_METAL_OPEN_TIME: return False return True