36 lines
1.2 KiB
Python
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}")
|