Skip to content
Oliver Zehentleitner edited this page May 4, 2024 · 16 revisions

Usually you want to know when a stream is working and when it is not. This can be useful to know that your own system is currently "blind" and you may want to close open positions to be on the safe side, know that indicators will now provide incorrect values or that you have to reload the missing data via REST as an alternative.

For this purpose, the UNICORN Binance WebSocket API provides so-called STREAM SIGNALS, which are used to tell your code in real time when a stream is connected, when it received its first data record, when it was disconnected and stopped, and when the stream cannot be restarted.

Receive signals about changes in the status of your stream with the stream_signal_buffer or with an event-based callback function.

Type Info
CONNECT This signal informs about a successful connection establishment.
DISCONNECT This signal informs about a disconnect and also includes the last received data record. last_received_data_record can contain the last record or None.
FIRST_RECEIVED_DATA This signal informs about the first received data record. first_received_data_record contains the first received record.
STOP This signal informs about the stop of the stream.
STREAM_UNREPAIRABLE This signal informs you when a stream cannot be restarted, e.g. an invalid API key or an exception within your provided process_asyncio_queue-coroutine. Attention: This signal is NOT sent if there is no network connection, as soon as the Internet connection is re-established, the stream automatically reconnects. error_msg contains the full error message.