nkaz001 / collect-binancefutures

Collect BinanceFutures's trade and orderbook(depth) feeds.
91 stars 27 forks source link

Unable to convert data, KeyError: 'T' #9

Closed 312707047 closed 1 week ago

312707047 commented 2 weeks ago

image

It seems that Binance change the format of their stream data?

image from the above picture you can tell that the data from last year still got E and T as the key, but now it doesn't Did I do something wrong or it just doesn't work anymore?

nkaz001 commented 2 weeks ago

T still exists in the target streams. I think the message may not be for the trade or diff book stream. Could you check the raw message where the error occurs?

312707047 commented 2 weeks ago

image

The error happened at row 183. It is dealing with the first data stream without data as a dictionary key.

image

And I checked the data. It seems that the lastUpdateId doesn't have T inside

nkaz001 commented 2 weeks ago

Could you post the full message of the specific row? I checked the Binance API documentation, and nothing seems to have changed. It may be a temporary problem on Binance's side, but I'm unsure. Meanwhile, I think you can skip that message and rely on the natural refresh.

312707047 commented 2 weeks ago

I’ve checked the data I fetched recently. I found that every other event except trade has no T inside. And I also checked the Binance API documentation, and everything seems no problem there. I will try to figure it out in the future.

nkaz001 commented 2 weeks ago

I think you may be connecting to the spot stream. In the spot stream, there is no T field in the diff depth stream. Therefore, it is inaccurate to use it, but, you have to use the E field instead. However, note that the E field represents the timestamp when the exchange sent the feed, not when the exchange actually accepted the order. Please refer to the documentation for more details. https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams#diff-depth-stream

312707047 commented 1 week ago

This solve the problem, thanks!