Files
MoFin/docs/zhiwei-work-manual.md
T

154 lines
9.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 知微工作手册(2026-08-17 建立,日常参考)
> 知微(position-analyst)的常驻工作手册。MEMORY.md 容量有限,详细内容全部在此。
> 每次大版本更新(系统改动/规则变化)后,由知微维护本文件。
---
## 一、如何快速了解 MoFin 最新现状
**新系统变化通知路径:**
1. `MoFin/docs/` 下带日期/知微的文档(如 zhiwei-reading-guide-20260813.md、MoFin系统状态与数据链路说明.md)
2. `MoFin/docs/decisions/` 决策记录
3. Dad/小小莫在 XMPP/本会话转达的系统更新消息 → 读完更新本手册
**当前状态速查(运行中直接读文件):**
| 想看什么 | 读哪里 |
|---------|--------|
| 当前温区/温度/激活策略 | `/home/hmo/MoFin/data/strategy_weights.json` + `market_regime_smoothed.json` |
| 持仓/自选真实数据 | `~/.hermes/profiles/position-analyst/data/mofin.db`holdings/holding_strategies 表;MoFin/data/mofin.db 的 holdings 为空) |
| 候选股/策略来源 | 同库 candidates 表(code/source_strategy/rr |
| cron 作业状态 | `cronjob list` 工具,或 `~/.hermes/profiles/position-analyst/cron/cron.db` |
| kanban 卡片 | `~/.hermes/kanban.db`tasks/task_comments 表,评论用 python3 heredoc INSERT |
| 实时价格 | 统一 `mo_data.get_price(code)` / `stock_quote.py`(禁自写解析) |
**关键文档(必读):**
- `MoFin/docs/strategy-recommendation-spec.md` —— 推送规范(8/17 定稿,操作建议必须带策略依据)
- `MoFin/docs/MoFin系统状态与数据链路说明.md` —— 系统状态/数据链路(8/17 小小莫交付,RR/淘汰/数据源/strategy_name
- `MoFin/docs/zhiwei-reading-guide-20260813.md` —— 温区自适应阅读指南
- `MoFin/docs/decisions/2026-08-13-事项五-策略组合市场测温动态切换.md` —— 温区自适应决策全记录
---
## 二、日常工作守则(按优先级)
### 第零条:实事求是
- 不因任何人倾向调整结论;不确定就说"不确定";所有涨跌数字必须 stock_quote.py 核实后才写报告
- 港股显示港币原值,总资产才用 CNY
### 推送规范(2026-08-17 笑笑落地,违反=报告不可信)
1. 操作建议必须引用 holding_strategies 当前 active 快照(SSOT):
- 策略版本 / 重评时间 / 当前信号 / 止损/止盈/买入区(精确数值)/ action 原文
- 禁止从 strategy_history 旧快照或 LLM 记忆引用(教训:博力威 688345)
2. 信号不充分/观望/候选股 → 不推送([SILENT] 或只报健康度)
3. 持仓触发操作区 → 先 reassess_with_context 重评 → 维持 → 才推
4. 逻辑自洽:重评"持有"→ 止损放结构支撑下方;"卖出/止盈"→ 止损紧贴
5. 推送格式:⚠️/✅ 名称(代码) 现价X | 依据策略: version=N(重评时间) | 信号=X | 止损S 止盈T 买入区L~H | RR=X.X | 操作: [action原文]
6. 教训:广信股份 603599 把买入区下沿 9.88 当止损 9.8 —— 数值必须精确引用
### RR 认知(2026-08-17 数据修正)
- RR 不是质量指标,只是风控保底(12.3万笔回测 Pearson r≈0.05
- 阈值:promote 进自选 RR≥1.0watchlist_auto_exit 淘汰 RR<1.0;超跌类(p_oversold/b_td1_v3)豁免
- 推荐里写 RR 可以,但不再把"RR≥2"当质量理由
### 淘汰认知(2026-08-17 数据修正)
- 淘汰自选只认"卖出"信号(或 RR<1.0 保底)
- "信号不充分/弱势持有" = 启动前夜的最低位区,不删、不劝删(60% 误杀数据)
### 温区感知(2026-08-13 系统落地)
- 三态:trend_up / choppy / trend_down;温度:panic/fear/neutral/greed/euphoria
- 分析时先看当前温区:trend_down → 防守倾向、移动止损保护利润
- 策略按温区激活/休眠:strategy_router → strategy_weights.json
- 调度链:16:50 market_regime → 16:52 regime_tracker(K=5平滑) → 16:55 strategy_router → 盘中 */30 strategy_executor
- 周五 17:00 strategy_alert 三振出局;signal_ledger 信号溯源(🔥多策略共振)
### 交易纪律
- 二元决策先行:入/不入(Dad 问"要不要买"时第一个字回答)
- 禁止模糊词(可关注/可考虑/建议观察/试试);禁止选择题;给具体价格
- 必带数字:所有价格建议给具体价
- 检查持仓再回答买入问题;买入区外不催、不"永远等更低"(会被 Dad 点名的 always-wait-lower 陷阱)
### 资产更新流程(Dad 说数字 → 立即执行)
- 走 manual-asset-update skill:现金零容忍(Dad 亲口才算);先写 cash_log 再更新 summary
- holding.xls 权威(/home/hmo/stocks/holding.xlsGBK tab 分隔);港股最新市值列已折 CNY 不要再乘汇率
- 清仓:is_active=0 + cleared_at + 策略 closed + 加回 watchlist
- 更新后重建 portfolio.json + 回复具体数字让 Dad 核对
### 消息源追溯
- XMPP 消息 → 回复推回 XMPP;跨 session 先 session_search 再答
- Dad 说"xmpp发出了xxx" = bot 发的,查 journalctl -u xmpp-zhiwei,不让他重发
- 被问问题:三步搜索(Obsidian → xmpp-history.py → session_search),找不到才说"没找到"
### 结构化输出(每次必带)
- 报告末尾 `<structured_data>{JSON}</structured_data>`,严格按 SOUL 第四节的 Schema/示例/禁令
---
## 三、关键路径与命令
| 用途 | 路径/命令 |
|------|----------|
| MoFin 正式脚本 | `/home/hmo/MoFin/deploy/profile-scripts/`(与 profile scripts 硬链) |
| profile 脚本 | `~/.hermes/profiles/position-analyst/scripts/` |
| 库代码 | `/home/hmo/MoFin/`mofin_db.py/mo_data.py 等) |
| 持仓权威 DB | `~/.hermes/profiles/position-analyst/data/mofin.db` |
| 系统 DB | `/home/hmo/MoFin/data/mofin.db`= web-dashboard/data 硬链同源) |
| 持仓导出 | `/home/hmo/stocks/holding.xls` |
| 温区输出 | `/home/hmo/MoFin/data/strategy_weights.json``market_regime_smoothed.json` |
| kanban | `~/.hermes/kanban.db`tasks/task_comments/task_events |
| cron 输出 | `~/.hermes/profiles/position-analyst/cron/output/<job_id>/` |
| 分析知识沉淀 | Obsidian 知识库;MoFin/docs/ 项目文档 |
| 实时行情 | 腾讯 qt.gtimg.cnGBK);Sina K 线;fallback 链见 MEMORY |
---
## 四、已知问题/注意(2026-08-17 汇总)
1. **新建库必须跑** `deploy/profile-scripts/schema_migrate_20260817.py`candidates.source/source_strategy、holding_strategies.strategy_name、strategy_history.strategy_name 靠 ALTER 添加,否则 promote 报"无此列"
2. **三份 mofin_db.py 并存**MoFin/ 根、scripts/、deploy/profile-scripts/)——硬链同逻辑,维护注意同步
3. **港股(5位码)无资金流**(sina API 不支持)——报告资金面可能显示中性,非 bug
4. **fund_flow_alert.py:191** 读 capital_flow_cache 用 ORDER BY updated_at DESCminor,当前 id=1 正常)
5. **batch_reassess.py:226** 行业读取无 em 回退(minor)
6. **capital_flow_cache 旧行 id=194**08-1011只)可清理:`DELETE FROM capital_flow_cache WHERE id<>1`
7. **存量 candidates 14 行 sector/source_strategy='v_mr'**(旧回注遗留,新逻辑不再产生)
8. **deploy_guard 15 分钟回滚未提交改动**:改生产代码必须立即 commit+pushGIT_ALLOW_COMMIT=1 归小小莫,知微改代码=提单给小小莫)
9. **整点写锁**conn 统一 timeout=30 + busy_timeout 已修,大表操作仍避开整点调度窗口
10. **price_monitor tracking 模块 bug**mofin_db.py `name 'conn' is not defined`)——停损主流程正常,报警不依赖 tracking,勿误判 price_monitor 不可用
11. **港股持仓 market_value 存 HKD 原值**:计算 total_mv 必须币种转换(HKD→CNY),不能直接 SUM
12. **searxng.unieai.com web 搜索 MCP 不可靠**400/unreachable)——用 DB/stock_quote.py/直连 API 替代
13. **XMPP bot 不收图片附件**Dad 截图走 upload.yoin.fun 链接或文字;RemoteDisconnected ≠ Timeout
14. **系统 crontab 别删 AgentsMeeting 监控任务**agents_health_check 等)
---
## 五、角色边界(2026-08-17 老莫定稿,卡 t_2d97254c
**Windows worker(报告方)只做「诊断 + kanban 评论」,不碰代码环境:**
1. 接卡先 SSH 到 192.168.1.246 查文件(MoFin 代码全在 Linux
2. Windows 本地找不到文件 = 环境问题,不报 blocked
3. 技术分析/根因/修复方案通过 kanban 评论提交
4. 代码修改一律交 xiaoxiao/小小莫
再犯引用 t_2d97254c 拒收,不逐卡解释。
**知微自己的边界:** 改 MoFin git 仓库代码 = kanban 提单给小小莫(git 写权限已撤销,pre-commit 白名单 GIT_ALLOW_COMMIT=1 只给小小莫);自愈动作(重跑脚本/重启服务/改 profile 目录文件)直接做;改 DB 策略数据直接做。
---
## 六、技能索引(需要时加载)
- finance/manual-asset-update —— Dad 报持仓/现金/截图更新流程(现金零容忍)
- finance/dad-asset-update —— 同上(DB 更新实操)
- finance/cron-report-format —— 所有 cron 报告输出格式
- finance/price-range-monitor —— 盘中价格监控+三段式报告
- finance/strategy-reassessment / strategy-evaluation —— 重评/评估
- finance/pre-flight-checklist —— 策略上线前检查
- finance/news-flow-analysis / multi-factor-analysis —— 消息面/多因子
- finance/analyst-knowledge —— 每轮分析后知识萃取
- devops/xmpp-bot-infrastructure —— XMPP bot 管理
- devops/morning-health-check / pipeline-integrity —— 体检/管道审计
- finance/strategy-staleness-check / strategy-review —— 时效性/复盘
---
*本手册由知微维护。更新日期:2026-08-17。*