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
+32
View File
@@ -57,3 +57,35 @@ def test_normalize_exchange() -> None:
assert normalize_exchange_name("BN") == "binance"
assert normalize_exchange_name("okx") == "okx"
assert normalize_exchange_name(None) == "okx"
def test_binance_maps_okx_family_name() -> None:
"""误传 OKX family 时不应按 startswith(ETH) 乱匹配,应映射到 ETHUSDT。"""
from app.exchange.binance.rest import BinanceRestClient
cli = BinanceRestClient.__new__(BinanceRestClient)
cli._exchange_info = {
"optionSymbols": [
{
"symbol": "ETH-260726-1860-C",
"underlying": "ETHUSDT",
"status": "TRADING",
"strikePrice": "1860",
"side": "CALL",
"expiryDate": 1785052800000,
"unit": "1",
},
{
"symbol": "BTC-260726-100000-C",
"underlying": "BTCUSDT",
"status": "TRADING",
"strikePrice": "100000",
"side": "CALL",
"expiryDate": 1785052800000,
"unit": "1",
},
]
}
rows = BinanceRestClient.fetch_option_instruments(cli, "ETH-USD_UM")
assert len(rows) == 1
assert rows[0]["symbol"] == "ETH-260726-1860-C"