From a3f5ad5b3a7d08889a752c7d2d5b1a94980926ba Mon Sep 17 00:00:00 2001 From: hmo Date: Wed, 22 Jul 2026 12:36:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=84=E9=87=91=E6=B5=81=E7=AB=AF?= =?UTF-8?q?=E7=82=B9=E5=86=8D=E4=BF=AE=E6=AD=A3=E2=80=94=E2=80=94ssl=5Fqsf?= =?UTF-8?q?x=5Fzjlrqs(=E6=9C=80=E6=96=B0=E5=9C=A8=E5=89=8D),=20lscjfb?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=81=9C2020=E5=B9=B4=E6=98=AF=E5=83=B5?= =?UTF-8?q?=E5=B0=B8=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile-scripts/capital_flow_collector.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/deploy/profile-scripts/capital_flow_collector.py b/deploy/profile-scripts/capital_flow_collector.py index 86997cb3..355f20b6 100644 --- a/deploy/profile-scripts/capital_flow_collector.py +++ b/deploy/profile-scripts/capital_flow_collector.py @@ -47,27 +47,27 @@ def secid(code): return f"0.{code}" def fetch_flow(code, days=5): - """拉取个股近N日资金流(Sina MoneyFlow — eastmoney 在 246 不可达 2026-07-22)""" + """拉取个股近N日资金流(Sina MoneyFlow ssl_qsfx_zjlrqs,最新在前 — + eastmoney 在 246 不可达、ssl_qsfx_lscjfb 数据停在2020年(2026-07-22 实证)""" code = str(code).strip() if code.startswith(("6", "9")): dm = f"sh{code}" - elif code.startswith(("0", "1")) and len(code) == 5: - dm = f"hk{code}" # 港股 sina 不支持资金流,直接返回 None - return None + elif len(code) == 5 and code[0] in "01": + return None # 港股 sina 不支持资金流 else: dm = f"sz{code}" url = ("https://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/" - f"MoneyFlow.ssl_qsfx_lscjfb?daima={dm}") + f"MoneyFlow.ssl_qsfx_zjlrqs?daima={dm}") data = _rate_limited_request(url, referer="https://finance.sina.com.cn") if not data or not isinstance(data, list) or not data: return None result = [] - for d in data[-days:]: + for d in data[:days]: # 最新在前,取近N日 try: - r0n = float(d.get("r0_net", 0) or 0) # 超大单净流入(元) - r1n = float(d.get("r1_net", 0) or 0) # 大单净流入(元) - r2n = float(d.get("r2_net", 0) or 0) # 中单净流入(元) - r3n = float(d.get("r3_net", 0) or 0) # 小单净流入(元) + r0n = float(d.get("r0_net", 0) or 0) + r1n = float(d.get("r1_net", 0) or 0) + r2n = float(d.get("r2_net", 0) or 0) + r3n = float(d.get("r3_net", 0) or 0) result.append({ "date": d.get("opendate", ""), "main_net": r0n + r1n, @@ -78,6 +78,7 @@ def fetch_flow(code, days=5): }) except Exception: continue + result.reverse() # 转为时间升序(analyze_flow 以 [-1] 为最新日) return result or None def fetch_flow_intraday(code):