Skip to content

Commit 6fa6d3e

Browse files
authored
Improvements_again (#47)
* Add fx/metal close hours * Add confidence interval info on pub price check * Bump version to 0.1.3 * refactor
1 parent 4aa010c commit 6fa6d3e

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore_missing_imports = true
44

55
[tool.poetry]
66
name = "pyth-observer"
7-
version = "0.1.2"
7+
version = "0.1.3"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

pyth_observer/calendar.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131

3232
class HolidayCalendar:
33-
def is_market_open(self, asset_type, dt):
34-
# equity market
33+
def is_market_open(self, asset_type: str, dt: datetime.datetime):
34+
day, date, time = dt.weekday(), dt.date(), dt.time()
35+
3536
if asset_type == "Equity":
36-
day, date, time = dt.weekday(), dt.date(), dt.time()
3737
if date in EQUITY_HOLIDAYS or date in EQUITY_EARLY_HOLIDAYS:
3838
if (
3939
date in EQUITY_EARLY_HOLIDAYS
@@ -45,5 +45,22 @@ def is_market_open(self, asset_type, dt):
4545
if day < 5 and time >= EQUITY_OPEN and time <= EQUITY_CLOSE:
4646
return True
4747
return False
48-
# all other markets (crypto, fx, metal)
48+
49+
if asset_type in ["FX", "Metal"]:
50+
# The market for FX and Metal is closed from Friday 5pm to Sunday 5pm
51+
close_or_open_time = datetime.time(17, 0, 0, tzinfo=TZ)
52+
53+
# Friday the market is close after 5pm
54+
if day == 4 and time > close_or_open_time:
55+
return False
56+
# Saturday the market is closed all the time
57+
if day == 5:
58+
return False
59+
# Sunday the market is closed before 5pm
60+
if day == 6 and time < close_or_open_time:
61+
return False
62+
63+
return True
64+
65+
# all other markets (crypto)
4966
return True

pyth_observer/check/publisher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ def error_message(self) -> str:
213213
{self.__state.publisher_name} price is too far from aggregate price.
214214
215215
Symbol: {self.__state.symbol}
216-
Publisher price: {self.__state.price}
217-
Aggregate price: {self.__state.price_aggregate}
216+
Publisher price: {self.__state.price} ± {self.__state.confidence_interval}
217+
Aggregate price: {self.__state.price_aggregate} ± {self.__state.confidence_interval_aggregate}
218218
Deviation: {deviation}%
219219
"""
220220
).strip()

0 commit comments

Comments
 (0)