bithumb-pro / bithumb.pro-official-api-docs

rest and websocket api doc
22 stars 26 forks source link

Fatal bug in websokcet order book #29

Open sniperem opened 4 years ago

sniperem commented 4 years ago

When I subscribe order book of BTC-USDT, the replies are as follow (timestamp is added by me):

2020/02/07 21:34:21 {"b":[["9756.8000000000","0.044985"],["9756.6000000000","0.024648"],["9756.3000000000","0.183138"],["9756.1000000000","0.273944"],["9755.8000000000","0.095392"],["9755.6000000000","0.426989"],["9755.3000000000","1.573724"],["9755.1000000000","1.294173"],["9754.6000000000","1.415908"],["9754.1000000000","2.493374"],["9754.0000000000","1.726758"],["9753.6000000000","2.472730"],["9753.5000000000","0.302039"],["9753.0000000000","2.528049"],["9752.9000000000","2.177003"],["9752.8000000000","3.490732"],["9752.4000000000","0.568442"],["9751.9000000000","1.456111"],["9751.4000000000","2.123245"],["9751.3000000000","0.349701"],["9750.8000000000","0.695952"],["9750.3000000000","0.312237"],["9749.8000000000","1.050580"],["9749.3000000000","1.596748"],["9749.1000000000","0.839609"],["9748.6000000000","0.074933"],["9748.1000000000","3.783306"],["9747.8000000000","1.352731"],["9747.6000000000","1.265206"],["9747.1000000000","0.185928"],["9746.9000000000","4.125762"],["9746.4000000000","3.893274"],["9745.9000000000","1.493246"],["9745.8000000000","0.221488"],["9745.3000000000","0.527085"],["9744.8000000000","1.043764"],["9744.3000000000","0.157803"],["9743.8000000000","1.538415"],["9743.4000000000","3.819557"],["9743.0000000000","0.427683"],["9742.5000000000","0.869369"],["9742.0000000000","0.371933"],["9741.5000000000","0.735088"],["9741.2000000000","0.199711"],["9740.7000000000","0.040051"],["9740.2000000000","3.596536"],["9740.0000000000","1.970845"],["9739.8000000000","1.470153"],["9739.3000000000","2.597309"],["9739.0000000000","0.707326"],["9738.5000000000","3.613645"],["9738.0000000000","3.839603"],["9737.5000000000","1.641251"],["9737.0000000000","0.261855"],["9736.5000000000","3.247438"],["9736.0000000000","2.360485"],["9735.5000000000","2.588038"],["9735.0000000000","3.953340"],["9734.5000000000","3.077822"],["9734.0000000000","2.206718"],["9733.5000000000","1.952227"],["9733.0000000000","2.601668"],["9732.5000000000","0.195102"],["9732.0000000000","2.194092"],["9731.5000000000","2.328750"],["9731.0000000000","0.623820"],["9730.5000000000","1.697736"],["9730.0000000000","0.649295"],["9729.5000000000","1.218902"],["9729.0000000000","1.576767"],["9728.5000000000","3.948226"],["9728.0000000000","1.675433"],["9727.5000000000","0.974341"],["9727.0000000000","1.484802"],["9726.5000000000","1.300644"],["9726.0000000000","0.659600"],["9725.5000000000","2.071650"],["9725.0000000000","3.990878"],["9724.5000000000","2.549374"],["9724.0000000000","0.716908"],["9723.5000000000","1.710044"],["9723.0000000000","1.457009"],["9722.5000000000","1.520962"],["9722.0000000000","1.050154"],["9721.5000000000","1.560686"],["9721.0000000000","3.689661"],["9720.5000000000","1.689908"],["9720.0000000000","3.828225"],["9719.5000000000","0.775683"],["9719.0000000000","1.684986"],["9718.5000000000","2.951847"],["9718.0000000000","3.445410"],["9717.5000000000","3.427180"],["9717.0000000000","1.750621"],["9716.5000000000","3.889291"],["9716.0000000000","1.887968"],["9715.5000000000","1.403417"],["9715.0000000000","2.963989"],["9714.5000000000","3.446412"],["9714.0000000000","3.948747"],["9713.5000000000","2.336027"],["9713.0000000000","3.961071"],["9712.5000000000","3.614921"],["9712.0000000000","3.065792"],["9700.0000000000","0.004318"],["9260.5000000000","0.009949"],["9101.0000000000","0.004284"],["9100.0000000000","0.479694"],["9000.4000000000","0.015225"],["9000.0000000000","0.012649"],["8916.0000000000","0.010000"],["8275.6000000000","0.052903"],["7313.6000000000","0.163999"],["6900.0000000000","0.001766"],["6848.6000000000","0.001005"],["6300.0000000000","0.001000"],["0.5000000000","6.100000"],["0.3000000000","8.002546"]],"s":[["9776.1000000000","0.363719"],["9776.5000000000","0.138898"],["9777.0000000000","0.673355"],["9777.5000000000","0.262488"],["9778.0000000000","3.848415"],["9778.2000000000","0.929015"],["9778.7000000000","2.013407"],["9778.9000000000","1.708508"],["9779.0000000000","2.836898"],["9779.4000000000","2.063151"],["9779.6000000000","1.111037"],["9780.1000000000","1.222929"],["9780.6000000000","1.488307"],["9780.9000000000","0.354354"],["9781.0000000000","0.640297"],["9781.5000000000","0.546532"],["9782.0000000000","0.294301"],["9782.5000000000","0.929948"],["9783.0000000000","0.942084"],["9783.2000000000","1.578294"],["9783.7000000000","0.198240"],["9784.0000000000","3.014889"],["9784.4000000000","1.863739"],["9784.7000000000","0.221194"],["9785.1000000000","0.417373"],["9785.6000000000","0.524963"],["9786.1000000000","0.520311"],["9786.6000000000","1.643978"],["9786.7000000000","0.309808"],["9787.0000000000","0.125686"],["9787.1000000000","3.262975"],["9787.2000000000","3.472682"],["9787.4000000000","3.293128"],["9787.8000000000","0.382934"],["9788.2000000000","3.027139"],["9788.6000000000","0.481127"],["9789.0000000000","0.163797"],["9789.4000000000","0.076614"],["9789.9000000000","0.675894"],["9790.4000000000","1.399930"],["9790.9000000000","2.169701"],["9791.1000000000","1.087185"],["9791.6000000000","0.554955"],["9792.1000000000","0.443663"],["9792.4000000000","0.555262"],["9792.8000000000","2.561557"],["9793.2000000000","0.441783"],["9793.6000000000","2.866973"],["9794.0000000000","3.807108"],["9794.4000000000","0.387822"],["9794.7000000000","0.283400"],["9795.1000000000","0.068175"],["9795.6000000000","1.060241"],["9796.1000000000","1.088121"],["9796.6000000000","0.841712"],["9796.7000000000","1.491941"],["9796.8000000000","3.643197"],["9797.2000000000","2.027201"],["9797.5000000000","0.355906"],["9797.9000000000","0.187587"],["9798.4000000000","0.651190"],["9798.9000000000","0.763494"],["9799.4000000000","2.143298"],["9799.7000000000","3.535269"],["9800.1000000000","0.873668"],["9800.6000000000","3.163761"],["9800.8000000000","2.191637"],["9801.2000000000","2.962501"],["9801.6000000000","0.875705"],["9802.0000000000","3.800427"],["9802.4000000000","2.548473"],["9802.8000000000","1.215785"],["9803.2000000000","2.148460"],["9803.6000000000","3.973448"],["9804.0000000000","3.309424"],["9804.4000000000","3.596141"],["9804.8000000000","1.492962"],["9805.2000000000","2.235736"],["9805.6000000000","1.821064"],["9806.0000000000","3.015085"],["9806.4000000000","3.937777"],["9806.8000000000","0.979218"],["9807.2000000000","2.651672"],["9807.6000000000","2.941514"],["9808.0000000000","2.457488"],["9808.4000000000","3.610899"],["9808.8000000000","2.666185"],["9809.2000000000","1.140798"],["9809.6000000000","2.730945"],["9810.0000000000","2.818856"],["9810.4000000000","1.938465"],["9810.8000000000","1.166761"],["9811.2000000000","2.782454"],["9811.6000000000","3.442737"],["9812.0000000000","2.868558"],["9812.4000000000","2.390495"],["9812.8000000000","0.339684"],["9813.2000000000","1.332205"],["9813.6000000000","0.774454"],["9814.0000000000","1.672414"],["9814.4000000000","0.590833"],["9829.0000000000","0.001434"],["9999.9000000000","0.021839"],["10009.9000000000","0.032759"],["10099.9000000000","0.016380"],["10540.0000000000","0.041208"],["10550.0000000000","0.000540"],["10999.9000000000","0.016380"],["11000.0000000000","0.004864"],["12000.0000000000","0.001898"],["12050.0000000000","0.007000"],["13000.0000000000","0.000597"],["95239999.3000000000","0.000918"]],"symbol":"BTC-USDT","ver":"60688084"}
2020/02/07 21:34:21 {"b":[["9755.6000000000","0.000000"]],"s":[],"symbol":"BTC-USDT","ver":"60688087"}
2020/02/07 21:34:21 {"b":[["9755.1000000000","0.000000"]],"s":[],"symbol":"BTC-USDT","ver":"60688088"}

