From 864d9240122260f362942fd8cb47acca544fdaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Wed, 1 Jul 2026 23:28:29 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20CHANGELOG=202026-07-01=20=E2=80=94=20DB?= =?UTF-8?q?=20migration=20+=20single=20price=20source=20+=20health=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5204dd0..c184f8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,3 +165,72 @@ cd /home/hmo/MoFin && python3 migrate_all.py # 2. 如需启用 AlphaSift: ALPHASIFT_ENABLED=true python3 mo_alphasift_bridge.py ``` - LLM 连通:opencode-go 三 Key 正常 + +--- + +## 2026-07-01 — DB 迁移 + 唯一价格源 + 保活机制 + +### JSON → DB 完整迁移(币种约束) + +**4 张核心表加 `currency` 列**(`NOT NULL DEFAULT 'CNY'`): +- `holdings` — 新增 price, market_value, change_pct, currency +- `holding_strategies` — 新增 15 列(currency, action, trigger_json, changelog_json 等) +- `portfolio_summary` — 新增 total_mv, frozen_cash, currency +- `watchlist_stocks` — 新增 10 列(price, entry_low/high, stop_loss, currency, source 等) + +**写入保护**:所有 `write_*` 函数校验币种,写入 USD 直接拒绝。 + +**所有高危写入者已迁移到 DB**: +- `price_monitor.py` — holdings + portfolio_summary + watchlist +- `strategy_lifecycle.py` — regenerate_all → holdings + strategies + watchlist + summary +- `holdings_reconciliation.py` — holdings + strategies + summary +- `process_trade.py` — holdings + strategies +- `import_holding_xls.py` — holdings + summary +- JSON 保留作为冷备(DB 写失败不影响 JSON 写入) + +### 唯一价格源(消除多入口拉价) + +**问题**:17 个文件各自调用腾讯 `qt.gtimg.cn` 拉价,互不通信,币种转换不一致。 + +**修复**:所有价格读取改为 DB 优先,腾讯 API 仅作 fallback。 + +| 文件 | 改动 | +|------|------| +| `mofin_db.py` | 新增 `get_price_from_db()` / `get_prices_batch_from_db()` 通用工具 | +| `strategy_lifecycle.py` | `batch_fetch_prices()` + `get_price_tencent()` DB 优先 | +| `stale_push_wlin.py` | `fetch_trend_data()` + 移除硬编码 0.87 fallback | +| `per_stock_reassess.py` | 价格从 DB 读,不再自拉腾讯 | +| `stale_detector.py` | `fetch_prices()` DB 优先 | +| `server.py` | `/api/portfolio` DB 优先 | +| `strategy_evaluator.py` | `fetch_prices()` DB 优先 | +| `technical_analysis.py` | `get_quote()` DB 优先,移除 60s 缓存 | +| `stock_profile.py` | `get_quote()` DB 优先 | +| `collect_evaluation_data.py` | `fetch_tencent_data()` DB 优先 | +| `branch_scanner.py` (×2) | `get_price()` DB 优先 | +| `strategy_review.py` | `fetch_price()` DB 优先 | +| `xiaoguo_signal_consumer.py` | `fetch_quote()` DB 优先 | + +### price_monitor 保活 + +- **cron**:交易日 9:00-16:00 每 2 分钟 `price_monitor.py` +- **健康检查**:每 10 分钟检查进程 + DB 新鲜度 +- **健康检查脚本**:`scripts/check_price_monitor.py` + +### NEAR_SL 误报修复 + +- `stale_detector.py`:距止损 <5% 时加浮盈判断 +- 浮盈 >5% → `[PROFIT_PROTECT]`(利润保护,不报警) +- 浮盈 ≤5% → `[NEAR_SL]`(真正危险) + +### 小果连接统一 + +- 全部改为 `node122`(机器名),`/etc/hosts` 自动解析 LAN/EasyTier +- 涉及 5 个文件:market_screener, xiaoguo_scanner, xiaoguo_news_processor, intraday_health_check, ocr_client + +### 待办(知微) + +- [ ] 明天开盘验证 price_monitor 正常更新 DB +- [ ] 验证 `[PROFIT_PROTECT]` 标记取代 `[NEAR_SL]` 误报 +- [ ] DB 表新增了列,旧 `migrate_all.py` 可能需要重新跑一次 +- [ ] `refactor-for-xiaoxiao.md` 中的 Phase 2 待讨论 +- [ ] 如果启用 AlphaSift:`ALPHASIFT_ENABLED=true python3 mo_alphasift_bridge.py`