Skip to content

Commit

Permalink
Fix fx/metal calendar open time (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati authored Jan 10, 2023
1 parent 6fa6d3e commit 12783dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions pyth_observer/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 12783dc

Please sign in to comment.