A/H跨市场去重:药明康德不再推H股
药明康德(02359) timing_signal=买入、多头排列,但Dad已持有 药明康德A股(603259)。同股同权,H折CNY还贵7.4%。 新增:stale_push_wlin在推荐前检查portfolio中是否有 同名不同代码的持仓。有则跳过推荐。 测试:之前推H股,现在静默(0可操作→无输出)
This commit is contained in:
@@ -339,6 +339,14 @@ def main():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 加载portfolio获取持仓信息(A/H去重用)
|
||||
pf = {"holdings": []}
|
||||
try:
|
||||
with open(PORTFOLIO_PATH) as f:
|
||||
pf = json.load(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
stocks.sort(key=lambda s: (
|
||||
0 if len(str(s[1])) == 6 else 1,
|
||||
-code_data.get(s[1], {}).get("rr_ratio", 0)
|
||||
@@ -372,6 +380,19 @@ def main():
|
||||
# 空头排列或弱势震荡,不推荐
|
||||
continue
|
||||
# (如果趋势数据获取失败,放行—不因数据问题错杀)
|
||||
|
||||
# A/H跨市场去重:同一公司已有持仓,不推荐另一市场的品种
|
||||
name_s1 = code_data.get(s[1], {}).get("name", "") or s[0]
|
||||
skip_ah = False
|
||||
for h in pf.get("holdings", []):
|
||||
if h["code"] == s[1]:
|
||||
continue # 同一代码,不跳过
|
||||
if h.get("name", "") == name_s1:
|
||||
skip_ah = True
|
||||
break
|
||||
if skip_ah:
|
||||
continue # 同一公司已在另一市场持有,不推荐
|
||||
|
||||
actionable.append(s)
|
||||
|
||||
if not actionable:
|
||||
|
||||
Reference in New Issue
Block a user