Bitfinex KeyError instead of Too Many Requests
See original GitHub issueEnvironment
- OS: Mac
- Programming Language version: python 3.6.3
- CCXT version: 1.10.566
- Exchange: Bitfinex
- Method: .fetch_balance()
Error Regular polling of the exchange balance on Bitfinex works on and off e.g. succeeds 20 times then fails 5 then succeeds then fails etc …
When in a try/except
it raises a KeyError
exception.
When not in the try/except
it raises a Too many requests
error
Code
exchange_class = "Bitfinex"
....
exchange = eval('ccxt.%s ()' % exchange_class)
....
# In a loop that polls every 1 to 20 seconds
balances = exchange.fetch_balance()
Outside Try/Exception Handling with Verbose
POST https://api.bitfinex.com/v1/balances
Request: {'X-BFX-APIKEY': '4R2JKa7SLigrJ2IXo86MSCASzUJf9EmiFGmHKgfyuyT', 'X-BFX-PAYLOAD': 'eyJub25jZSI6IjE1MTYxNTExNzQ0ODUiLCJyZXF1ZXN0IjoiL3YxL2JhbGFuY2VzIn0=', 'X-BFX-SIGNATURE': '319d6bc3cfc84f000b5e4a10a4f134645ebae684c8aa367df4103ec8cea619fcf08bfd3f3d0a8671cc5628085bd9fb7b', 'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None
Traceback (most recent call last):
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/base/exchange.py", line 349, in fetch
response.raise_for_status()
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://api.bitfinex.com/v1/balances
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "xx.py", line 30, in <module>
pairs = xx.bot(exchange)
File "/Users/michaelnew/Dropbox/Aptana_Workspace/xx/xx.py", line 1220, in bot
self.xx(exchange, xx, pair1_price)
File "/Users/michaelnew/Dropbox/Aptana_Workspace/xx/xx.py", line 1053, in xx
start_balance = self._get_balance(exchange, currency1)
File "/Users/michaelnew/Dropbox/Aptana_Workspace/xx/xx.py", line 900, in _get_balance
balances = exchange.fetch_balance()
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/bitfinex.py", line 279, in fetch_balance
balances = self.privatePostBalances()
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/bitfinex.py", line 654, in request
response = self.fetch2(path, api, method, params, headers, body)
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/base/exchange.py", line 296, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/base/exchange.py", line 361, in fetch
self.handle_errors(response.status_code, response.reason, url, method, None, self.last_http_response)
File "/Users/michaelnew/Dropbox/Aptana_Workspace/Virtual_Environments/Aptana_Workspace-YR4oaOLW/lib/python3.6/site-packages/ccxt/bitfinex.py", line 633, in handle_errors
message = response['message']
KeyError: 'message'
With Try/Exception Handling and Verbose
Raises an exception of class 'KeyError' with no other details
POST https://api.bitfinex.com/v1/balances
Request: {'X-BFX-APIKEY': '4R2JKa7SLigrJ2IXo86MSCASzUJf9EmiFGmHKgfyuyT', 'X-BFX-PAYLOAD': 'eyJub25jZSI6IjE1MTYxNTEwNjcyMjMiLCJyZXF1ZXN0IjoiL3YxL2JhbGFuY2VzIn0=', 'X-BFX-SIGNATURE': '4e925f877c6d0106ef23be3ae8cafe8838d4208868613ce5197b21e34b1d3f315688ef2cd769df2fa0271049702166b8', 'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None
<class 'KeyError'>
e dict: {}
err_msg: EXCEPTION UNKNOWN - TAS::bot ._get_balance EXCHANGE CALL Failed Bitfinex - BTC
currency: BTC
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
bitfinex api v2 error, invalid key - Stack Overflow
I reissued the api key just to verify, same error. from time import time import urllib.request import urllib.parse import hashlib import hmac ...
Read more >ccxt-dev/ccxt - Gitter
And you're required to rate limit your requests (as documented in the Manual, ... I'm using Bitfinex, which returns KeyError: Percentage when I...
Read more >Requirements and Limitations - Bitfinex API
Bitfinex API access is rate limited. For the REST API, an IP address can be rate limited if it has sent too many...
Read more >Why the h*** is this giving me a KeyError? : r/learnpython
For some reason, everything runs fine until I try to record the current price to ... response = requests.get("https://api.bitfinex.com/v1/ticker/btcusd") ...
Read more >How to Fix 429 Too Many Requests Error - Kinsta
Regardless of how the error appears, it always means the same thing – there's a user or a snippet of code that's overwhelming...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have updated the issue with verbose on
will do