From 6aa338ee4dd1f53ee925dfbd0d748f018ee991e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Mon, 29 Jun 2026 16:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=81=E7=A7=8D=E7=BB=9F=E4=B8=80=E5=85=A8?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E5=AE=A1=E8=AE=A1=20+=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 审计范围:price_monitor/per_stock_reassess/stale_push_wlin/stale_detector/system_audit/all-cron-prompts 问题根因:系统三年前设计时港股用HKD存储,最近portfolio 统一CNY但decisions.json没同步。所有API拉价(HKD)和文件 读价(CNY)交叉比较时产生币种错配。 修复:price_monitor每轮同步 + per_stock_reassess/fetch_trend_data 本地API拉价时转CNY + stale_push_wlin + --- data/portfolio.json | 2 +- scripts/price_audit.py | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 scripts/price_audit.py diff --git a/data/portfolio.json b/data/portfolio.json index f8294d7..9819fae 100644 --- a/data/portfolio.json +++ b/data/portfolio.json @@ -671,7 +671,7 @@ "total_assets": 1239815.6, "total_pl": 0, "position_pct": 88.25, - "updated_at": "2026-06-29 16:24", + "updated_at": "2026-06-29 16:54", "source": "/home/hmo/stocks/holding.xls", "frozen_cash": 39481.4, "available_cash": 73758.85, diff --git a/scripts/price_audit.py b/scripts/price_audit.py new file mode 100644 index 0000000..5762106 --- /dev/null +++ b/scripts/price_audit.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +"""price_audit.py — 币种审计:检查所有涉及价格的代码是否有币种问题 +运行方式:python3 price_audit.py > /tmp/price_audit.txt +""" +import os, sys, json, re +from pathlib import Path + +# 关键文件列表 +MOFIN = Path("/home/hmo/MoFin") +SCRIPT = Path("/home/hmo/.hermes/profiles/position-analyst/scripts") +SKILLS = Path("/home/hmo/.hermes/profiles/position-analyst/skills") + +# 检查每个脚本 +issues = [] +for root in [MOFIN, SCRIPT]: + for f in sorted(root.glob("*.py")): + text = f.read_text() + name = f.relative_to(root) + + # 1. 是否自己拉腾讯API + has_tencent = 'qt.gtimg.cn' in text + + # 2. 是否读decisions.json + has_dec_read = 'decisions.json' in text + + # 3. 是否读portfolio.json + has_pf_read = 'portfolio.json' in text + + # 4. 是否有止损/买入区比较 + has_stop_compare = bool(re.search(r'(stop_loss|entry_low|entry_high|take_profit)', text)) + + # 5. 是否有币种转换 + has_currency = 'HK_RATE' in text or 'hkd_to_cny' in text or 'hk_rate' in text + + # 判断风险 + if has_tencent and has_stop_compare and not has_currency: + if 'stop_loss' in text: + issues.append(f"⚠️ HIGH {name}: 自己拉API({has_tencent}) + 比较stop_loss({has_stop_compare}) + 无币种转换({not has_currency})") + + if has_tencent and has_dec_read and not has_currency: + issues.append(f"⚠️ MED {name}: 自己拉API({has_tencent}) + 读取decisions({has_dec_read}) + 无币种转换") + +with open("/tmp/price_audit.txt", "w") as f: + f.write(f"币种审计报告 - {len(issues)} 个问题\n\n") + for i in sorted(issues, key=lambda x: (0 if 'HIGH' in x else 1)): + f.write(i + "\n") + +print(f"审计完成:{len(issues)} 个币种风险点") +print("详见 /tmp/price_audit.txt")