diff --git a/notifications/telegram.py b/notifications/telegram.py index a3b96ce..a2b5e0d 100644 --- a/notifications/telegram.py +++ b/notifications/telegram.py @@ -103,21 +103,39 @@ "strategy_plugin_alert_scope_note": "执行范围:{scope_note}", "strategy_plugin_alert_scope": "仅作人工复核提醒;插件不会自动下单或改仓位", "strategy_plugin_name_crisis_response_shadow": "危机观察通知", + "strategy_plugin_name_macro_risk_governor": "宏观风险控制通知", + "strategy_plugin_name_market_regime_control": "市场状态控制通知", + "strategy_plugin_name_panic_reversal_shadow": "恐慌反转观察通知", "strategy_plugin_name_taco_rebound_shadow": "TACO 抄底观察通知", "strategy_plugin_mode_shadow": "影子观察", + "strategy_plugin_route_blocked": "已阻断", + "strategy_plugin_route_crisis": "危机", + "strategy_plugin_route_delever": "降杠杆", "strategy_plugin_route_no_action": "未触发", + "strategy_plugin_route_opportunity_watch": "机会观察", + "strategy_plugin_route_panic_reversal": "恐慌反转", + "strategy_plugin_route_risk_off": "风险关闭", + "strategy_plugin_route_risk_reduced": "风险降低", "strategy_plugin_route_true_crisis": "真危机", "strategy_plugin_route_taco_rebound": "TACO 反弹确认", "strategy_plugin_route_unknown_route": "未知状态", + "strategy_plugin_route_watch": "观察", "strategy_plugin_action_no_action": "不操作", "strategy_plugin_action_watch_only": "仅通知", "strategy_plugin_action_notify_manual_review": "通知人工复核", "strategy_plugin_action_defend": "防守", + "strategy_plugin_action_delever": "降杠杆", "strategy_plugin_action_blocked": "已阻断", "strategy_plugin_action_monitor": "持续观察", "strategy_plugin_action_unknown_action": "未知提醒", "strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend": "优先考虑降低杠杆或清理杠杆仓位,暂停加仓;如需保留风险敞口,先降到可承受的小仓位。", "strategy_plugin_guidance_crisis_response_shadow_no_action_blocked": "危机路线被风控阻断;先核对数据新鲜度和外部情境,不建议仅凭此条加仓。", + "strategy_plugin_guidance_macro_risk_governor_delever_delever": "宏观风险控制建议降低杠杆敞口;是否执行由策略侧可回测规则和仓位适配器决定。", + "strategy_plugin_guidance_macro_risk_governor_crisis_defend": "宏观危机信号建议风险仓位转向防守或现金类资产,直到压力缓和。", + "strategy_plugin_guidance_market_regime_control_risk_off_defend": "市场状态控制进入风险关闭;机会类信号先不执行,风险仓位应保持防守。", + "strategy_plugin_guidance_market_regime_control_risk_reduced_delever": "市场状态控制建议降杠杆;自动仓位调整只按策略侧已批准的可回测规则执行。", + "strategy_plugin_guidance_market_regime_control_opportunity_watch_notify_manual_review": "仅作人工复核:市场状态允许有限机会观察,但插件本身不会下单或直接改仓位。", + "strategy_plugin_guidance_market_regime_control_blocked_blocked": "市场状态控制被数据质量或新鲜度保护阻断;先核对数据源和产物,再决定是否人工处理。", "strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO 仅提示可能的反弹窗口;可考虑小仓位、分批、预设止损/失效条件的人工博弈,不建议一次性满仓。", "no_trades": "✅ 无需调仓", "emergency": "🛡️ 金丝雀应急: {n_bad}/4 坏, 全部转入 {safe}", @@ -253,21 +271,39 @@ "strategy_plugin_alert_scope_note": "Execution scope: {scope_note}", "strategy_plugin_alert_scope": "Manual review notice only; the plugin does not place orders or change allocations", "strategy_plugin_name_crisis_response_shadow": "Crisis Watch Notice", + "strategy_plugin_name_macro_risk_governor": "Macro Risk Governor Notice", + "strategy_plugin_name_market_regime_control": "Market Regime Control Notice", + "strategy_plugin_name_panic_reversal_shadow": "Panic Reversal Watch Notice", "strategy_plugin_name_taco_rebound_shadow": "TACO Rebound Watch Notice", "strategy_plugin_mode_shadow": "shadow", + "strategy_plugin_route_blocked": "blocked", + "strategy_plugin_route_crisis": "crisis", + "strategy_plugin_route_delever": "de-lever", "strategy_plugin_route_no_action": "no alert", + "strategy_plugin_route_opportunity_watch": "opportunity watch", + "strategy_plugin_route_panic_reversal": "panic reversal", + "strategy_plugin_route_risk_off": "risk off", + "strategy_plugin_route_risk_reduced": "risk reduced", "strategy_plugin_route_true_crisis": "true crisis", "strategy_plugin_route_taco_rebound": "TACO rebound confirmed", "strategy_plugin_route_unknown_route": "unknown status", + "strategy_plugin_route_watch": "watch", "strategy_plugin_action_no_action": "no action", "strategy_plugin_action_watch_only": "notify only", "strategy_plugin_action_notify_manual_review": "notify manual review", "strategy_plugin_action_defend": "defend", + "strategy_plugin_action_delever": "de-lever", "strategy_plugin_action_blocked": "blocked", "strategy_plugin_action_monitor": "watch", "strategy_plugin_action_unknown_action": "unknown notice", "strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend": "Consider reducing or clearing leveraged exposure, then pause new risk additions; if keeping exposure, resize it to a small amount you can tolerate.", "strategy_plugin_guidance_crisis_response_shadow_no_action_blocked": "A guard blocked the crisis route; verify data freshness and external context before acting on this alert.", + "strategy_plugin_guidance_macro_risk_governor_delever_delever": "The macro risk governor suggests reducing leveraged exposure; execution is controlled by strategy-side backtestable rules and position adapters.", + "strategy_plugin_guidance_macro_risk_governor_crisis_defend": "The macro crisis signal suggests moving the risk sleeve toward defensive or cash-like exposure until stress de-escalates.", + "strategy_plugin_guidance_market_regime_control_risk_off_defend": "Market regime control is risk-off; opportunity signals should stay blocked and risk exposure should remain defensive.", + "strategy_plugin_guidance_market_regime_control_risk_reduced_delever": "Market regime control suggests de-levering; automatic position changes only follow strategy-side approved, backtestable rules.", + "strategy_plugin_guidance_market_regime_control_opportunity_watch_notify_manual_review": "Manual review only: the market regime allows bounded opportunity watch, but the plugin does not place orders or directly change allocations.", + "strategy_plugin_guidance_market_regime_control_blocked_blocked": "Market regime control was blocked by data-quality or freshness guards; verify source data and artifacts before manual action.", "strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO only flags a possible rebound window; consider a small staged manual probe with a predefined invalidation level instead of full-size exposure.", "no_trades": "✅ No rebalance needed", "emergency": "🛡️ Canary Emergency: {n_bad}/4 bad, rotating to {safe}", diff --git a/tests/test_notifications.py b/tests/test_notifications.py index 2c24355..7a67d63 100644 --- a/tests/test_notifications.py +++ b/tests/test_notifications.py @@ -135,9 +135,20 @@ def test_build_translator_supports_chinese(): ) == "🧩 插件:TACO 抄底观察通知 | 状态:TACO 反弹确认 | 提醒:通知人工复核" ) + assert ( + translate( + "strategy_plugin_line", + plugin=translate("strategy_plugin_name_market_regime_control"), + mode=translate("strategy_plugin_mode_shadow"), + route=translate("strategy_plugin_route_risk_reduced"), + action=translate("strategy_plugin_action_delever"), + ) + == "🧩 插件:市场状态控制通知 | 状态:风险降低 | 提醒:降杠杆" + ) assert translate("strategy_plugin_alert_guidance", guidance="小仓位博弈") == "处置建议:小仓位博弈" assert translate("strategy_plugin_alert_scope_note", scope_note="不会自动下单") == "执行范围:不会自动下单" assert "降低杠杆" in translate("strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend") + assert "策略侧已批准" in translate("strategy_plugin_guidance_market_regime_control_risk_reduced_delever") assert "小仓位" in translate("strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review") assert translate("account_ids_detail", account_ids="U1234567") == "🆔 账户: U1234567" assert (