fix(stocksdk): normalize realtime change percentage

This commit is contained in:
Marquis03
2026-08-20 10:35:52 +08:00
parent a49c67c5b5
commit 177fca7ae8
2 changed files with 15 additions and 4 deletions
+10 -1
View File
@@ -203,7 +203,16 @@ class StockSDKProvider:
except bridge.StockSDKBridgeError as e:
logger.warning("stock-sdk realtime 拉取失败: %s", e)
return []
return result.get("rows") or []
rows = result.get("rows") or []
normalized: list[dict] = []
for row in rows:
item = dict(row)
# stock-sdk 的 changePercent 是百分数值(-1.15 = -1.15%);
# provider 入口契约统一使用小数制(-0.0115 = -1.15%)。
if item.get("change_pct") is not None:
item["change_pct"] = float(item["change_pct"]) / 100
normalized.append(item)
return normalized
# ---- instruments (标的维表) ----
def get_instruments(self, asset_type: str = "stock") -> list[dict]: