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")