Closed xilopaint closed 3 years ago
stream_label
is the name/label you choose for the stream and can be used with get_stream_id_by_label()
and is shown in print_summary()
which helps you to identify it in the view and should be unique (one stream, one label)
stream_buffer_name
is the name of the buffer you want to use. you can use one buffer for all streams or just one buffer for one stream. for example you can create 2 streams to stream all trades. Since there are more than 1024 trading pairs, not all subscriptions fit into one stream, so you have to create 2 streams:
stream_label="trades_1" and stream_label="trades_2" but both use stream_buffer_name="trades"
Since there are more than 1024 trading pairs, not all subscriptions fit into one stream
Thanks for the explanation. How many subscriptions fit into one stream?
that depends on the exchange endpoint, i made an overview here: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/Binance-websocket-endpoint-configuration-overview
you can use one buffer for all streams or just one buffer for one stream.
Do I have better performance using just one buffer per stream or one buffer for all streams?
Splitting them uses a little bit more RAM but i think it saves operation times and avoids threading locks. Only one stream at a time can write to the buffer - the more buffers the less locks...
Splitting them uses a little bit more RAM but i think it saves operation times and avoids threading locks. Only one stream at a time can write to the buffer - the more buffers the less locks...
So is it generally preferable to split them?
I think yes! But never tested this out. https://medium.com/python-features/using-locks-to-prevent-data-races-in-threads-in-python-b03dfcfbadd6
One more question. stream_buffer_name
can be bool
or str
. If it's set to False
data is written to the default stream_buffer
and if it's set to True
data can be read via pop_stream_data_from_stream_buffer(stream_id)
. In the latter case do we have a separate stream_buffer
without a name since we are not setting a str
to stream_buffer_name
?
yes
What happens if I unsubscribe from all channels and markets in a stream? An exception is returned or the library handle this situation? Can a stream object live without subscriptions?
then its a stream (established websocket connection) without subscriptions...
i suggest you try a few of the example files i prepared and play a little bit with the code... try and error. I think the initial question is answered i close this!
Could anyone explain me the difference between
stream_buffer_name
andstream_label
parameters inbinance_websocket_api_manager.create_stream()
?What's the point of having both parameters instead of only one of them?