修复 WS 订阅格式:type=subscribe channel=market 对齐官方文档
This commit is contained in:
@@ -262,14 +262,11 @@ class PolymarketWsQuoteCache:
|
||||
batch = [asset_id for asset_id in asset_ids if asset_id]
|
||||
if not batch:
|
||||
return
|
||||
payload = {
|
||||
payload: Dict[str, Any] = {
|
||||
"type": "subscribe",
|
||||
"channel": "market",
|
||||
"assets_ids": batch,
|
||||
"custom_feature_enabled": True,
|
||||
}
|
||||
if initial:
|
||||
payload["type"] = "market"
|
||||
else:
|
||||
payload["operation"] = "subscribe"
|
||||
await ws.send(json.dumps(payload))
|
||||
|
||||
def _handle_message(self, raw: Any) -> None:
|
||||
|
||||
@@ -113,12 +113,12 @@ def test_ws_cache_subscription_payloads_match_market_channel_shape():
|
||||
asyncio.run(cache._send_subscription(ws, ["asset-2"], initial=False))
|
||||
|
||||
assert ws.messages[0] == {
|
||||
"type": "market",
|
||||
"type": "subscribe",
|
||||
"channel": "market",
|
||||
"assets_ids": ["asset-1"],
|
||||
"custom_feature_enabled": True,
|
||||
}
|
||||
assert ws.messages[1] == {
|
||||
"operation": "subscribe",
|
||||
"type": "subscribe",
|
||||
"channel": "market",
|
||||
"assets_ids": ["asset-2"],
|
||||
"custom_feature_enabled": True,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user