Corfucinas/crypto-candlesticks

Extend code with limit check

Opened this issue · 1 comments

paczko commented

Is your feature request related to a problem? Please describe.
When executing the code sometime Bitfinex limitation (https://docs.bitfinex.com/docs/requirements-and-limitations) reached.
A logic need to be added when it happens and sleep for a time (60s) defined by Bitfinex.

Describe the solution you'd like
A logic like that would be nice to be added:

orig code:

    candle_data.extend(candlestick)
    write_to_console(
        ticker,
        interval,
        candlestick,
        live,
        setup_table(),
    )

..suggested code:

  if (len(candlestick) == 3):
      if  (candlestick[2] == 'ratelimit: error'):
          print('limit exceeded. sleep for 60s')
          sleep(60)
          continue
      break
  if len(candlestick) > 0:
    candle_data.extend(candlestick)
    write_to_console(
        ticker,
        interval,
        candlestick,
        live,
        setup_table(),
    )
  else:
    break

..the above suggested changes handles the situation if date is newer than latest data (even today added causes exception in code running)