Skip to content

Commit 9dce67f

Browse files
authored
Localize strategy plugin notice labels (#159)
1 parent fb7847f commit 9dce67f

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

notifications/telegram.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,39 @@
103103
"strategy_plugin_alert_scope_note": "执行范围:{scope_note}",
104104
"strategy_plugin_alert_scope": "仅作人工复核提醒;插件不会自动下单或改仓位",
105105
"strategy_plugin_name_crisis_response_shadow": "危机观察通知",
106+
"strategy_plugin_name_macro_risk_governor": "宏观风险控制通知",
107+
"strategy_plugin_name_market_regime_control": "市场状态控制通知",
108+
"strategy_plugin_name_panic_reversal_shadow": "恐慌反转观察通知",
106109
"strategy_plugin_name_taco_rebound_shadow": "TACO 抄底观察通知",
107110
"strategy_plugin_mode_shadow": "影子观察",
111+
"strategy_plugin_route_blocked": "已阻断",
112+
"strategy_plugin_route_crisis": "危机",
113+
"strategy_plugin_route_delever": "降杠杆",
108114
"strategy_plugin_route_no_action": "未触发",
115+
"strategy_plugin_route_opportunity_watch": "机会观察",
116+
"strategy_plugin_route_panic_reversal": "恐慌反转",
117+
"strategy_plugin_route_risk_off": "风险关闭",
118+
"strategy_plugin_route_risk_reduced": "风险降低",
109119
"strategy_plugin_route_true_crisis": "真危机",
110120
"strategy_plugin_route_taco_rebound": "TACO 反弹确认",
111121
"strategy_plugin_route_unknown_route": "未知状态",
122+
"strategy_plugin_route_watch": "观察",
112123
"strategy_plugin_action_no_action": "不操作",
113124
"strategy_plugin_action_watch_only": "仅通知",
114125
"strategy_plugin_action_notify_manual_review": "通知人工复核",
115126
"strategy_plugin_action_defend": "防守",
127+
"strategy_plugin_action_delever": "降杠杆",
116128
"strategy_plugin_action_blocked": "已阻断",
117129
"strategy_plugin_action_monitor": "持续观察",
118130
"strategy_plugin_action_unknown_action": "未知提醒",
119131
"strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend": "优先考虑降低杠杆或清理杠杆仓位,暂停加仓;如需保留风险敞口,先降到可承受的小仓位。",
120132
"strategy_plugin_guidance_crisis_response_shadow_no_action_blocked": "危机路线被风控阻断;先核对数据新鲜度和外部情境,不建议仅凭此条加仓。",
133+
"strategy_plugin_guidance_macro_risk_governor_delever_delever": "宏观风险控制建议降低杠杆敞口;是否执行由策略侧可回测规则和仓位适配器决定。",
134+
"strategy_plugin_guidance_macro_risk_governor_crisis_defend": "宏观危机信号建议风险仓位转向防守或现金类资产,直到压力缓和。",
135+
"strategy_plugin_guidance_market_regime_control_risk_off_defend": "市场状态控制进入风险关闭;机会类信号先不执行,风险仓位应保持防守。",
136+
"strategy_plugin_guidance_market_regime_control_risk_reduced_delever": "市场状态控制建议降杠杆;自动仓位调整只按策略侧已批准的可回测规则执行。",
137+
"strategy_plugin_guidance_market_regime_control_opportunity_watch_notify_manual_review": "仅作人工复核:市场状态允许有限机会观察,但插件本身不会下单或直接改仓位。",
138+
"strategy_plugin_guidance_market_regime_control_blocked_blocked": "市场状态控制被数据质量或新鲜度保护阻断;先核对数据源和产物,再决定是否人工处理。",
121139
"strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO 仅提示可能的反弹窗口;可考虑小仓位、分批、预设止损/失效条件的人工博弈,不建议一次性满仓。",
122140
"no_trades": "✅ 无需调仓",
123141
"emergency": "🛡️ 金丝雀应急: {n_bad}/4 坏, 全部转入 {safe}",
@@ -253,21 +271,39 @@
253271
"strategy_plugin_alert_scope_note": "Execution scope: {scope_note}",
254272
"strategy_plugin_alert_scope": "Manual review notice only; the plugin does not place orders or change allocations",
255273
"strategy_plugin_name_crisis_response_shadow": "Crisis Watch Notice",
274+
"strategy_plugin_name_macro_risk_governor": "Macro Risk Governor Notice",
275+
"strategy_plugin_name_market_regime_control": "Market Regime Control Notice",
276+
"strategy_plugin_name_panic_reversal_shadow": "Panic Reversal Watch Notice",
256277
"strategy_plugin_name_taco_rebound_shadow": "TACO Rebound Watch Notice",
257278
"strategy_plugin_mode_shadow": "shadow",
279+
"strategy_plugin_route_blocked": "blocked",
280+
"strategy_plugin_route_crisis": "crisis",
281+
"strategy_plugin_route_delever": "de-lever",
258282
"strategy_plugin_route_no_action": "no alert",
283+
"strategy_plugin_route_opportunity_watch": "opportunity watch",
284+
"strategy_plugin_route_panic_reversal": "panic reversal",
285+
"strategy_plugin_route_risk_off": "risk off",
286+
"strategy_plugin_route_risk_reduced": "risk reduced",
259287
"strategy_plugin_route_true_crisis": "true crisis",
260288
"strategy_plugin_route_taco_rebound": "TACO rebound confirmed",
261289
"strategy_plugin_route_unknown_route": "unknown status",
290+
"strategy_plugin_route_watch": "watch",
262291
"strategy_plugin_action_no_action": "no action",
263292
"strategy_plugin_action_watch_only": "notify only",
264293
"strategy_plugin_action_notify_manual_review": "notify manual review",
265294
"strategy_plugin_action_defend": "defend",
295+
"strategy_plugin_action_delever": "de-lever",
266296
"strategy_plugin_action_blocked": "blocked",
267297
"strategy_plugin_action_monitor": "watch",
268298
"strategy_plugin_action_unknown_action": "unknown notice",
269299
"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.",
270300
"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.",
301+
"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.",
302+
"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.",
303+
"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.",
304+
"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.",
305+
"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.",
306+
"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.",
271307
"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.",
272308
"no_trades": "✅ No rebalance needed",
273309
"emergency": "🛡️ Canary Emergency: {n_bad}/4 bad, rotating to {safe}",

tests/test_notifications.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,20 @@ def test_build_translator_supports_chinese():
135135
)
136136
== "🧩 插件:TACO 抄底观察通知 | 状态:TACO 反弹确认 | 提醒:通知人工复核"
137137
)
138+
assert (
139+
translate(
140+
"strategy_plugin_line",
141+
plugin=translate("strategy_plugin_name_market_regime_control"),
142+
mode=translate("strategy_plugin_mode_shadow"),
143+
route=translate("strategy_plugin_route_risk_reduced"),
144+
action=translate("strategy_plugin_action_delever"),
145+
)
146+
== "🧩 插件:市场状态控制通知 | 状态:风险降低 | 提醒:降杠杆"
147+
)
138148
assert translate("strategy_plugin_alert_guidance", guidance="小仓位博弈") == "处置建议:小仓位博弈"
139149
assert translate("strategy_plugin_alert_scope_note", scope_note="不会自动下单") == "执行范围:不会自动下单"
140150
assert "降低杠杆" in translate("strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend")
151+
assert "策略侧已批准" in translate("strategy_plugin_guidance_market_regime_control_risk_reduced_delever")
141152
assert "小仓位" in translate("strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review")
142153
assert translate("account_ids_detail", account_ids="U1234567") == "🆔 账户: U1234567"
143154
assert (

0 commit comments

Comments
 (0)