Fix weekend filter: use precise forex market hours (Fri 22:00–Sun 22:00 UTC)
The old `weekday() >= 5` check blocked all of Sunday, but the forex market reopens Sunday 22:00 UTC (Sydney open). Now uses proper time-based check so the bot fetches data and generates signals on Sunday evening. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-2
@@ -21,6 +21,19 @@ from news_engine import NewsEngine, FundamentalContext
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _is_forex_weekend(now_utc: datetime) -> bool:
|
||||
"""Forex market closed: Friday 22:00 UTC → Sunday 22:00 UTC (Sydney open)."""
|
||||
wd = now_utc.weekday()
|
||||
hour = now_utc.hour
|
||||
if wd == 4 and hour >= 22: # Friday after 22:00
|
||||
return True
|
||||
if wd == 5: # All Saturday
|
||||
return True
|
||||
if wd == 6 and hour < 22: # Sunday before 22:00
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@dataclass
|
||||
class TradeSetup:
|
||||
pair: str
|
||||
@@ -108,7 +121,7 @@ class SignalAggregator:
|
||||
if pair_info["display"] == "XAU/USD" and self.config.xau_strategy.enabled:
|
||||
xau_cfg = self.config.xau_strategy
|
||||
|
||||
if xau_cfg.weekend_filter and now_utc.weekday() >= 5:
|
||||
if xau_cfg.weekend_filter and _is_forex_weekend(now_utc):
|
||||
report = SignalReport(
|
||||
symbol=symbol,
|
||||
display_name=pair_info["display"],
|
||||
@@ -122,7 +135,7 @@ class SignalAggregator:
|
||||
return report
|
||||
|
||||
if xau_cfg.allowed_weekdays and now_utc.weekday() not in xau_cfg.allowed_weekdays:
|
||||
day_names = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri"}
|
||||
day_names = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"}
|
||||
allowed = "/".join(day_names.get(d, str(d)) for d in xau_cfg.allowed_weekdays)
|
||||
report = SignalReport(
|
||||
symbol=symbol,
|
||||
|
||||
Reference in New Issue
Block a user