Skip to content

Commit ccfa42f

Browse files
authored
Remove quote overlay copy from notifications
1 parent 60a8bf8 commit ccfa42f

1 file changed

Lines changed: 38 additions & 64 deletions

File tree

notifications/telegram.py

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,49 @@
1010
localize_notification_text as _base_localize_notification_text,
1111
)
1212

13+
_PRICE_SOURCE_LABELS = {
14+
"longbridge_candlesticks": ("LongBridge 日线K线", "LongBridge daily candlesticks"),
15+
"schwab_daily_history_with_live_quote_overlay": ("Schwab 日线历史", "Schwab daily history"),
16+
"firstrade_ohlc_with_live_quote_overlay": ("Firstrade OHLC", "Firstrade OHLC"),
17+
"market_quote": ("实时行情报价", "market quote"),
18+
"mixed_market_quote_snapshot_close": (
19+
"实时行情报价 + 快照收盘价回补",
20+
"market quote + snapshot close fallback",
21+
),
22+
"mixed_market_quote_historical_close": (
23+
"实时行情报价 + 历史收盘价回补",
24+
"market quote + historical close fallback",
25+
),
26+
"snapshot_close": ("快照收盘价", "snapshot close"),
27+
"historical_close": ("历史收盘价", "historical close"),
28+
"market_data": ("市场数据", "market data"),
29+
}
30+
31+
32+
def _locale_uses_zh(locale: str | None) -> bool:
33+
return str(locale or "").strip().lower().startswith("zh")
34+
35+
1336
try:
1437
from quant_platform_kit.common.notification_localization import (
15-
localize_price_source_label as _localize_price_source_label,
16-
localize_quote_overlay_state as _localize_quote_overlay_state,
38+
localize_price_source_label as _shared_localize_price_source_label,
1739
)
1840
except ImportError: # pragma: no cover - compatibility with older pinned shared wheels
19-
_PRICE_SOURCE_LABELS = {
20-
"longbridge_candlesticks": ("LongBridge 日线K线", "LongBridge daily candlesticks"),
21-
"schwab_daily_history_with_live_quote_overlay": (
22-
"Schwab 日线历史 + 实时报价覆盖",
23-
"Schwab daily history + live quote overlay",
24-
),
25-
"firstrade_ohlc_with_live_quote_overlay": (
26-
"Firstrade OHLC + 实时报价覆盖",
27-
"Firstrade OHLC + live quote overlay",
28-
),
29-
"market_quote": ("实时行情报价", "market quote"),
30-
"mixed_market_quote_snapshot_close": (
31-
"实时行情报价 + 快照收盘价回补",
32-
"market quote + snapshot close fallback",
33-
),
34-
"mixed_market_quote_historical_close": (
35-
"实时行情报价 + 历史收盘价回补",
36-
"market quote + historical close fallback",
37-
),
38-
"snapshot_close": ("快照收盘价", "snapshot close"),
39-
"historical_close": ("历史收盘价", "historical close"),
40-
"market_data": ("市场数据", "market data"),
41-
}
41+
_shared_localize_price_source_label = None
4242

43-
def _locale_uses_zh(locale: str | None) -> bool:
44-
return str(locale or "").strip().lower().startswith("zh")
45-
46-
def _localize_price_source_label(value, *, translator=None, locale=None):
47-
source = str(value or "").strip()
48-
use_zh = _locale_uses_zh(locale)
49-
if not source:
50-
return "未知" if use_zh else "unknown"
51-
label = _PRICE_SOURCE_LABELS.get(source)
52-
if label is not None:
53-
return label[0] if use_zh else label[1]
54-
return source.replace("_", " ")
55-
56-
def _localize_quote_overlay_state(value, *, translator=None, locale=None):
57-
use_zh = _locale_uses_zh(locale)
58-
if value is True:
59-
return "是" if use_zh else "yes"
60-
if value is False:
61-
return "否" if use_zh else "no"
43+
44+
def _localize_price_source_label(value, *, translator=None, locale=None):
45+
source = str(value or "").strip()
46+
use_zh = _locale_uses_zh(locale)
47+
if not source:
6248
return "未知" if use_zh else "unknown"
49+
label = _PRICE_SOURCE_LABELS.get(source)
50+
if label is not None:
51+
return label[0] if use_zh else label[1]
52+
if _shared_localize_price_source_label is not None:
53+
return _shared_localize_price_source_label(source, translator=translator, locale=locale)
54+
return source.replace("_", " ")
55+
6356
try:
6457
from quant_platform_kit.common.small_account_compatibility import (
6558
format_small_account_cash_substitution_notes,
@@ -553,22 +546,6 @@ def _localize_timing_contract(contract: Any, *, translator: Callable[..., str])
553546
return value
554547

555548

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-
572549
def _format_timing_lines(execution: Mapping[str, Any], *, translator: Callable[..., str]) -> list[str]:
573550
signal_date = str(execution.get("signal_date") or "").strip()
574551
effective_date = str(execution.get("effective_date") or "").strip()
@@ -589,24 +566,21 @@ def _format_signal_snapshot_line(snapshot: Any, *, lang: str) -> str:
589566
return ""
590567
market_date = str(snapshot.get("market_date") or snapshot.get("signal_as_of") or "").strip()
591568
source = str(snapshot.get("latest_price_source") or "").strip()
592-
overlay = _infer_quote_overlay_used(source, snapshot.get("quote_overlay_used"))
593569
warning = snapshot.get("data_freshness_warning")
594-
if not market_date and not source and overlay is None and warning in (None, "", False):
570+
if not market_date and not source and warning in (None, "", False):
595571
return ""
596572
use_zh = str(lang or "").lower().startswith("zh")
597573
if use_zh:
598574
parts = [
599575
f"日期 {market_date or '未知'}",
600576
f"数据源 {_localize_price_source_label(source, locale=lang)}",
601-
f"报价覆盖 {_localize_quote_overlay_state(overlay, locale=lang)}",
602577
]
603578
if warning not in (None, "", False):
604579
parts.append(f"提示 {_base_localize_notification_text(warning, translator=build_translator(lang))}")
605580
return "🧾 信号快照: " + " | ".join(parts)
606581
parts = [
607582
f"date {market_date or 'unknown'}",
608583
f"source {_localize_price_source_label(source, locale=lang)}",
609-
f"quote overlay {_localize_quote_overlay_state(overlay, locale=lang)}",
610584
]
611585
if warning not in (None, "", False):
612586
parts.append(f"warning {warning}")

0 commit comments

Comments
 (0)