Skip to content

Commit 12783dc

Browse files
authored
Fix fx/metal calendar open time (#49)
1 parent 6fa6d3e commit 12783dc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
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.3"
7+
version = "0.1.4"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

pyth_observer/calendar.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
datetime.datetime(2023, 11, 24, tzinfo=TZ).date(),
2929
]
3030

31+
FX_METAL_CLOSE_TIME = datetime.time(17, 0, 0, tzinfo=TZ)
32+
FX_METAL_OPEN_TIME = datetime.time(12, 0, 0, tzinfo=TZ)
33+
3134

3235
class HolidayCalendar:
3336
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):
4851

4952
if asset_type in ["FX", "Metal"]:
5053
# 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)
5254

5355
# Friday the market is close after 5pm
54-
if day == 4 and time > close_or_open_time:
56+
if day == 4 and time > FX_METAL_CLOSE_TIME:
5557
return False
5658
# Saturday the market is closed all the time
5759
if day == 5:
5860
return False
5961
# Sunday the market is closed before 5pm
60-
if day == 6 and time < close_or_open_time:
62+
if day == 6 and time < FX_METAL_OPEN_TIME:
6163
return False
6264

6365
return True

0 commit comments

Comments
 (0)