Strengthen retry case and add comments

emit_clear_ticks_only_on_ts_change
jaredgoldman 2023-03-20 21:24:23 -04:00
parent 84cd7fe0e1
commit ccfe033b7a
1 changed files with 4 additions and 1 deletions

View File

@ -343,6 +343,7 @@ class Client:
url = f"/market/candles?type={type}&symbol={kucoin_sym}&startAt={start_dt}&endAt={end_dt}"
bars = []
for i in range(10):
res = await self._request(
@ -350,7 +351,9 @@ class Client:
url,
api_v="v1",
)
if not isinstance(res, list):
if not isinstance(res, list) or not len(bars):
# Do a gradual backoff if Kucoin is rate limiting us
await trio.sleep(i + (randint(0, 1000) / 1000))
else:
bars = res