fix: fetch_fund_flow_daykline 增加 rc 校验和 data 空值保护
东方财富 daykline/get 接口返回 rc=100(data=null) 时无保护处理:
- 增加 result 类型检查、rc 状态校验、data 空值判断
- 避免 None.get('klines') 抛 AttributeError
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1074,7 +1074,20 @@ async def fetch_fund_flow_daykline(code: str, days: int) -> Optional[list[dict]]
|
|||||||
continue
|
continue
|
||||||
return None
|
return None
|
||||||
result = resp.json()
|
result = resp.json()
|
||||||
klines = result.get("data", {}).get("klines", [])
|
if not isinstance(result, dict):
|
||||||
|
if attempt == 0:
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
if result.get("rc", -1) != 0:
|
||||||
|
if attempt == 0:
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
data = result.get("data")
|
||||||
|
if not data or not isinstance(data, dict):
|
||||||
|
if attempt == 0:
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
klines = data.get("klines", [])
|
||||||
if not klines:
|
if not klines:
|
||||||
if attempt == 0:
|
if attempt == 0:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user