Skip to content

Commit 0e8c734

Browse files
authored
Humanize plugin alert messages (#99)
1 parent 5ee38a0 commit 0e8c734

3 files changed

Lines changed: 343 additions & 30 deletions

File tree

src/quant_platform_kit/common/notification_localization.py

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,34 @@
2626

2727
STRATEGY_PLUGIN_I18N: dict[str, dict[str, str]] = {
2828
"zh": {
29+
"strategy_plugin_alert_locale": "zh-CN",
30+
"strategy_plugin_alert_reason_joiner": "、",
31+
"strategy_plugin_alert_reason_none": "未提供明确原因",
2932
"strategy_plugin_line": "🧩 插件:{plugin} | 状态:{route} | 提醒:{action}",
30-
"strategy_plugin_alert_subject": "🚨 策略插件告警:{plugin} | {route}",
31-
"strategy_plugin_alert_title": "🚨 【策略插件告警】",
32-
"strategy_plugin_alert_context": "运行环境:{context}",
33+
"strategy_plugin_alert_subject": "策略插件提醒:{plugin} | {route}",
34+
"strategy_plugin_alert_title": "【策略插件提醒】",
35+
"strategy_plugin_alert_context": "发布来源:{context}",
36+
"strategy_plugin_alert_context_strategy_plugin_publish": "插件发布 / {target}",
3337
"strategy_plugin_alert_target": "{target_name}:{target}",
3438
"strategy_plugin_alert_target_name_strategy": "策略",
35-
"strategy_plugin_alert_target_name_notification_target": "通知目标",
39+
"strategy_plugin_alert_target_name_notification_target": "通知对象",
3640
"strategy_plugin_alert_strategy": "策略:{strategy}",
3741
"strategy_plugin_alert_plugin": "插件:{plugin}",
38-
"strategy_plugin_alert_status": "状态:{route}",
39-
"strategy_plugin_alert_action": "人工处理建议:{action}",
42+
"strategy_plugin_alert_situation": "当前情况:{situation}",
43+
"strategy_plugin_alert_recommendation": "建议处理:{recommendation}",
44+
"strategy_plugin_alert_status": "插件状态:{route}",
45+
"strategy_plugin_alert_action": "动作边界:{action}",
4046
"strategy_plugin_alert_mode": "模式:{mode}",
4147
"strategy_plugin_alert_as_of": "信号时间:{as_of}",
4248
"strategy_plugin_alert_guidance": "处置建议:{guidance}",
43-
"strategy_plugin_alert_scope_note": "执行范围:{scope_note}",
44-
"strategy_plugin_alert_scope": "仅作人工复核提醒;插件不会自动下单或改仓位",
49+
"strategy_plugin_alert_scope_note": "自动化边界:{scope_note}",
50+
"strategy_plugin_alert_scope": "这条通知只用于人工复核;插件不会自动下单,也不会直接修改仓位",
4551
"strategy_plugin_name_crisis_response_shadow": "危机观察通知",
4652
"strategy_plugin_name_macro_risk_governor": "宏观风险控制通知",
47-
"strategy_plugin_name_market_regime_control": "市场状态控制通知",
53+
"strategy_plugin_name_market_regime_control": "市场状态控制",
4854
"strategy_plugin_name_panic_reversal_shadow": "恐慌反转观察通知",
4955
"strategy_plugin_name_taco_rebound_shadow": "TACO 反弹观察通知",
56+
"strategy_plugin_notification_target_market_regime_notification": "统一市场状态通知",
5057
"strategy_plugin_mode_shadow": "影子观察",
5158
"strategy_plugin_route_blocked": "已阻断",
5259
"strategy_plugin_route_crisis": "危机",
@@ -61,13 +68,30 @@
6168
"strategy_plugin_route_unknown_route": "未知状态",
6269
"strategy_plugin_route_watch": "观察",
6370
"strategy_plugin_action_no_action": "不操作",
64-
"strategy_plugin_action_watch_only": "仅通知",
71+
"strategy_plugin_action_watch_only": "仅观察,不自动交易",
6572
"strategy_plugin_action_notify_manual_review": "通知人工复核",
6673
"strategy_plugin_action_defend": "防守",
6774
"strategy_plugin_action_delever": "降杠杆",
6875
"strategy_plugin_action_blocked": "已阻断",
6976
"strategy_plugin_action_monitor": "持续观察",
7077
"strategy_plugin_action_unknown_action": "未知提醒",
78+
"strategy_plugin_situation_watch_watch_only": "当前不是危机,也不是自动抄底信号;插件只提示市场进入观察状态。触发原因:{reasons}。",
79+
"strategy_plugin_situation_market_regime_control_watch_watch_only": "当前不是危机,也不是自动抄底信号;市场状态控制只提示波动或宏观条件进入观察区。触发原因:{reasons}。",
80+
"strategy_plugin_situation_market_regime_control_risk_reduced_delever": "市场压力升高,策略可能需要按已批准的可回测规则降杠杆。触发原因:{reasons}。",
81+
"strategy_plugin_situation_market_regime_control_risk_off_defend": "市场状态进入防守区,机会类信号应先让位给风险控制。触发原因:{reasons}。",
82+
"strategy_plugin_situation_market_regime_control_opportunity_watch_notify_manual_review": "出现可能的反弹或低吸窗口,但证据只够人工复核,不足以自动交易。触发原因:{reasons}。",
83+
"strategy_plugin_situation_market_regime_control_blocked_blocked": "数据质量或新鲜度保护触发,当前插件信号不能直接使用。触发原因:{reasons}。",
84+
"strategy_plugin_situation_taco_rebound_shadow_taco_rebound_notify_manual_review": "出现 TACO 反弹观察窗口;这属于人工复核机会,不是自动买入信号。触发原因:{reasons}。",
85+
"strategy_plugin_situation_true_crisis_defend": "危机防守信号已触发,需要优先处理风险敞口。触发原因:{reasons}。",
86+
"strategy_plugin_situation_delever_delever": "降杠杆信号已触发,需要按策略规则压低风险敞口。触发原因:{reasons}。",
87+
"strategy_plugin_situation_notify_manual_review": "插件发现需要人工复核的市场状态。触发原因:{reasons}。",
88+
"strategy_plugin_situation_default": "插件发现需要关注的市场状态。触发原因:{reasons}。",
89+
"strategy_plugin_recommendation_watch_only": "先人工核对市场环境和现有仓位;策略仓位不因这条通知自动调整,具体买卖仍以策略运行结果或人工确认执行。",
90+
"strategy_plugin_recommendation_notify_manual_review": "人工复核触发原因、新闻/宏观背景、现有仓位和失效条件;未确认前不要把这条通知当成下单指令。",
91+
"strategy_plugin_recommendation_defend": "优先确认策略运行结果和账户约束;如果策略已触发自动防守,由策略通知和仓位适配器执行,插件通知本身不直接下单。",
92+
"strategy_plugin_recommendation_delever": "优先确认策略运行结果和账户约束;如果策略已触发自动降杠杆,由策略通知和仓位适配器执行,插件通知本身不直接下单。",
93+
"strategy_plugin_recommendation_blocked": "先修复数据源或产物新鲜度,再决定是否人工处理;不要基于被阻断的信号调仓。",
94+
"strategy_plugin_recommendation_default": "先人工复核,再决定是否交给策略规则或人工流程处理;不要把插件通知直接当作交易指令。",
7195
"strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend": "优先考虑降低杠杆或清理杠杆仓位,暂停加仓;如需保留风险敞口,先降到可承受的小仓位。",
7296
"strategy_plugin_guidance_crisis_response_shadow_no_action_blocked": "危机路线被风控阻断;先核对数据新鲜度和外部情境,不建议仅凭此条加仓。",
7397
"strategy_plugin_guidance_macro_risk_governor_delever_delever": "宏观风险控制建议降低杠杆敞口;是否执行由策略侧可回测规则和仓位适配器决定。",
@@ -79,27 +103,34 @@
79103
"strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO 仅提示可能的反弹窗口;可考虑小仓位、分批、预设止损/失效条件的人工博弈,不建议一次性满仓。",
80104
},
81105
"en": {
106+
"strategy_plugin_alert_locale": "en-US",
107+
"strategy_plugin_alert_reason_joiner": ", ",
108+
"strategy_plugin_alert_reason_none": "no explicit reason provided",
82109
"strategy_plugin_line": "🧩 Plugin: {plugin} | status: {route} | notice: {action}",
83-
"strategy_plugin_alert_subject": "🚨 Strategy plugin alert: {plugin} | {route}",
84-
"strategy_plugin_alert_title": "🚨 【Strategy Plugin Alert】",
85-
"strategy_plugin_alert_context": "Context: {context}",
110+
"strategy_plugin_alert_subject": "Strategy plugin notice: {plugin} | {route}",
111+
"strategy_plugin_alert_title": "【Strategy Plugin Notice】",
112+
"strategy_plugin_alert_context": "Source: {context}",
113+
"strategy_plugin_alert_context_strategy_plugin_publish": "plugin publish / {target}",
86114
"strategy_plugin_alert_target": "{target_name}: {target}",
87115
"strategy_plugin_alert_target_name_strategy": "Strategy",
88-
"strategy_plugin_alert_target_name_notification_target": "Notification target",
116+
"strategy_plugin_alert_target_name_notification_target": "Notification scope",
89117
"strategy_plugin_alert_strategy": "Strategy: {strategy}",
90118
"strategy_plugin_alert_plugin": "Plugin: {plugin}",
91-
"strategy_plugin_alert_status": "Status: {route}",
92-
"strategy_plugin_alert_action": "Notice: {action}",
119+
"strategy_plugin_alert_situation": "Situation: {situation}",
120+
"strategy_plugin_alert_recommendation": "Suggested review: {recommendation}",
121+
"strategy_plugin_alert_status": "Plugin status: {route}",
122+
"strategy_plugin_alert_action": "Action boundary: {action}",
93123
"strategy_plugin_alert_mode": "Mode: {mode}",
94124
"strategy_plugin_alert_as_of": "Signal as-of: {as_of}",
95125
"strategy_plugin_alert_guidance": "Manual guidance: {guidance}",
96-
"strategy_plugin_alert_scope_note": "Execution scope: {scope_note}",
97-
"strategy_plugin_alert_scope": "Manual review notice only; the plugin does not place orders or change allocations",
126+
"strategy_plugin_alert_scope_note": "Automation boundary: {scope_note}",
127+
"strategy_plugin_alert_scope": "Manual review notice only; the plugin does not place orders or directly change allocations",
98128
"strategy_plugin_name_crisis_response_shadow": "Crisis Watch Notice",
99129
"strategy_plugin_name_macro_risk_governor": "Macro Risk Governor Notice",
100-
"strategy_plugin_name_market_regime_control": "Market Regime Control Notice",
130+
"strategy_plugin_name_market_regime_control": "Market Regime Control",
101131
"strategy_plugin_name_panic_reversal_shadow": "Panic Reversal Watch Notice",
102132
"strategy_plugin_name_taco_rebound_shadow": "TACO Rebound Watch Notice",
133+
"strategy_plugin_notification_target_market_regime_notification": "Unified market-regime notification",
103134
"strategy_plugin_mode_shadow": "shadow",
104135
"strategy_plugin_route_blocked": "blocked",
105136
"strategy_plugin_route_crisis": "crisis",
@@ -121,6 +152,23 @@
121152
"strategy_plugin_action_blocked": "blocked",
122153
"strategy_plugin_action_monitor": "watch",
123154
"strategy_plugin_action_unknown_action": "unknown notice",
155+
"strategy_plugin_situation_watch_watch_only": "This is not a crisis signal and not an automatic dip-buy signal; the plugin is only flagging a watch state. Trigger: {reasons}.",
156+
"strategy_plugin_situation_market_regime_control_watch_watch_only": "This is not a crisis signal and not an automatic dip-buy signal; market-regime control is only flagging volatility or macro conditions for review. Trigger: {reasons}.",
157+
"strategy_plugin_situation_market_regime_control_risk_reduced_delever": "Market stress has risen; the strategy may need to reduce leverage under approved backtestable rules. Trigger: {reasons}.",
158+
"strategy_plugin_situation_market_regime_control_risk_off_defend": "The market regime is defensive; opportunity signals should give way to risk control. Trigger: {reasons}.",
159+
"strategy_plugin_situation_market_regime_control_opportunity_watch_notify_manual_review": "A possible rebound or dip-buy window is present, but the evidence is only strong enough for manual review, not automatic trading. Trigger: {reasons}.",
160+
"strategy_plugin_situation_market_regime_control_blocked_blocked": "Data-quality or freshness guards blocked the signal, so it should not be used directly. Trigger: {reasons}.",
161+
"strategy_plugin_situation_taco_rebound_shadow_taco_rebound_notify_manual_review": "A TACO rebound watch window is present; this is a manual-review opportunity, not an automatic buy signal. Trigger: {reasons}.",
162+
"strategy_plugin_situation_true_crisis_defend": "A crisis-defense signal is active and risk exposure needs priority review. Trigger: {reasons}.",
163+
"strategy_plugin_situation_delever_delever": "A de-lever signal is active and risk exposure should be reduced under strategy rules. Trigger: {reasons}.",
164+
"strategy_plugin_situation_notify_manual_review": "The plugin found a market state that needs manual review. Trigger: {reasons}.",
165+
"strategy_plugin_situation_default": "The plugin found a market state that needs attention. Trigger: {reasons}.",
166+
"strategy_plugin_recommendation_watch_only": "Review the market context and current holdings first; this notice does not automatically change strategy exposure, and any trade should come from the strategy run or an explicit manual decision.",
167+
"strategy_plugin_recommendation_notify_manual_review": "Review the trigger, news or macro context, current exposure, and invalidation level before acting; do not treat this notice as an order instruction.",
168+
"strategy_plugin_recommendation_defend": "Confirm the strategy run and account constraints first; if automatic defense is active, execution belongs to the strategy notification and position adapter, not to this plugin notice.",
169+
"strategy_plugin_recommendation_delever": "Confirm the strategy run and account constraints first; if automatic de-levering is active, execution belongs to the strategy notification and position adapter, not to this plugin notice.",
170+
"strategy_plugin_recommendation_blocked": "Fix source data or artifact freshness before acting; do not adjust exposure from a blocked signal.",
171+
"strategy_plugin_recommendation_default": "Review manually first, then decide whether the action belongs to strategy rules or a manual process; do not treat the plugin notice as a trade instruction.",
124172
"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.",
125173
"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.",
126174
"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.",

0 commit comments

Comments
 (0)