From 43f9d8b6012ec52841c9489afce3150791bd7aa1 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Fri, 29 May 2026 11:37:06 +0800 Subject: [PATCH] Infer quote overlay state in notifications --- notifications/renderers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/notifications/renderers.py b/notifications/renderers.py index bd5bda6..2ddb868 100644 --- a/notifications/renderers.py +++ b/notifications/renderers.py @@ -105,6 +105,22 @@ def _localize_notification_text(text: str, *, translator) -> str: ) +def _infer_quote_overlay_used(source: str, overlay): + if overlay is not None: + return overlay + normalized_source = str(source or "").strip().lower() + if "with_live_quote_overlay" in normalized_source: + return True + if normalized_source in { + "longbridge_candlesticks", + "historical_close", + "snapshot_close", + "market_quote", + }: + return False + return None + + def _localize_timing_contract(contract: str, *, translator) -> str: value = str(contract or "").strip() if not value: @@ -353,7 +369,7 @@ def _format_signal_snapshot_line(snapshot, *, translator) -> str: return "" market_date = str(snapshot.get("market_date") or snapshot.get("signal_as_of") or "").strip() source = str(snapshot.get("latest_price_source") or "").strip() - overlay = snapshot.get("quote_overlay_used") + overlay = _infer_quote_overlay_used(source, snapshot.get("quote_overlay_used")) warning = snapshot.get("data_freshness_warning") if not market_date and not source and overlay is None and warning in (None, "", False): return ""