on “partial book depth streams” (<symbol>@depth<levels>) stream payload there is no field indicating the symbol associated with the update. how can i distinguish updates when subscribing to multiple symbols?
here is the documentation example payload:
{
"lastUpdateId": 160, // Last update ID
"bids": [ // Bids to be updated
[
"0.0024", // Price level to be updated
"10" // Quantity
]
],
"asks": [ // Asks to be updated
[
"0.0026", // Price level to be updated
"100" // Quantity
]
]
}
Depending on the ws implementation you are using, you may also be able to register a different end point for each currency and thus forward corresponding events to differents consumers. That’s how I do.
There is definitely a field missing, if you want to subscribe to multiple symbols within the same connection, there is no way to distinguish what update is for what symbol. @dino I assume it wouldn’t be complicated to simply add the “symbol” field?
@aisling It means opening a new websocket connection for each channel you subscribe to, or at least you don’t have the flexibility to subscribe/unsubscribe after the connection has been opened (most of the time when your program start you don’t know in advance what channels/symbols you will need, because it depends on what the user needs, what are his actions while the program is already running).
This lack of fields is only with the Spot API from what I see in the documentation, on the futures API side the channel has all the necessary information.
@aisling Yes the “Live Subscribing/Unsubscribing to streams” part is what I use.
I do set the “id”, but the “id” isn’t returned in the websocket messages that we receive (for any channel, not just the depth one).
{
"lastUpdateId": 160, // Last update ID
"bids": [ // Bids to be updated
[
"0.0024", // Price level to be updated
"10" // Quantity
]
],
"asks": [ // Asks to be updated
[
"0.0026", // Price level to be updated
"100" // Quantity
]
]
}
@aisling I’m coding things from scratch, not using this library, I see the callback argument in binance-connector is simply creating a new connection for every channel (not the “Live Subscribing” case then).
I will use the Diff. Depth Stream endpoint instead, it has the “s” (symbol) field.
Thanks again for taking the time to answer.
I totally agree this is a major drawback of the SPOT Partial Book Depth Streams!
Come on guys, it’s 2024, could you please add the symbol field inside this stream?
This is a really important feature to be added!