BitBotFactory / MikaLendingBot

Automated lending on Cryptocurrency exchanges Poloniex and Bitfinex
http://poloniexlendingbot.readthedocs.io/en/latest/index.html
MIT License
1.11k stars 344 forks source link

PoloniexApiError: Please do not make more than 6 API calls per second. #167

Closed laxdog closed 7 years ago

laxdog commented 7 years ago

I'm getting this error quite a lot at the minute, I've two different backtraces for it

Traceback (most recent call last):
  File "/home/dog/poloniexlendingbot_new/lendingbot.py", line 91, in <module>
    Lending.lend_all()
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 126, in lend_all
    lending_balances = api.return_available_account_balances("lending")['lending']
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 105, in return_available_account_balances
    balances = self.api_query('returnAvailableAccountBalances', {"account": account})
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 79, in api_query
    json_ret = _read_response(ret)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 46, in _read_response
    raise PoloniexApiError(data['error'])
PoloniexApiError: Please do not make more than 6 API calls per second.
  File "/home/dog/poloniexlendingbot_new/lendingbot.py", line 91, in <module>
    Lending.lend_all()
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 125, in lend_all
    total_lended = Data.get_total_lended()[0]
  File "/home/dog/poloniexlendingbot_new/modules/Data.py", line 41, in get_total_lended
    crypto_lended = api.return_active_loans()
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 129, in return_active_loans
    return self.api_query('returnActiveLoans')
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 79, in api_query
    json_ret = _read_response(ret)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 46, in _read_response
    raise PoloniexApiError(data['error'])
PoloniexApiError: Please do not make more than 6 API calls per second.

I've recently started lending across a total of 4 currencies. I'm not sure if that's significant, but I don't think anything else has changed.

laxdog commented 7 years ago

I meant to say, this was on master at 16849f2461c0dd1e5bcd3f99251b11ce52aad39d

Though I looked at the diff from head and there doesn't seem to be anything that would change this.

Evanito commented 7 years ago

Yeah, this is an occasional error that stems from the bot acting too quick, only solution is to add an API request rate limiter.

laxdog commented 7 years ago

The python API that I've been using for a sell bot has a coach mode that limits you to 6 calls a second.

The repo is here: https://github.com/s4w3d0ff/python-poloniex

The return format is a bit different and the functions are of course all named differently, but everything is there by the looks of it. Could be a pain to move API I guess, though would be nice to have a separately maintained API.

Evanito commented 7 years ago

@laxdog I will take a look at it, but it is not a priority.

Evanito commented 7 years ago

Discussion for addition of a coach in #188 This issue is about error handling.

rnevet commented 7 years ago

@Evanito should we close this one as well?