tiagosiebler / bybit-api

Node.js SDK for the Bybit APIs and WebSockets, with TypeScript & browser support.
https://www.npmjs.com/package/bybit-api
MIT License
246 stars 81 forks source link

Data comes in twice from the websocket position #76

Closed k3341095 closed 3 years ago

k3341095 commented 3 years ago

Connect to webso and subscribe to the position When you buy coins at the market price The signal flies twice.. Is it originally like that? Or is it a bug?

I am using a testnet.

tiagosiebler commented 3 years ago

It's originally like that - I see it too sometimes. I think it's more common when multiple position events happen in a short amount of time. For example if you place a larger market order that sees many smaller partial fills, I think each fill triggers a position update.

For position updates, this library just relays raw events coming from the websocket - you can follow it from here down to the this.emit('update', message) call further down: https://github.com/tiagosiebler/bybit-api/blob/master/src/websocket-client.ts#L239

raifemre commented 3 years ago

I am also having the same problem, to quick fix this; store id's of data and do not evaluate duplicate ones