Sunday, 15 May 2022

Open user socket and depth book with BinanceSocketManager

So I've been trying to get to open two sockets - one for listening to trade streams and the other for data to act upon.

Here's my code, and so far I can only have one socket (depth) opened at the same time. My question is how do I open two sockets using BinanceSocketManager? Especially bm.user_socket() as well?

async def main(client):
    bm = BinanceSocketManager(client)
    ds = bm.depth_socket(symbol, depth=BinanceSocketManager.WEBSOCKET_DEPTH_5)

    async with ds as depth_socket:
        while True:
            res = await depth_socket.recv()
            print(res)

    await client.close_connection()


from Open user socket and depth book with BinanceSocketManager

No comments:

Post a Comment