do you have code example on how to filter orderbook events based on first update id and last update id ? Binance API Documentation i found the code on cryptofeed : cryptofeed/binance.py at master · bmoscon/cryptofeed · GitHub but that elif statement doesnt make any sense because Since msg[‘u’] will always be greater than or equal to msg[‘U’], the statement self.last_update_id[std_pair] + 1 == msg[‘U’] will never be true if elif msg[‘U’] <= self.last_update_id[std_pair] + 1 <= msg[‘u’] is not true. So, if the first elif statement is not hit, the second elif statement will also not be hit. Therefore, the second elif statement is unnecessary and can be removed.
So there are two redundancy in the code :
- No need to check both msg[U] and msg[u] <= lastupdateid[pair]
because since U <= u checking whether msg[u] <= lastupdateid[pair] is enough
- No need of third elif like I stated above.
I don’t know what author really means here, I contacted him, but he seems to ignore it