diff --git a/pyproject.toml b/pyproject.toml index c6ca31e..d7e7d17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ignore_missing_imports = true [tool.poetry] name = "pyth-observer" -version = "0.1.2" +version = "0.1.3" description = "Alerts and stuff" authors = [] readme = "README.md" diff --git a/pyth_observer/calendar.py b/pyth_observer/calendar.py index 6ca1265..071bf24 100644 --- a/pyth_observer/calendar.py +++ b/pyth_observer/calendar.py @@ -30,10 +30,10 @@ class HolidayCalendar: - def is_market_open(self, asset_type, dt): - # equity market + def is_market_open(self, asset_type: str, dt: datetime.datetime): + day, date, time = dt.weekday(), dt.date(), dt.time() + if asset_type == "Equity": - day, date, time = dt.weekday(), dt.date(), dt.time() if date in EQUITY_HOLIDAYS or date in EQUITY_EARLY_HOLIDAYS: if ( date in EQUITY_EARLY_HOLIDAYS @@ -45,5 +45,22 @@ def is_market_open(self, asset_type, dt): if day < 5 and time >= EQUITY_OPEN and time <= EQUITY_CLOSE: return True return False - # all other markets (crypto, fx, metal) + + 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: + 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: + return False + + return True + + # all other markets (crypto) return True diff --git a/pyth_observer/check/publisher.py b/pyth_observer/check/publisher.py index aa28f36..fc15e0c 100644 --- a/pyth_observer/check/publisher.py +++ b/pyth_observer/check/publisher.py @@ -213,8 +213,8 @@ def error_message(self) -> str: {self.__state.publisher_name} price is too far from aggregate price. Symbol: {self.__state.symbol} - Publisher price: {self.__state.price} - Aggregate price: {self.__state.price_aggregate} + Publisher price: {self.__state.price} ± {self.__state.confidence_interval} + Aggregate price: {self.__state.price_aggregate} ± {self.__state.confidence_interval_aggregate} Deviation: {deviation}% """ ).strip()