There are some bugs in the Kucoin exchange
See original GitHub issueExchange
Kucoin
Subscription type
Level2orderbook
Describe the bug
The l2snapshot event doesn’t emit the market, like all other exchanges do. This is a simple fix at line 399:
this.emit("l2snapshot", snapshot);
-> this.emit("l2snapshot", snapshot, market);
Second bug / feature is that with Kucoin or the code emits orderbook updates one by one?
Simple test is to do the following:
kucoin.on("l2update",
(update, market) => {
console.log(“Handling response”);
setTimeout(()=>console.log(“After response”), 0);
});`
And then you often see multiple “handling response” without an after response after? It also seems weird if kucoin sends every orderbook update one by one? While documentation suggests multiple updates might come in one message?
https://docs.kucoin.com/#level-2-market-data
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
The plan is by end of this upcoming week. The Kucoin L3 support and a few other issues are on the remaining list before we cut this next huge release.
@bmancini55 I have tried your L3 prototype OB and I have also built one myself, but both of them lose quite a lot of messages it seems. I think at least 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.
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 exact code I ran. 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-477105864EDIT: 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
Could you reopen the issue please or should I open a new issue?