Suppress stale market closed warnings

This commit is contained in:
Thigazhezhilan J 2026-04-01 21:07:40 +05:30
parent 1660b13778
commit 302edc5b79

View File

@ -915,15 +915,24 @@ def _issue_is_stale_for_current_state(
data: dict | None,
meta: dict | None,
):
status_key = (status.get("status") or "IDLE").upper()
cfg = status.get("config") if isinstance(status.get("config"), dict) else {}
mode = str(cfg.get("mode") or "").strip().upper()
if mode != "LIVE":
return False
payload = data if isinstance(data, dict) else {}
extra = meta if isinstance(meta, dict) else {}
reason = payload.get("reason") or extra.get("reason")
reason_key = str(reason or "").strip().lower()
if status_key == "STOPPED" and event in {"BROKER_AUTH_EXPIRED", "EXECUTION_BLOCKED", "SIP_NO_FILL"}:
return True
if event == "EXECUTION_BLOCKED" and reason_key == "market_closed":
return is_market_open(datetime.now())
if mode != "LIVE":
return False
auth_related_issue = event == "BROKER_AUTH_EXPIRED" or (
event == "SIP_NO_FILL" and reason_key == "broker_auth_expired"
) or (event == "EXECUTION_BLOCKED" and reason_key in {"broker_auth_expired", "auth_expired"})