2020/02/07 21:34:21 {"b":[],"s":[["9776.3000000000","0.104585"]],"symbol":"BTC-USDT","ver":"60688089"}
2020/02/07 21:34:22 {"b":[["9754.8000000000","1.137549"]],"s":[],"symbol":"BTC-USDT","ver":"60688090"}
2020/02/07 21:34:22 {"b":[],"s":[["9776.7000000000","0.144661"]],"symbol":"BTC-USDT","ver":"60688091"}
2020/02/07 21:34:23 {"b":[["9712.0000000000","0.000000"]],"s":[],"symbol":"BTC-USDT","ver":"60688092"}
2020/02/07 21:34:23 {"b":[],"s":[["9777.2000000000","0.458727"]],"symbol":"BTC-USDT","ver":"60688093"}
2020/02/07 21:34:23 {"b":[],"s":[["9777.7000000000","0.534788"]],"symbol":"BTC-USDT","ver":"60688094"}
2020/02/07 21:34:23 {"b":[],"s":[["9776.1000000000","0.000000"]],"symbol":"BTC-USDT","ver":"60688095"}

The problem is some updates are missing!! The snapshot is Ver 60688084, but the first update is Ver 60688087. You can reproduce this easily in a slow network connection(for example, 3G). you guys didn't handle the timing correctly.

