自选清理+新增策略

1. 13只已持仓自选股移除(watchlist 32→19)
2. 贵州茅台(600519) 买入区1101~1184 止损1068 止盈1300 RR=1.3
3. 中国平安(601318) 买入区43~46.8 止损41.4 止盈58.9 RR=2.0
4. 两股均空头排列,信号=等待企稳
This commit is contained in:
知微
2026-06-28 00:12:31 +08:00
parent 8474effcad
commit 91d2957ab0
6 changed files with 18480 additions and 118 deletions
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Remove held stocks from watchlist"""
import json, os
WL = "/home/hmo/web-dashboard/data/watchlist.json"
DEC = "/home/hmo/web-dashboard/data/decisions.json"
holding_codes = set()
pf = json.load(open("/home/hmo/web-dashboard/data/portfolio.json"))
for h in pf.get("holdings", []):
c = h.get("code", "")
if c:
holding_codes.add(c)
print(f"持仓 codes: {sorted(holding_codes)}")
# Load watchlist
wl = json.load(open(WL))
stocks = wl.get("stocks", [])
before = len(stocks)
# Remove held stocks
new_stocks = [s for s in stocks if s.get("code") not in holding_codes]
removed = [s for s in stocks if s.get("code") in holding_codes]
after = len(new_stocks)
wl["stocks"] = new_stocks
# Backup
os.rename(WL, WL + ".bak2")
json.dump(wl, open(WL, "w"), indent=2, ensure_ascii=False)
print(f"\n自选: {before}{after}")
print(f"移除 {len(removed)} 只:")
for r in removed:
print(f" {r['code']} {r.get('name','')}")
# Also update decisions.json - set them to "managed_by_holdings" or remove watchlist-only fields
dec = json.load(open(DEC))
dec_changed = 0
for d in dec.get("decisions", []):
code = d.get("code", "")
if code in [r["code"] for r in removed]:
# Remove watchlist-specific tags
if d.get("tag") == "watchlist":
d["tag"] = "managed_by_holdings"
dec_changed += 1
if dec_changed:
os.rename(DEC, DEC + ".bak3")
json.dump(dec, open(DEC, "w"), indent=2, ensure_ascii=False)
print(f"\ndecisions.json: {dec_changed} 只更新标签")
else:
print(f"\ndecisions.json: 无需更新")
print("\nDONE")