'BINANCE API - Get Aggregated Book via WebSocket

I'm developing an application to read the Binance Order Book as following:

        data = dict()
        data["method"] = "SUBSCRIBE"
        data["params"] = []
        for symbol in self.ws_subscriptions:
            data["params"].append(symbol + "@depth5@100ms")
        data["id"] = self._ws_id
        self.log_event(f"Contracts to be subscribed: {data}")
        try:
            self.ws.send(json.dumps(data))
            self.log_event(f"WebSocket {data['method']} to {self.ws_channel_book} update")
        except Exception as e:
            self.log_event(f"ERROR: WebSocket error while {data['method']} {self.ws_channel_book} {e}")

It works perfectly but I have a specific need that is basically to "aggregate" the positions coming from the stream. Is there a way to request via API a specific aggregation data set?

Let me explain with two simple images: standard order book obtained via API

aggregated order book that I need

Thanks to all of you will spot the light to help me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source