From 46f8040ebfba5bcaeeca08bcd856d3a53c7ae012 Mon Sep 17 00:00:00 2001 From: xxm Date: Mon, 24 Aug 2026 21:06:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20S4=20cache=20miss=E8=85=BE=E8=AE=AFquot?= =?UTF-8?q?e=E5=85=9C=E5=BA=95(3s=E5=BF=AB=E5=A4=B1=E8=B4=A5)=E2=80=94?= =?UTF-8?q?=E2=80=94=E6=B1=A0=E5=A4=96=E5=80=99=E9=80=89=E6=8B=BF=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=86=85=E5=A4=96=E7=9B=98=E8=AF=84=E5=88=86,?= =?UTF-8?q?=E4=B8=8D=E9=9D=A0=E4=B8=AD=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/candidate_filter.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/deploy/profile-scripts/candidate_filter.py b/deploy/profile-scripts/candidate_filter.py index 84b46b24..30cf135c 100644 --- a/deploy/profile-scripts/candidate_filter.py +++ b/deploy/profile-scripts/candidate_filter.py @@ -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日