持仓来源修复:holding.xls导入+持仓数据修正

老问题:scripts读的是 strategy_staleness_report.json 里的旧现金值,
portfolio.json 被 strategy_lifecycle.regenerate_all 反复覆盖。

修复:
1. import_holding_xls.py — 从 ~/stocks/holding.xls 导入TSV持仓
   (含25只真实持仓,14A/11H,总市值93万,现金8万,仓位92%)
2. stale_push_wlin 现金来源改读 portfolio.json(取代旧stale_report缓存)
3. 港股市值×汇率修正(之前按1:1当人民币算,总资产多估了)
4. 每条策略的决策树同步重建

脚本执行:python3 MoFin/scripts/import_holding_xls.py (含全量重评)
Dad你以后更新holding.xls后跑这条命令就行
This commit is contained in:
知微
2026-06-24 11:19:29 +08:00
parent 046e81a202
commit df4f898bc4
6 changed files with 1445 additions and 1294 deletions
+4 -8
View File
@@ -307,22 +307,18 @@ def main():
except Exception:
pass
# 仓位计算:读取总资产和现金
# 仓位计算:从holding.xls导入的portfolio.json读取总资产和现金
n = len(actionable)
total_assets = 0
available_cash = 0
try:
with open("/home/hmo/web-dashboard/data/strategy_staleness_report.json") as f:
sr = json.load(f)
port = sr.get("portfolio", {})
available_cash = port.get("cash", 0) or 0
except Exception:
pass
try:
with open("/home/hmo/web-dashboard/data/portfolio.json") as f:
pf = json.load(f)
available_cash = pf.get("cash", 0) or 0
for h in pf.get("holdings", []):
mv = h.get("shares", 0) * h.get("price", 0)
if h.get("currency") == "HKD":
mv *= h.get("exchange_rate", 0.866)
total_assets += mv
total_assets += available_cash
except Exception: