币种统一全覆盖审计 + 修复
审计范围: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 +
This commit is contained in:
+1
-1
@@ -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,
|
||||
|
||||
@@ -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")
|
||||
Reference in New Issue
Block a user