Skip to content

Commit 2d917d8

Browse files
committed
Refine strategy plugin alert copy
1 parent 0e8c734 commit 2d917d8

3 files changed

Lines changed: 49 additions & 28 deletions

File tree

src/quant_platform_kit/common/notification_localization.py

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"strategy_plugin_alert_strategy": "策略:{strategy}",
4141
"strategy_plugin_alert_plugin": "插件:{plugin}",
4242
"strategy_plugin_alert_situation": "当前情况:{situation}",
43+
"strategy_plugin_alert_trigger": "触发原因:{reasons}",
4344
"strategy_plugin_alert_recommendation": "建议处理:{recommendation}",
4445
"strategy_plugin_alert_status": "插件状态:{route}",
4546
"strategy_plugin_alert_action": "动作边界:{action}",
@@ -75,18 +76,23 @@
7576
"strategy_plugin_action_blocked": "已阻断",
7677
"strategy_plugin_action_monitor": "持续观察",
7778
"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": "先人工核对市场环境和现有仓位;策略仓位不因这条通知自动调整,具体买卖仍以策略运行结果或人工确认执行。",
79+
"strategy_plugin_situation_watch_watch_only": "观察状态:插件检测到市场进入观察区。",
80+
"strategy_plugin_situation_market_regime_control_watch_watch_only": "波动观察:市场状态控制检测到波动或宏观压力进入观察区。",
81+
"strategy_plugin_situation_market_regime_control_risk_reduced_delever": "自动降杠杆候选:市场压力升高,策略可按已批准的可回测规则降低杠杆。",
82+
"strategy_plugin_situation_market_regime_control_risk_off_defend": "防守状态:市场状态进入风险关闭区,机会类信号应先让位给风险控制。",
83+
"strategy_plugin_situation_market_regime_control_opportunity_watch_notify_manual_review": "机会观察:出现可能的反弹或低吸窗口,当前证据只够人工复核。",
84+
"strategy_plugin_situation_market_regime_control_blocked_blocked": "数据阻断:数据质量或新鲜度保护已触发,当前插件信号不能直接使用。",
85+
"strategy_plugin_situation_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO 反弹观察:出现可能的反弹窗口,属于人工复核机会。",
86+
"strategy_plugin_situation_true_crisis_defend": "危机防守:危机防守信号已触发,需要优先处理风险敞口。",
87+
"strategy_plugin_situation_delever_delever": "降杠杆:降杠杆信号已触发,需要按策略规则压低风险敞口。",
88+
"strategy_plugin_situation_notify_manual_review": "人工复核:插件发现需要人工判断的市场状态。",
89+
"strategy_plugin_situation_default": "状态提醒:插件发现需要关注的市场状态。",
90+
"strategy_plugin_recommendation_market_regime_control_watch_watch_only": "核对触发项、近几日波动和当前仓位杠杆;这类观察通知不自动改仓位,需要调仓时以策略运行结果或人工确认执行。",
91+
"strategy_plugin_recommendation_market_regime_control_risk_reduced_delever": "核对策略运行结果、账户约束和降杠杆阈值;若策略侧已触发自动规则,由策略通知和仓位适配器执行。",
92+
"strategy_plugin_recommendation_market_regime_control_risk_off_defend": "暂停机会类加仓判断,先确认防守仓位是否符合策略规则;恢复进攻前等待风险关闭状态解除。",
93+
"strategy_plugin_recommendation_market_regime_control_opportunity_watch_notify_manual_review": "人工核对反弹质量、成交/趋势确认和失效条件;确认前只作为低吸候选,不直接转成自动买入。",
94+
"strategy_plugin_recommendation_market_regime_control_blocked_blocked": "先修复数据源、产物新鲜度或校验失败项;阻断解除前不要基于这条信号调仓。",
95+
"strategy_plugin_recommendation_watch_only": "核对触发项、市场环境和现有仓位;观察通知不自动改仓位,需要调仓时以策略运行结果或人工确认执行。",
9096
"strategy_plugin_recommendation_notify_manual_review": "人工复核触发原因、新闻/宏观背景、现有仓位和失效条件;未确认前不要把这条通知当成下单指令。",
9197
"strategy_plugin_recommendation_defend": "优先确认策略运行结果和账户约束;如果策略已触发自动防守,由策略通知和仓位适配器执行,插件通知本身不直接下单。",
9298
"strategy_plugin_recommendation_delever": "优先确认策略运行结果和账户约束;如果策略已触发自动降杠杆,由策略通知和仓位适配器执行,插件通知本身不直接下单。",
@@ -117,6 +123,7 @@
117123
"strategy_plugin_alert_strategy": "Strategy: {strategy}",
118124
"strategy_plugin_alert_plugin": "Plugin: {plugin}",
119125
"strategy_plugin_alert_situation": "Situation: {situation}",
126+
"strategy_plugin_alert_trigger": "Trigger: {reasons}",
120127
"strategy_plugin_alert_recommendation": "Suggested review: {recommendation}",
121128
"strategy_plugin_alert_status": "Plugin status: {route}",
122129
"strategy_plugin_alert_action": "Action boundary: {action}",
@@ -152,18 +159,23 @@
152159
"strategy_plugin_action_blocked": "blocked",
153160
"strategy_plugin_action_monitor": "watch",
154161
"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.",
162+
"strategy_plugin_situation_watch_watch_only": "Watch state: the plugin detected that the market has entered a watch zone.",
163+
"strategy_plugin_situation_market_regime_control_watch_watch_only": "Volatility watch: market-regime control detected volatility or macro pressure in the watch zone.",
164+
"strategy_plugin_situation_market_regime_control_risk_reduced_delever": "Automatic de-lever candidate: market stress has risen, and the strategy may reduce leverage under approved backtestable rules.",
165+
"strategy_plugin_situation_market_regime_control_risk_off_defend": "Defensive state: the market regime is in the risk-off zone, so opportunity signals should give way to risk control.",
166+
"strategy_plugin_situation_market_regime_control_opportunity_watch_notify_manual_review": "Opportunity watch: a possible rebound or dip-buy window is present, but the evidence is only strong enough for manual review.",
167+
"strategy_plugin_situation_market_regime_control_blocked_blocked": "Data block: data-quality or freshness guards fired, so the current plugin signal cannot be used directly.",
168+
"strategy_plugin_situation_taco_rebound_shadow_taco_rebound_notify_manual_review": "TACO rebound watch: a possible rebound window is present and needs manual review.",
169+
"strategy_plugin_situation_true_crisis_defend": "Crisis defense: a crisis-defense signal is active and risk exposure needs priority review.",
170+
"strategy_plugin_situation_delever_delever": "De-lever: a de-lever signal is active and risk exposure should be reduced under strategy rules.",
171+
"strategy_plugin_situation_notify_manual_review": "Manual review: the plugin found a market state that needs human judgment.",
172+
"strategy_plugin_situation_default": "State notice: the plugin found a market state that needs attention.",
173+
"strategy_plugin_recommendation_market_regime_control_watch_watch_only": "Check the trigger, recent volatility, and current leverage; this watch notice does not change allocations automatically, and any position change should come from the strategy run or an explicit manual decision.",
174+
"strategy_plugin_recommendation_market_regime_control_risk_reduced_delever": "Check the strategy run, account constraints, and de-lever thresholds; if the strategy-side automatic rule fired, execution belongs to the strategy notification and position adapter.",
175+
"strategy_plugin_recommendation_market_regime_control_risk_off_defend": "Pause opportunity adds and confirm whether defensive exposure matches strategy rules; wait for the risk-off state to clear before resuming offensive signals.",
176+
"strategy_plugin_recommendation_market_regime_control_opportunity_watch_notify_manual_review": "Manually review rebound quality, volume/trend confirmation, and the invalidation level; treat it as a dip-buy candidate only until confirmed.",
177+
"strategy_plugin_recommendation_market_regime_control_blocked_blocked": "Fix source data, artifact freshness, or validation failures first; do not adjust exposure from this signal until the block clears.",
178+
"strategy_plugin_recommendation_watch_only": "Review the trigger, market context, and current holdings; watch notices do not change allocations automatically, and any trade should come from the strategy run or an explicit manual decision.",
167179
"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.",
168180
"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.",
169181
"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.",

