Refine market alert wording and focus digest scheduling
This commit is contained in:
@@ -808,7 +808,7 @@ def _build_advice_cn(
|
||||
parts.append("实测已击穿主流模型上沿")
|
||||
|
||||
if not parts:
|
||||
return "当前未触发高优先级天气异动,继续观察实测与模型联动。"
|
||||
return "当前未触发高优先级关键信号,继续观察实测与模型联动。"
|
||||
return ",".join(parts) + "。"
|
||||
|
||||
|
||||
@@ -934,8 +934,8 @@ def _build_telegram_messages(
|
||||
|
||||
advice = _build_advice_cn(rules, temp_symbol, suppression=suppression)
|
||||
final_map = map_url or "https://polyweather-pro.vercel.app/"
|
||||
title_zh = "🚨 PolyWeather 异动预警" if has_active_trigger else "📍 PolyWeather 状态快照"
|
||||
title_en = "🚨 PolyWeather Alert" if has_active_trigger else "📍 PolyWeather Status"
|
||||
title_zh = "🚨 PolyWeather 市场提醒" if has_active_trigger else "📍 PolyWeather 状态快照"
|
||||
title_en = "🚨 PolyWeather Market Alert" if has_active_trigger else "📍 PolyWeather Status"
|
||||
|
||||
lines_zh = [
|
||||
f"{title_zh} [{city_name}]",
|
||||
@@ -1139,7 +1139,7 @@ def _build_telegram_messages_mispricing(
|
||||
elif snapshot.get("available"):
|
||||
title_zh = "📍 PolyWeather 市场观察"
|
||||
else:
|
||||
title_zh = "🚨 PolyWeather 异动预警" if (has_active_trigger or suppressed) else "📍 PolyWeather 状态快照"
|
||||
title_zh = "🚨 PolyWeather 市场提醒" if (has_active_trigger or suppressed) else "📍 PolyWeather 状态快照"
|
||||
|
||||
lines_zh = [f"{title_zh} [{city_name}]"]
|
||||
lines_zh.append("")
|
||||
|
||||
@@ -153,15 +153,10 @@ class StartupCoordinator:
|
||||
def _start_trade_alert_loop(self) -> LoopStatus:
|
||||
enabled = _env_bool("TELEGRAM_ALERT_PUSH_ENABLED", True)
|
||||
chat_ids = get_telegram_chat_ids_from_env()
|
||||
mispricing_only = _env_bool("TELEGRAM_ALERT_MISPRICING_ONLY", True)
|
||||
interval = (
|
||||
max(300, _env_int("TELEGRAM_ALERT_MISPRICING_INTERVAL_SEC", 7200))
|
||||
if mispricing_only
|
||||
else max(60, _env_int("TELEGRAM_ALERT_PUSH_INTERVAL_SEC", 300))
|
||||
)
|
||||
interval = max(60, _env_int("TELEGRAM_ALERT_PUSH_INTERVAL_SEC", 300))
|
||||
cities_count = _parse_csv_count(os.getenv("TELEGRAM_ALERT_CITIES"))
|
||||
details = {
|
||||
"mode": "mispricing-only" if mispricing_only else "full",
|
||||
"mode": "focus-digest-only",
|
||||
"interval_sec": interval,
|
||||
"cities_count": cities_count,
|
||||
"chat_targets": len(chat_ids),
|
||||
|
||||
@@ -961,16 +961,7 @@ def start_trade_alert_push_loop(bot: Any, config: Dict[str, Any]) -> Optional[th
|
||||
logger.warning("telegram market monitor loop skipped: TELEGRAM_CHAT_IDS is not set")
|
||||
return None
|
||||
|
||||
mispricing_only = _env_bool("TELEGRAM_ALERT_MISPRICING_ONLY", True)
|
||||
if mispricing_only:
|
||||
interval_sec = max(
|
||||
300, _env_int("TELEGRAM_ALERT_MISPRICING_INTERVAL_SEC", 7200)
|
||||
)
|
||||
else:
|
||||
interval_sec = max(60, _env_int("TELEGRAM_ALERT_PUSH_INTERVAL_SEC", 300))
|
||||
cooldown_sec = max(interval_sec, _env_int("TELEGRAM_ALERT_PUSH_COOLDOWN_SEC", 1800))
|
||||
min_trigger_count = max(1, _env_int("TELEGRAM_ALERT_MIN_TRIGGER_COUNT", 2))
|
||||
min_severity = os.getenv("TELEGRAM_ALERT_MIN_SEVERITY", "medium").strip().lower()
|
||||
interval_sec = max(60, _env_int("TELEGRAM_ALERT_PUSH_INTERVAL_SEC", 300))
|
||||
cities = _parse_city_list(os.getenv("TELEGRAM_ALERT_CITIES"))
|
||||
state_path = _state_file()
|
||||
focus_digest_enabled = _env_bool("TELEGRAM_MARKET_FOCUS_DIGEST_ENABLED", True)
|
||||
@@ -989,9 +980,8 @@ def start_trade_alert_push_loop(bot: Any, config: Dict[str, Any]) -> Optional[th
|
||||
except Exception:
|
||||
logger.exception(f"failed to initialize market monitor state path={state_path}")
|
||||
logger.info(
|
||||
f"telegram market monitor loop started mode={'mispricing-only' if mispricing_only else 'full'} "
|
||||
f"telegram market monitor loop started mode=focus-digest-only "
|
||||
f"cities={len(cities)} interval={interval_sec}s chat_targets={len(chat_ids)} "
|
||||
f"cooldown={cooldown_sec}s min_triggers={min_trigger_count} min_severity={min_severity} "
|
||||
f"focus_digest_enabled={focus_digest_enabled} focus_hours={focus_digest_hours} "
|
||||
f"state_path={state_path}"
|
||||
)
|
||||
@@ -1005,21 +995,6 @@ def start_trade_alert_push_loop(bot: Any, config: Dict[str, Any]) -> Optional[th
|
||||
try:
|
||||
alert_payload = build_trade_alert_for_city(city, config)
|
||||
cycle_payloads.append(alert_payload)
|
||||
if _maybe_send_alert(
|
||||
bot=bot,
|
||||
chat_ids=chat_ids,
|
||||
city=city,
|
||||
alert_payload=alert_payload,
|
||||
state=state,
|
||||
cooldown_sec=cooldown_sec,
|
||||
min_severity=min_severity,
|
||||
min_trigger_count=min_trigger_count,
|
||||
mispricing_only=mispricing_only,
|
||||
):
|
||||
try:
|
||||
_save_state(state_path, state)
|
||||
except Exception:
|
||||
logger.exception(f"failed to save market monitor state city={city}")
|
||||
except Exception:
|
||||
logger.exception(f"telegram market monitor loop failed for city={city}")
|
||||
time.sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user