godlikers commented 4 years ago

thank for your issue, this situation happened, because the first of order book is full message which be get with async, as your says, the network is slow. so we just the client should use rest api for get full order book, our clients(web, app, sdk) has handle this situation. thank you again, we will upgrade the doc for this.

sniperem commented 4 years ago

I don't think you should blame this on the slow connection, even a fast connection may delay and jitter, the key is timing and sequence.

sniperem commented 4 years ago

And you know what, even I subscribe order book updates first, then get a full orderbook, sometimes there is also a gap between them

godlikers commented 4 years ago

yeah, maybe, the full message which get from other server, if sync by force, not a good idea, so we suggest clients should do some handles by 'ver', if increment's 'ver' not the next of full's ver, then should resubscribe. most situation, the increment's ver is greater than the full's ver, thank you for your response.

sniperem commented 4 years ago

This exchange is running for nearly a year, but can't provide this fundamental data correctly! No wonder I saw price of ask 1 is less than bid 1 on App frequently. I've developed binance/gate/kucoin/bitmax/bitmex/etc API clients, none of them has such an issue even I slow down the network speed on purpose

godlikers commented 4 years ago

thank you for your issue,we will fix it.

sniperem commented 4 years ago

Hope you guys fix it ASAP, it really hurts as I must call REST API to verify the order book.

BaalMarduk commented 3 years ago

We also have this problem.. any fix is planned soon?

davidemond1978 commented 3 years ago

Is it possible to update your example code and make sure that the order book is stable and functional:

https://github.com/bithumb-pro/java-api-client/blob/master/src/test/java/cn/bithumb/pro/api/example/BuildOrderBook.java

Like this, it will be easier to review our code from your example.