Closed MFelex closed 3 days ago
I tested this but there is a failure in the logic somewhere because running it for a couple of minutes brings the number of items in the bid and ask lists to zero.
from pybit.unified_trading import WebSocket
from time import sleep
ws = WebSocket(
testnet=False,
channel_type="linear",
)
def handle_message(message):
print(len(message["data"]["a"]), len(message["data"]["b"]), message)
ws.orderbook_stream(50, "BTCUSDT", handle_message)
while True:
sleep(1)
Closing to cleanup but feel free to reopen in future
Optimize algorithm to reduce complexity from O(n^2) to O(n) in _process_delta_orderbook method