Crypto-toolbox / btfxwss

Bitfinex Websocket API Client written in Python3
MIT License
284 stars 125 forks source link

Incomplete book ? #128

Open Leobouloc opened 6 years ago

Leobouloc commented 6 years ago

I use the API to fetch the orderbooks for BTCUSD with the following parameters:

PRECISION = 'P0'
FREQUENCY = 'F0' # F0 for realtime, F1 for 2sec
LENGTH = '100' # 25 or 100

I would expect my book length to always be 99 or 100 both for bid and ask. Yet when I empty the book updates using the code below, I often end up with book lengths of 85, 86 ... If I try to loop the code below to wait until I get a full book, I often have to wait up to 5 or 6 seconds before my book representation is valid (length 100 on both sides). This seems very long to me.

while not books_q.empty():
    values = books_q.get()
    [update book structure]

Is this an expected behavior ? If not, is it possible that the ordering of the queue be different than that in which the messages were passed ? Is it possible that some update messages got lost ?

deepbrook commented 6 years ago

Hm. If I understand correctly, some entries are also entry removals. So technically, there may be 100 entries.

have you checked if values has a length of 100 ?

Leobouloc commented 6 years ago

At the snapshot, I always have 100 values as far as I recall. For updates, I always get a single update per message. So it makes sense that my orderbook does not always have 100 values. But I would expect the following updates to make up for any deletion. Yet I often have to wait 5 or 6 seconds to get a complete orderbook back (with additions to the orderbook)... Does this seem like the expected behavior of the Bitfinex API / btfxwss library ?

deepbrook commented 6 years ago

I'd say it's expected behaviour - since i would assume its alway 100 updates, not actualy entries. Btfxwss just passes the messages though, so perhaps you should check with bitfinex - just to be sure :)