持仓排名数据清洗,机构名称为空时用名次兜底

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 23:16:42 +08:00
parent 223001d8a2
commit ac4236b03f
2 changed files with 6 additions and 2 deletions
+6 -2
View File
@@ -293,10 +293,14 @@ def fetch_position_rankings(contract_code: str, trade_date: str) -> list[dict]:
for _, row in df.iterrows():
try:
inst = str(row["会员简称"]).strip()
rank = int(row["名次"])
if inst in ("-", ""):
inst = f"-{rank}"
results.append({
"data_type": dtype,
"rank": int(row["名次"]),
"institution": str(row["会员简称"]),
"rank": rank,
"institution": inst,
"value": int(row.iloc[2]),
"change": int(row["比上交易增减"]),
})