Revert "feat(options): push chain asks/bids via OKX WS + SSE"

This reverts commit 14a7adae1f.
This commit is contained in:
dekun
2026-08-11 12:22:41 +08:00
parent a488e2fabd
commit d592632834
7 changed files with 7 additions and 959 deletions
-64
View File
@@ -1,64 +0,0 @@
"""options_quote_live_lib 单元测试."""
from __future__ import annotations
import json
from lib.options.options_quote_live_lib import OptionsQuoteLive
class _FakeWs:
connected = True
last_msg_at = 0.0
def start(self) -> None:
return None
def stop(self) -> None:
return None
def set_subscriptions(self, args) -> None:
self.last_args = list(args)
def test_ticker_patch_and_flush():
live = OptionsQuoteLive()
live._ws = _FakeWs() # type: ignore[assignment]
live._started = True
live.watch(
underlying="ETH",
exp_time="1",
contracts=[{"inst_id": "ETH-USD-260811-2500-C", "opt_type": "C", "strike": 2500}],
index_inst_id="ETH-USD",
)
live._on_ws_data(
{
"arg": {"channel": "tickers", "instId": "ETH-USD-260811-2500-C"},
"data": [
{
"instId": "ETH-USD-260811-2500-C",
"askPx": "12.5",
"askSz": "3",
"bidPx": "11.0",
"bidSz": "2",
"markPx": "12.0",
}
],
}
)
live._on_ws_data(
{
"arg": {"channel": "index-tickers", "instId": "ETH-USD"},
"data": [{"idxPx": "2600"}],
}
)
raw = live._build_flush_event()
assert raw is not None
payload = json.loads(raw)
assert payload["index_px"] == 2600.0
assert payload["quotes"]
q = next(x for x in payload["quotes"] if x["inst_id"] == "ETH-USD-260811-2500-C")
assert q["ask"] == 12.5
assert q["ask_sz"] == 3.0
assert q["expiry_be_px"] == 2512.5
st = live.status()
assert st["watch_count"] == 1