feat: S4 cache miss腾讯quote兜底(3s快失败)——池外候选拿真实内外盘评分,不靠中性

This commit is contained in:
xxm
2026-08-24 21:06:13 +08:00
parent ef835c1241
commit 46f8040ebf
+15 -1
View File
@@ -193,7 +193,21 @@ def stage4_capital_flow(code, name):
stocks = (_j.loads(r[0]) or {}).get("stocks") or {}
info = stocks.get(raw)
if not info or not info.get("flow"):
# 2026-08-24 中性化:cache只覆盖池内股票,池外候选无数据不该压分(S4设计是筛资金差,不是筛没数据)
# 2026-08-24 cache miss→腾讯quote兜底(3s快失败):池外候选拿真实内外盘,不靠中性
try:
prefix = "sh" if raw.startswith(("6", "9")) else "sz"
import subprocess as _sp
url = f"http://qt.gtimg.cn/q={prefix}{raw}"
r2 = _sp.run(["curl", "-s", url], capture_output=True, timeout=3)
parts = r2.stdout.decode("gbk", errors="ignore").split("~")
if len(parts) > 8 and parts[7] and parts[8]:
outer, inner = int(float(parts[7])), int(float(parts[8]))
if outer > 0 and inner > 0:
ratio = outer / inner
score = 2 if ratio > 1.3 else (1 if ratio > 1.0 else 0)
return score >= 1, score, f"外/内={ratio:.2f}(腾讯兜底)"
except Exception:
pass
return True, 1, "无资金流数据(中性)"
flow = info["flow"] # [{date, main_net, super_large, ...}] 日期升序
recent = flow[-3:] # 近3日