Bug L3 orderbook kucoin
See original GitHub issueL3 orderbook gets out of sync really fast with Kucoin
@bmancini55 I have tried your L3 prototype OB and I have also built one myself, but both of them lose quite a lot of information it seems. I think it gets out of sync at least around every minute (so the sequenceId gets out of sync). To recreate the bug, just run your code and you should have an “out of sync, expected ${ob.sequenceId + 1}, got ${update.sequenceId}” error fast.
Here is the exact code:
const ccxws = require("ccxws"); const KucoinOrderBook = require("ccxws/src/orderbooks/KucoinOrderBook"); let market = {id: "BTC-USDT", base: "BTC", quote: "USDT"}; let updates = []; let ob; const client = new ccxws.Kucoin(); client.subscribeLevel3Updates(market); client.on("l3snapshot", snapshot => { ob = new KucoinOrderBook(snapshot, updates); }); client.on("l3update", update => { // enqueue updates until snapshot arrives if (!ob) { updates.push(update); return; } // validate the sequence and exit if we are out of sync if (ob.sequenceId + 1 !== update.sequenceId) { console.log(out of sync, expected ${ob.sequenceId + 1}, got ${update.sequenceId}); process.exit(1); } // apply update ob.update(update); });
The only thing I found about it as of right now, was someone who used python : https://github.com/Kucoin/kucoin-api-docs/issues/44#issuecomment-477105864
EDIT: Running on Node v14.7 on Windows 10
Really random guess, could be a fault in WS package and this could be the fix? https://github.com/websockets/ws/commit/e1349c047d7f1c120ca606364e35d5c4c627c599
Tried it myself didn’t work unfortunately
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Released in https://github.com/altangent/ccxws/releases/tag/v0.37.2. Also added a few minor fixes to the L3 order book.
Nice work thanks @bmancini55