fix: 资金流端点再修正——ssl_qsfx_zjlrqs(最新在前), lscjfb数据停2020年是僵尸源
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user