Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions notifications/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,37 @@ def format_small_account_cash_substitution_notes(
"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": "恐慌反转观察通知",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add guidance for panic reversal alerts

This commit localizes the panic_reversal_shadow plugin name/route but adds no strategy_plugin_guidance_panic_reversal_shadow_* key in either locale. When that newly localized plugin produces a panic-reversal alert, the alert body still has no matching localized guidance entry, so Chinese plugin-bot messages can continue falling back to the default/English guidance instead of the intended Chinese instruction; add the guidance key for the emitted route/action pair.

Useful? React with 👍 / 👎.

"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_guidance_crisis_response_shadow_true_crisis_defend": "优先考虑降低杠杆或清理杠杆仓位,暂停加仓;如需保留风险敞口,先降到可承受的小仓位。",
"strategy_plugin_guidance_crisis_response_shadow_no_action_blocked": "危机路线被风控阻断;先核对数据新鲜度和外部情境,不建议仅凭此条加仓。",
"strategy_plugin_guidance_macro_risk_governor_delever_delever": "宏观风险控制建议降低杠杆敞口;是否执行由策略侧可回测规则和仓位适配器决定。",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the risk_reduced route in macro guidance key

When macro_risk_governor emits the route already used by the execution metadata (dual_drive_macro_risk_governor_route is risk_reduced in the existing signal/decision tests) with action delever, the guidance lookup follows the adjacent strategy_plugin_guidance_{plugin}_{route}_{action} pattern. This new _delever_delever key will not match that alert, so zh plugin-bot messages still miss the localized guidance and fall back to the default/English text; add or rename it to strategy_plugin_guidance_macro_risk_governor_risk_reduced_delever.

Useful? React with 👍 / 👎.

"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 仅提示可能的反弹窗口;可考虑小仓位、分批、预设止损/失效条件的人工博弈,不建议一次性满仓。",
"strategy_plugin_action_monitor": "持续观察",
"strategy_plugin_action_unknown_action": "未知提醒",
Expand Down Expand Up @@ -268,19 +286,37 @@ def format_small_account_cash_substitution_notes(
"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_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.",
"strategy_plugin_action_monitor": "watch",
"strategy_plugin_action_unknown_action": "unknown notice",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_rebalance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,19 @@ def test_notification_i18n_keys_are_aligned():
)
== "SOXX 10 日年化波动率 61.0% 高于实际阈值 60.0%(动态 p95,252日窗口,范围 50.0%-75.0%,样本 252),SOXL 转向 SOXX"
)
assert (
zh(
"strategy_plugin_line",
plugin=zh("strategy_plugin_name_market_regime_control"),
mode=zh("strategy_plugin_mode_shadow"),
route=zh("strategy_plugin_route_risk_reduced"),
action=zh("strategy_plugin_action_delever"),
)
== "🧩 插件:市场状态控制通知 | 状态:风险降低 | 提醒:降杠杆"
)
assert "策略侧已批准" in zh("strategy_plugin_guidance_market_regime_control_risk_reduced_delever")
en = build_translator("en")
assert en("strategy_plugin_name_market_regime_control") == "Market Regime Control Notice"
assert (
en(
"blend_gate_reason_volatility_delever_dynamic",
Expand Down