fbpx

Typical Binance API exception with Python

(Last Updated On: January 13, 2022)

 

Here are some sample exceptions you might have with Binance using Python. This can be handled any way you want but it will not stop your bot. This does not happen as long as you stay within the Binance trading rules

Build your trading bot with this https://quantlabs.shop/collections/main-items/products/python-algo-trading-infrastructure-with-crypto-currency

Join our newsletter to enhance your trading knowledge  https://quantlabs.net/contact/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/caustic/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send

timeout=timeout

File "/home/caustic/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 756, in urlopen

method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

File "/home/caustic/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 574, in increment

raise MaxRetryError(_pool, url, error or ResponseError(cause))

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/exchangeInfo (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fca44dac908>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 569, in fetch

verify=self.verify

File "/home/caustic/.local/lib/python3.6/site-packages/requests/sessions.py", line 542, in request

resp = self.send(prep, **send_kwargs)

File "/home/caustic/.local/lib/python3.6/site-packages/requests/sessions.py", line 655, in send

r = adapter.send(request, **kwargs)

File "/home/caustic/.local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send

raise ConnectionError(e, request=request)

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/exchangeInfo (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fca44dac908>: Failed to establish a new connection: [Errno -2] Name or service not known',))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "ccxt_market_data2redis.py", line 67, in <module>

exchange.load_markets()

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 1350, in load_markets

markets = self.fetch_markets(params)

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/binance.py", line 579, in fetch_markets

response = getattr(self, method)(query)

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 465, in inner

return entry(_self, **inner_kwargs)

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/binance.py", line 2472, in request

response = self.fetch2(path, api, method, params, headers, body)

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 486, in fetch2

return self.fetch(request['url'], request['method'], request['headers'], request['body'])

File "/home/caustic/.local/lib/python3.6/site-packages/ccxt/base/exchange.py", line 614, in fetch

raise NetworkError(details) from e

ccxt.base.errors.NetworkError: binance GET https://api.binance.com/api/v3/exchangeInfo

BinanceCryptoData_1m LUNAUSDT

Error: 'NoneType' object has no attribute 'decode'

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top