python API/wrapper - listening to trades

Hi,

I’m hoping to listen to trades in realtime for a lot of pairs… like a lot :slight_smile:

Before I go down this route, am I going to encounter problems? Right now, I’m basing code on example from python-binance documentation.

My intention is to create listeners for each symbol and have them run in parallel. Right now I have 6 listeners setup but only see callbacks (trade data) for about 3 symbols/pairs.

  1. Is this approach wrong? Or is it simply a case that I’ve coded it wrong (I’ve put the listeners in objects and create each one identically. Only 3 receive callbacks with trade information.

  2. Am I going to hit “limits” with this approach, assuming its feasible.

async def main():

client = await AsyncClient.create()
bsm = BinanceSocketManager(client)
async with bsm.trade_socket(‘ETHBTC’) as ts:
while true
res = await ts.recv()

Appreciate any feedback. Hints.

Thanks much,

Graham

Thanks a million for your reply!

I actually switched over to cryptox lib and it worked a treat. I strongly suspect it was my use of threads in conjunction with await. In any case the cryptoxlib approach/lib shields me from all that.

Thanks much

Graham

Hi.

  1. Based on the info you provided, it might have several possible reasons, including:
    a) The liquidity of certain symbols is low, there is no transaction done at the moment you tested.
    b) Symbol name error. When subscribing the streams, according to the official document, the stream name should be written in lower case. Please check if your library convert it from upper case properly. https://binance-docs.github.io/apidocs/spot/en/#websocket-market-streams
    c) Programming error, please check how you handled the asynchronous methods. You may also want to check if you are establishing 3 connections with 1 stream subscribed or 1 connection with 3 streams subscribed. The later is recommended as it occupies fewer resources.
  2. One connection can subscribe up to 1024 streams. Please refer to the “Websocket Limits” section here: https://binance-docs.github.io/apidocs/spot/en/#limits