CyberPunkMetalHead / Binance-News-Sentiment-Bot

This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds. If you like this project consider donating though the Brave browser to allow me to continuously improve the script.
MIT License
1.57k stars 290 forks source link

Not Able to Buy: AttributeError: 'NoneType' object has no attribute 'encode' #38

Closed rtaibah closed 3 years ago

rtaibah commented 3 years ago

Getting the following error:


preparing to buy 0.001996 BTC with USDT at 50112.05000000
Traceback (most recent call last):
  File "/Users/rami/scripts/Binance-News-Sentiment-Bot/news-analysis.py", line 489, in <module>
    buy(compiled_sentiment, headlines_analysed)
  File "/Users/rami/scripts/Binance-News-Sentiment-Bot/news-analysis.py", line 389, in buy
    test_order = client.create_test_order(symbol=coin+PAIRING, side='BUY', type='MARKET', quantity=volume[coin+PAIRING])
  File "/usr/local/lib/python3.9/site-packages/binance/client.py", line 1723, in create_test_order
    return self._post('order/test', True, data=params)
  File "/usr/local/lib/python3.9/site-packages/binance/client.py", line 323, in _post
    return self._request_api('post', path, signed, version, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/binance/client.py", line 265, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/binance/client.py", line 243, in _request
    kwargs['data']['signature'] = self._generate_signature(kwargs['data'])
  File "/usr/local/lib/python3.9/site-packages/binance/client.py", line 198, in _generate_signature
    m = hmac.new(self.API_SECRET.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)
AttributeError: 'NoneType' object has no attribute 'encode'```
rtaibah commented 3 years ago

Had to define api_secret without env variables, since I wasn't using those.

api_key="API_KEY" api_secret="API_SECRET