Since each websocket is for a single symbol, I'd like to open a trades websocket for each symbol. But that's over 100 websockets, and I'm not sure if that's possible. That information would be a good addition to the documentation.
I have about ~300 running in the program i'm working on right now no problem, and one of my testers runs 3 instances at the same time so thats ~900 sockets on 1 machine
You can run a single socket for multiple symbols:
socket_manager.start_multiplex_socket(['btcusdt@aggTrade','ethbtc@aggTrade','!miniTicker@arr@3000ms'], handler)
Is the multiplex socket actually any more efficient than separate sockets? I thought it was just an easier way of managing multiple sockets but I know roughly nothing about how websockets actually work
It opens a single connection, so yes.
In my experience, the number of file descriptors is the limiting factor. No issues opening a websocket for each symbol.
my experience is, you can start as much websockets as you like. only with userdata streams you have to keep in mind, that they cause a weight cost of 1 each time they do a "keepalive" (~30min). so the more userdata streams you have that do independen keepalive tasks you accumulate weight costs.
i had up to 10 machines with up to 20 active webstreams (with multiplex webstreams for 100s of trading_pairs) from one IP and had no issues. the only thing i found, you have to care is how much webstreams are used through one websocket. There i found a max lenght for the URI of 8004 signs.
Update: I'm subscribing to 555 pairs successfully with no issues. Haven't hit a limit yet.
I subscribed at 250 pairs but receive just for 3-4... There are no exceptions
Reached 1400 here: https://colonist.io/
Seems to be affected heavily by cpu, memory, bandwidth. When one of those resources aren't enough, I start getting disconnections.
hi
i have problem in websocket :
indexingerror-unalignable-boolean-series-provided-as-indexer-index-of-the-bool
after priod time while:
while():
df = price['BTCUSDT']
mask=df.date >= start_time #type(mask)=series
df2 =df.loc[mask] #?????
after 10 or 50 period is good but after n minute:
df.index> mask.index then mask do not operate over df . (df.index +1=mask.index)
i do not know why????
god willing
Most helpful comment
my experience is, you can start as much websockets as you like. only with userdata streams you have to keep in mind, that they cause a weight cost of 1 each time they do a "keepalive" (~30min). so the more userdata streams you have that do independen keepalive tasks you accumulate weight costs.
i had up to 10 machines with up to 20 active webstreams (with multiplex webstreams for 100s of trading_pairs) from one IP and had no issues. the only thing i found, you have to care is how much webstreams are used through one websocket. There i found a max lenght for the URI of 8004 signs.