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
39 changes: 39 additions & 0 deletions docs/operational_attention_v1.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 可行动注意力门槛 V1(AttentionLevel)

> 状态:库侧纯函数 + drift Telegram 分发修复(本 PR);平台周期接线与 mandate 预算表另票。
> 范围:通知分级 / 人工恢复路由;不授权 live、不抬 RRL、不做 Kelly。

## 原则

1. **不**用全局绝对回撤(如 10%)对 TQQQ/SOXL 发 Telegram。
2. 回撤仅相对显式 `mandate_dd_budget`;缺预算则 **omit** 该轴。
3. 仅 `ACTION` / `HALT` 可通知;键为状态跃迁,发送成功后才记 marker。
4. 自动刹车仍在 NEW_RISK / RiskEngine;本模块只分类注意力与短文案。

## API

- `evaluate_attention(AttentionAxes | mapping) → AttentionDecision`
- `attention_transition_key(...)` 去重键
- `render_attention_compact(locale=...)`(`zh-CN`→`zh`)
- `build_drift_alert` / `publish_drift_alerts`:WATCH 不建页;Telegram 走真实 `send_telegram_message`;缺配置记 `skipped` 并打日志(不再吞异常)

## 分级

| Level | 例 | TG |
|---|---|---|
| OK | 预算内路径回撤 | 否 |
| WATCH | drift watch;dd_ratio∈[0.7,1) | 否 |
| ACTION | NEW_RISK 禁买;drift review;dd 打穿 mandate | 是(跃迁) |
| HALT | drift critical;对账不确定;hard PARK | 是(跃迁) |

## 复利风控审计对照(同批)

生存层(拒单 / 禁新买 / Policy A / RRL)已能支撑「先活下来」的几何复利。
连续最优仓位仍缺:日损事实生产者、`combined_scale` live 缩仓、`assess_with_evidence`。
**默认后置** Kelly / 抬 RRL;下一有界工程仅「日损事实→禁买」(材料齐时)。

## 后续(非本 PR)

- 平台在禁买/CRITICAL 首次跃迁时调用 publish + marker store
- 为 SOXL/TQQQ 配置 mandate_dd_budget(研究/mandate 口径,非 10%)
- 信封 `combined_scale`→目标缩仓另票
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@
"workflow_heartbeat_latest_failed": "最近一次运行未成功完成(结论:{conclusion})",
"workflow_heartbeat_no_success": "GitHub Actions 查询未返回成功的运行记录",
"workflow_heartbeat_query_failed": "GitHub Actions 运行记录查询失败",
"workflow_heartbeat_missing_dispatches": "已连续 {count} 个预期周期未发现运行(阈值:{threshold})",
"workflow_heartbeat_missing_dispatches": "已连续 {count} 个预期周期未发现运行(频率:{threshold})",
"attention_title": "{platform} · {account} · {strategy}",
"attention_result_ok": "结果:运行正常",
"attention_result_watch": "结果:观察中(无需立即处理)",
"attention_result_action": "结果:需确认(已限制新风险或偏离待审)",
"attention_result_halt": "结果:硬停 / 运行异常,需人工恢复",
"attention_result_new_risk_prohibited": "结果:已禁止新增风险",
"attention_reason": "原因:{code}",
"attention_next_none": "下一步:无需操作",
"attention_next_console_optional": "下一步:可在管理站查看详情",
"attention_next_open_console_confirm": "下一步:打开管理站确认意图(accept ≠ live)",
"attention_next_open_console_resume": "下一步:打开管理站处理恢复 / 复位(需授权)",
},
"en": {
"runtime_guard_title": "[Runtime Guard] {name}",
Expand Down Expand Up @@ -85,6 +96,17 @@
"workflow_heartbeat_no_success": "The GitHub Actions query returned no successful runtime run",
"workflow_heartbeat_query_failed": "The GitHub Actions runtime-run query failed",
"workflow_heartbeat_missing_dispatches": "No runtime dispatch was found for {count} expected interval(s) (threshold: {threshold})",
"attention_title": "{platform} · {account} · {strategy}",
"attention_result_ok": "Result: normal",
"attention_result_watch": "Result: watch (no immediate action)",
"attention_result_action": "Result: action needed (new risk limited or drift review)",
"attention_result_halt": "Result: halt / operational fault — human recovery required",
"attention_result_new_risk_prohibited": "Result: new risk additions prohibited",
"attention_reason": "Reason: {code}",
"attention_next_none": "Next: none",
"attention_next_console_optional": "Next: review details in the management console if needed",
"attention_next_open_console_confirm": "Next: open the management console to confirm intent (accept ≠ live)",
"attention_next_open_console_resume": "Next: open the management console for recovery / reset (authorization required)",
},
}

Expand Down
22 changes: 22 additions & 0 deletions src/quant_platform_kit/risk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
resolve_risk_profile_scale,
size_target_weight,
)
from quant_platform_kit.risk.attention import (
AttentionAxes,
AttentionDecision,
AttentionLevel,
attention_alert_key,
attention_level_from_drift_status,
attention_transition_key,
evaluate_attention,
format_attention_compact_message,
render_attention_compact,
should_notify_attention_transition,
)
from quant_platform_kit.risk.synthetic_combo_evidence import (
DEFAULT_CORRELATED_GROUP_CAP,
DEFAULT_CORRELATION_THRESHOLD,
Expand Down Expand Up @@ -159,4 +171,14 @@
"SyntheticComboMember",
"SyntheticComboMemberEvidence",
"evaluate_synthetic_combo_evidence",
"AttentionAxes",
"AttentionDecision",
"AttentionLevel",
"attention_alert_key",
"attention_level_from_drift_status",
"attention_transition_key",
"evaluate_attention",
"format_attention_compact_message",
"render_attention_compact",
"should_notify_attention_transition",
]
Loading
Loading