src/quant_platform_kit/common/strategy_plugins.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ def build_strategy_plugin_alert_messages(
13441344
fallback="Notification target" if target_type == "notification_target" else "Strategy",
13451345
)
13461346
guidance = build_strategy_plugin_alert_guidance(signal, translator=translator)
1347+
reason_summary = build_strategy_plugin_alert_reason_summary(signal, translator=translator)
13471348
situation = build_strategy_plugin_alert_situation(signal, translator=translator)
13481349
recommendation = build_strategy_plugin_alert_recommendation(signal, translator=translator)
13491350
scope_note = build_strategy_plugin_alert_scope_note(signal, translator=translator)
@@ -1398,6 +1399,12 @@ def build_strategy_plugin_alert_messages(
13981399
fallback="Situation: {situation}",
13991400
situation=situation,
14001401
),
1402+
_translate(
1403+
translator,
1404+
"strategy_plugin_alert_trigger",
1405+
fallback="Trigger: {reasons}",
1406+
reasons=reason_summary,
1407+
),
14011408
_translate(
14021409
translator,
14031410
"strategy_plugin_alert_recommendation",
@@ -1461,7 +1468,7 @@ def build_strategy_plugin_alert_messages(
14611468
"display_target": display_target_label,
14621469
"situation": situation,
14631470
"recommendation": recommendation,
1464-
"reason_summary": build_strategy_plugin_alert_reason_summary(signal, translator=translator),
1471+
"reason_summary": reason_summary,
14651472
"guidance": guidance,
14661473
"scope_note": scope_note,
14671474
"ai_audit": getattr(signal, "payload", {}).get("ai_audit")

tests/test_strategy_plugins.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,11 @@ def test_market_regime_notification_alert_explains_situation_and_next_step_in_zh
846846
self.assertIn("[插件发布 / 统一市场状态通知]", alerts[0].subject)
847847
self.assertNotIn("strategy-plugin-publish", alerts[0].subject)
848848
self.assertIn("通知对象:统一市场状态通知", alerts[0].body)
849-
self.assertIn("当前情况:当前不是危机,也不是自动抄底信号", alerts[0].body)
850-
self.assertIn("宏观:实现波动偏高", alerts[0].body)
851-
self.assertIn("建议处理:先人工核对市场环境和现有仓位", alerts[0].body)
849+
self.assertIn("当前情况:波动观察:市场状态控制检测到波动或宏观压力进入观察区。", alerts[0].body)
850+
self.assertIn("触发原因:宏观:实现波动偏高", alerts[0].body)
851+
self.assertIn("建议处理:核对触发项、近几日波动和当前仓位杠杆", alerts[0].body)
852+
self.assertNotIn("不是危机", alerts[0].body)
853+
self.assertNotIn("不是自动抄底信号", alerts[0].body)
852854
self.assertIn("动作边界:仅观察,不自动交易", alerts[0].body)
853855
self.assertIn("自动化边界:这条通知只用于人工复核", alerts[0].body)
854856
self.assertEqual(alerts[0].metadata["display_target"], "统一市场状态通知")

0 commit comments

Comments
 (0)