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

rest and websocket api doc
22 stars 26 forks source link

websocket order book is a mess #30

Open sniperem opened 4 years ago

sniperem commented 4 years ago

When I subscribe order book of BXA-USDT, I requested a full order book via REST API first, then subscribe websocket updates, below is what I got:

2020/02/19 20:34:07 [DEBUG] REST order book ver: 10579730
2020/02/19 20:34:07 {"code":"00006","data":{"b":[["0.0020010000","51001.000000"],["0.0020000000","10908.440000"],["0.0019990000","8185.420000"],["0.0019530000","51001.000000"],["0.0019500000","12586.660000"],["0.0019000000","49429.890000"],["0.0018880000","281450.000000"],["0.0018080000","100275.290000"],["0.0016380000","120912.360000"],["0.0014420000","823.170000"],["0.0013310000","1344.950000"],["0.0012200000","2781.970000"],["0.0011090000","2656.420000"],["0.0009980000","6195.610000"],["0.0009950000","9529.920000"],["0.0009930000","6480.900000"],["0.0009920000","8487.470000"],["0.0009880000","5562.680000"],["0.0009870000","8401.550000"],["0.0009850000","6734.250000"],["0.0009820000","8911.970000"],["0.0009810000","5510.400000"],["0.0009770000","9048.050000"],["0.0009760000","8753.820000"],["0.0009740000","6081.790000"],["0.0009720000","8584.420000"],["0.0009690000","9971.650000"],["0.0009670000","7868.640000"],["0.0009640000","5453.350000"],["0.0003700000","2000.000000"],["0.0000070000","495333.000000"],["0.0000040000","700000.000000"]],"s":[["0.0023960000","8204.610000"],["0.0023970000","11518.690000"],["0.0023980000","15358.260000"],["0.0024250000","17278.040000"],["0.0024290000","607.050000"],["0.0024330000","9988.940000"],["0.0026380000","1872.930000"],["0.0028240000","86422.240000"],["0.0028670000","19615.910000"],["0.0029330000","202879.120000"],["0.0030000000","10524.450000"],["0.0032180000","215.560000"],["0.0032400000","335.720000"],["0.0032620000","500.900000"],["0.0032840000","670.100000"],["0.0033060000","1781.200000"],["0.0033210000","669.200000"],["0.0033430000","582.030000"],["0.0033620000","14711.940000"],["0.0033660000","1658.280000"],["0.0033810000","1529.550000"],["0.0034000000","1123.070000"],["0.0034190000","1222.890000"],["0.0034390000","1404.750000"],["0.0034590000","2255.290000"],["0.0034790000","1633.800000"],["0.0034990000","1412.530000"],["0.0035190000","2154.610000"],["0.0035390000","1633.610000"],["0.0035590000","1836.030000"],["0.0035790000","2035.770000"],["0.0035990000","1886.210000"],["0.0036190000","2101.640000"],["0.0036390000","1407.920000"],["0.0036590000","1984.510000"],["0.0036790000","1152.710000"],["0.0036990000","1153.280000"],["0.0037190000","1753.160000"],["0.0037390000","2496.150000"],["0.0037590000","2405.020000"],["0.0037790000","1262.780000"],["0.0038000000","69597.650000"],["0.0038210000","1840.600000"],["0.0038420000","1849.550000"],["0.0038630000","1002.000000"],["0.0038750000","22067.910000"],["0.0038840000","1997.960000"],["0.0039000000","87289.780000"],["0.0039050000","1536.950000"],["0.0039260000","1227.580000"],["0.0039470000","2021.510000"],["0.0039680000","1265.050000"],["0.0039900000","2145.890000"],["0.0040120000","2077.080000"],["0.0043210000","22067.910000"],["0.0043520000","1014.300000"],["0.0045000000","250135.320000"],["0.0046000000","4405.660000"],["0.0060000000","1229.600000"],["0.0060500000","16918.220000"],["0.0061200000","16918.220000"],["0.0063520000","1521.460000"],["0.0065000000","5000.000000"],["0.0070000000","5000.000000"],["0.0080000000","5000.000000"],["0.0091000000","5000.000000"],["0.0100000000","266131.250000"],["0.0150000000","2015.680000"],["0.0160000000","490.530000"],["0.8219000000","27.549356"],["0.8990000000","472333.650000"],["0.9000000000","1019.010000"],["8.2190000000","30.000000"],["82.1900000000","30.000000"],["821.9000000000","30.900000"],["8219.0000000000","30.910000"]],"symbol":"BXA-USDT","ver":"10579730"},"timestamp":1582115646936,"topic":"ORDERBOOK"}
2020/02/19 20:34:07 {"code":"00007","data":{"b":[["0.0017110000","0.000000"]],"s":[],"symbol":"BXA-USDT","ver":"10537369"},"topic":"ORDERBOOK","timestamp":1582115647068}
2020/02/19 20:34:07 {"code":"00007","data":{"b":[["0.0017110000","51001.000000"]],"s":[],"symbol":"BXA-USDT","ver":"10537370"},"topic":"ORDERBOOK","timestamp":1582115647100}

REST API's ver is 10579730, so is websocket code 00006 data, but the first increment update's ver is 10537370!! Because this issue, my order book is totally wrong, and I lost 5 ETH!

sniperem commented 4 years ago

I can't believe this exchange is already running nearly for a year!

sniperem commented 4 years ago

Sometimes I reported a bug to binance, binance gave me a BNB. If this exchange do the same thing, I would be rich soon.

sniperem commented 4 years ago

