Files
MoFin/scripts/_watchdog_report.py
T
知微 66962ae190 fix: 全面系统修复 — delivery目标修正 + 脚本同步 + refresh_mtf_cache import修复 + clean_watchlist硬编码修复
修复清单:
- cron delivery修正:10个job从deliver=origin/all改为local,消除推送错误
- refresh_mtf_cache.py:替换strategy_lifecycle.PORTFOLIO_PATH导入为mofin_db直接读DB
- clean_watchlist.py:修复mo_data导入名错误和JSON硬编码路径
- MoFin/scripts/与profile scripts互相补全,双向sync到一致
- price_monitor.py:现金源从portfolio_summary表改为cash_log(Dad确认的现金权威)
- 更新watchlist.json加入000850华茂股份
2026-07-06 14:01:54 +08:00

36 lines
1.2 KiB
Python

import sys; sys.path.insert(0, '/home/hmo/MoFin')
from mo_data import *
# Portfolio
pf = read_portfolio()
ta = pf.get('total_assets',0)
ca = pf.get('cash',0)
pp = pf.get('position_pct',0)
print(f"总资产: {ta:.0f} 现金: {ca:.0f} 仓位: {pp:.1f}%")
for h in pf.get('holdings', []):
c = h.get('currency','CNY')
price = h['price']
cost = h['cost']
profit_pct = (price/cost - 1)*100 if cost and cost else 0
ps = f"{price:.2f}{' HKD' if c=='HKD' else ''}"
pp_h = h.get('position_pct')
if pp_h is None: pp_h = 0
print(f" {h['code']} {h['name']}{ps}{pp_h:.1f}% 盈{profit_pct:.1f}%")
# Watchlist
print()
wl = read_watchlist()
for s in wl.get('stocks',[]):
try:
c = s.get('currency','CNY')
price = s.get('price')
if price is None: price = 0
ps = f"{price:.2f}{' HKD' if c=='HKD' else ''}"
el = s.get('entry_low')
eh = s.get('entry_high')
enl = f"{el:.2f}" if el is not None else '?'
enh = f"{eh:.2f}" if eh is not None else '?'
print(f" 自选 {s['code']} {s.get('name','')}{ps}{enl}~{enh}")
except Exception as e:
print(f" ERROR {s.get('code','?')}: {e}")