Skip to content

Commit 60a8bf8

Browse files
authored
Infer quote overlay state in notifications (#52)
1 parent 2764bf2 commit 60a8bf8

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

notifications/telegram.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,22 @@ def _localize_timing_contract(contract: Any, *, translator: Callable[..., str])
553553
return value
554554

555555

556+
def _infer_quote_overlay_used(source: str, overlay):
557+
if overlay is not None:
558+
return overlay
559+
normalized_source = str(source or "").strip().lower()
560+
if "with_live_quote_overlay" in normalized_source:
561+
return True
562+
if normalized_source in {
563+
"longbridge_candlesticks",
564+
"historical_close",
565+
"snapshot_close",
566+
"market_quote",
567+
}:
568+
return False
569+
return None
570+
571+
556572
def _format_timing_lines(execution: Mapping[str, Any], *, translator: Callable[..., str]) -> list[str]:
557573
signal_date = str(execution.get("signal_date") or "").strip()
558574
effective_date = str(execution.get("effective_date") or "").strip()
@@ -573,7 +589,7 @@ def _format_signal_snapshot_line(snapshot: Any, *, lang: str) -> str:
573589
return ""
574590
market_date = str(snapshot.get("market_date") or snapshot.get("signal_as_of") or "").strip()
575591
source = str(snapshot.get("latest_price_source") or "").strip()
576-
overlay = snapshot.get("quote_overlay_used")
592+
overlay = _infer_quote_overlay_used(source, snapshot.get("quote_overlay_used"))
577593
warning = snapshot.get("data_freshness_warning")
578594
if not market_date and not source and overlay is None and warning in (None, "", False):
579595
return ""

0 commit comments

Comments
 (0)