ETH-USDT's result:

2020/02/19 20:19:13.718286 [DEBUG] REST ETHUSDT ver: 56925314
2020/02/19 20:19:13.962418 {"code":"00006","data":{"b":[["279.7400000000","1.944298"],["279.4600000000","2.398526"],["279.1800000000","0.349165"],["278.9000000000","9.592996"],["278.6200000000","4.141077"],["278.5500000000","20.689764"],["278.2900000000","3.708735"],["278.2800000000","1.584997"],["278.0000000000","17.762064"],["277.9900000000","0.501872"],["277.8900000000","0.767359"],["277.7600000000","19.675695"],["277.5400000000","22.450601"],["277.2900000000","13.896098"],["277.1400000000","5.279587"],["276.8600000000","18.144336"],["276.7800000000","49.888628"],["276.4900000000","10.963026"],["276.2000000000","0.667442"],["275.9100000000","23.031486"],["275.6200000000","1.635451"],["275.3300000000","23.965774"],["275.0400000000","7.528572"],["274.7500000000","19.603392"],["274.4600000000","16.728754"],["274.1700000000","16.006898"],["273.8800000000","2.994317"],["273.5900000000","22.982964"],["273.3000000000","8.761791"],["273.0100000000","24.090814"],["272.7200000000","22.442985"],["272.4300000000","15.432386"],["272.1400000000","24.605277"],["271.8500000000","12.009638"],["271.5600000000","29.678280"],["271.2700000000","27.754192"],["270.9800000000","24.477003"],["270.7000000000","22.727104"],["270.4200000000","28.291603"],["270.1400000000","27.130909"],["270.0000000000","1.903105"],["266.1600000000","0.317014"],["266.1400000000","0.211316"],["265.4300000000","0.180932"],["264.5700000000","0.245020"],["264.4200000000","0.121843"],["264.3100000000","0.181234"],["261.2700000000","0.248115"],["260.5800000000","0.186334"],["238.1600000000","0.061274"],["217.6900000000","0.012048"],["202.3100000000","1.000000"],["199.1000000000","0.047102"],["178.7700000000","1.000000"],["162.6800000000","1.000000"],["140.1300000000","1.000000"],["140.0000000000","0.003040"],["130.8800000000","1.000000"],["126.5000000000","0.291029"],["80.0000000000","0.010000"],["0.0500000000","999.999906"],["0.0400000000","100.000000"]],"s":[["279.8900000000","1.710540"],["280.1600000000","2.897062"],["280.4400000000","8.408671"],["280.7200000000","5.090458"],["281.0000000000","5.511954"],["281.0200000000","2.226430"],["281.1400000000","29.340124"],["281.1900000000","24.752435"],["281.2000000000","23.726921"],["281.2200000000","1.176720"],["281.2300000000","17.515405"],["281.3200000000","3.445459"],["281.4100000000","18.201384"],["281.5100000000","14.747807"],["281.5800000000","27.778345"],["281.6400000000","17.126955"],["281.6600000000","10.413284"],["281.7200000000","23.866266"],["281.7300000000","12.010347"],["281.8600000000","26.711761"],["281.9100000000","8.925161"],["282.1900000000","5.604440"],["282.3500000000","1.524684"],["282.5400000000","22.612226"],["282.6600000000","29.337393"],["282.9300000000","2.846472"],["283.2000000000","24.424579"],["283.4700000000","29.613840"],["283.7400000000","13.096012"],["284.0100000000","27.204922"],["284.2800000000","2.144675"],["284.5500000000","5.928419"],["284.8200000000","10.213263"],["285.0000000000","6.391095"],["285.0900000000","16.609141"],["285.3600000000","26.612573"],["285.6300000000","28.964454"],["285.9000000000","0.593987"],["286.0000000000","1.608226"],["286.1700000000","10.752574"],["286.4400000000","6.608890"],["286.7100000000","18.377579"],["289.0000000000","0.035100"],["300.0000000000","3.654736"],["300.8200000000","0.278497"],["687.5900000000","0.100000"],["1879.1500000000","0.010000"],["6870.5900000000","0.100000"],["18799.1500000000","0.010000"],["187999.1500000000","0.010000"],["1879999.1500000000","0.010000"],["18799999.1500000000","0.010000"]],"symbol":"ETH-USDT","ver":"56925314"},"timestamp":1582114753938,"topic":"ORDERBOOK"}
2020/02/19 20:19:14.056740 {"code":"00007","data":{"b":[],"s":[["279.9800000000","0.000000"]],"symbol":"ETH-USDT","ver":"56823842"},"topic":"ORDERBOOK","timestamp":1582114754032}
2020/02/19 20:19:14.060794 {"code":"00007","data":{"b":[["277.7900000000","29.396886"]],"s":[],"symbol":"ETH-USDT","ver":"56823843"},"topic":"ORDERBOOK","timestamp":1582114754036}
sniperem commented 4 years ago

I really don't know which ver I should trust...

godlikers commented 4 years ago

i am sorry about that. we check it and there is a delay at one server point. we fix it, and add some monitor for this. about 'ver', currently, client should do some work, first: client connect to webscoket server and subscribe the symbol of orderbook, then build a temp cache for updater's, second: client request rest api for full orderbook(this 'ver' should find in temp cache). third: according to the 'ver'(by compare full's ver with updater's ver) merge the full orderbook and temp cache for final complete orderbook.

sniperem commented 4 years ago

I dare not to trade on this exchange now, I already lost 2000$ in total because of wrong order book. I quit!