Crypto-toolbox / btfxwss

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

It takes long time to receive message after enabling checksum #129

Closed clintonlover closed 6 years ago

clintonlover commented 6 years ago

Hi team, I find it takes much longer time to receive messages when enabling checksum, than that without checksum. Here are the code I modified in client.py

    def config(self, decimals_as_strings=True, ts_as_dates=False,
           sequencing=False,checksum =False, **kwargs):
    """Send configuration to websocket server

    :param decimals_as_strings: bool, turn on/off decimals as strings
    :param ts_as_dates: bool, decide to request timestamps as dates instead
    :param sequencing: bool, turn on sequencing
    :param checksum: bool, turn on checksum ## added by lushichao, 20180324
    :param kwargs:
    :return:
    """
    flags = 0
    if decimals_as_strings:
        flags += 8
    if ts_as_dates:
        flags += 32
    if sequencing:
        flags += 65536
    if checksum:
        flags += 131072

And I check the interval time for public channel trades message, interval_time = MTS from message - local received time. I found that the average interval time without checksum is 216 ms, the stdev is 0.25; while the average interval time after enabling checksum is 1000 seconds (more than 16 minutes!!!), the stdev is 1321. Why it takes so long? It's not acceptable for us build local order book. Is there any solution to fix this problem? we'd expected the same delay interval as that without checksum. Or is there any other way except checksum to check my local order book is consistent with the market order book?

clintonlover commented 6 years ago

It's not the checksum that causes message long latency. I made a mistake to run the program in different environment. Actually, the latency with checksum enabled could be the same as the one without checksum. Hopefully it does not disturb you. thanks.