question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kucoin watch_order_book initial snapshot error

See original GitHub issue
  • OS: ubuntu 16.04
  • Programming Language version: python 3.6.5
  • CCXT version: 0.1.67

Happens intermittently when trying to subscribe to many pairs. Once it happens the stream never recovers. Would be great if there was a way to detect stale streams and automatically restart

Having trouble reproducing locally, I think it’s related to rate limiting where kucoin will return a blank response or something. Is it possible to add a retry on the initial book snapshot?

enableRateLimiting is set to True here

  File "/python3.6/site-packages/ccxtpro/kucoin.py", line 227, in watch_order_book
    return await self.after(future, self.limit_order_book, symbol, limit, params)
  File "/python3.6/site-packages/ccxtpro/base/exchange.py", line 77, in after
    return method(await future, *args)
  File "/python3.6/site-packages/ccxtpro/base/exchange.py", line 80, in after_async
    return await method(await future, *args)
  File "/python3.6/site-packages/ccxtpro/kucoin.py", line 111, in subscribe
    return await self.watch(url, messageHash, request, messageHash, subscription)
  File "/python3.6/site-packages/ccxtpro/kucoin.py", line 243, in fetch_order_book_snapshot
    previousSequence = sequenceStart - 1
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
kroitorcommented, Apr 20, 2020

Looks like this works, awesome thanks!

Yep, basically, you can play with those settings to adjust for the networking environment. Let me know if you experience any further difficulties with it. In the meantime we will try to address that in a more robust way. Thx for your involvement, appreciate it!

1reaction
jaseisen105commented, Apr 20, 2020

@jaseisen105 we have added one more solution that should also mitigate the problem (it’s already available in 0.1.69, so you have it already), you can add a warmup delay to make sure that the snapshot sequence number is older than the first delta:

exchange = ccxtpro.kucoin({
    'enableRateLimit': True,
    'options': {
        'fetchOrderBookSnapshot': {
            'maxAttempts': 1000,  # max attempts to fetch the snapshot
            'delay': 1000,  # a warmup delay in milliseconds before attempting to fetch the snapshot
        },
    },
})

↑ Adding a warmup delay should also help increase the reliability of synchronization with KuCoin. Let me know if that helps or not.

(I got the email with the logs from you, public feeds do not include sensitive info). The problem is that KuCoin returns a snapshot too old, compared to the WS delta feed, probably due to caching on the webservers – so, an added delay should help). Please, try values from 1000-5000 (1-5 seconds) for the 'delay' and let me know if that helps or not.

Thx!

Looks like this works, awesome thanks!

@jaseisen105 and another quick question – do you have any caching http/https proxies on the production system? (just to rule them out).

None

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual — ccxt 2.4.71 documentation
watchOrderBook (symbol, limit) // do something or react somehow based on that ... the updates received from the exchange server into the local...
Read more >
What Should I Do If Deposit Wrong Crypto? - KuCoin
(4) The screenshot of the transfer record from the withdrawal platform. Ensure that the TXID, coin type, amount, and address are shown on...
Read more >
KuCoin API Documentation: General
Add Get Market List; Add Symbol Snapshot Feed; Add Market Snapshot Feed ... 500, Internal Server Error -- We had a problem with...
Read more >
Deposit FAQ - KuCoin
... make sure to confirm it with KuCoin admins or customer support first. ... The correct deposit address and the screenshot of the...
Read more >
How to Make a Trade on KuCoin
This article will guide you through the process of making your first trade on KuCoin. Watch the YouTube video below for a step-by-step...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found