Fix Binance boot using OKX symbols after restart.

Startup ignored DB exchange choice and kept OKX ATM ids under a Binance health label, so option bid/ask stayed empty.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:13:19 +08:00
parent d701d30c04
commit 586469482e
4 changed files with 52 additions and 6 deletions
+9 -3
View File
@@ -55,19 +55,25 @@ class BinanceRestClient:
return self._exchange_info
def fetch_option_instruments(self, underlying: str) -> list[dict[str, Any]]:
"""underlying 如 ETH / ETHUSDT。"""
"""underlying 如 ETH / ETHUSDT。误传 OKX familyETH-USD_UM)时映射到 ETHUSDT。"""
info = self.fetch_option_exchange_info()
rows = info.get("optionSymbols") or info.get("symbols") or []
want = (underlying or "ETHUSDT").strip().upper()
eth_mode = want in ("ETH", "ETHUSDT") or want.startswith("ETH")
# 兼容误用 OKX 期权族名
if "USD_UM" in want or want in ("ETH-USD", "ETH-USDT", "ETHUSD"):
want = "ETHUSDT"
eth_mode = want in ("ETH", "ETHUSDT") or (
want.startswith("ETH") and "-" not in want
)
out: list[dict[str, Any]] = []
for row in rows:
if not isinstance(row, dict):
continue
u = str(row.get("underlying") or row.get("underlyingAsset") or "").upper()
sym = str(row.get("symbol") or "").upper()
# 只收币安格式 ETH-YYMMDD-STRIKE-C/P,避免脏符号进缓存
if eth_mode:
if sym.startswith("ETH-") or u.startswith("ETH"):
if sym.startswith("ETH-") and u.startswith("ETH"):
out.append(row)
continue
base = want.replace("USDT", "") if want.endswith("USDT") else want