Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rtaibah opened this issue Apr 25, 2021 · 1 comment

Comments

@rtaibah
Copy link

rtaibah commented Apr 25, 2021

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
Copy link
Author

rtaibah commented Apr 25, 2021

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

api_key="API_KEY"
api_secret="API_SECRET

@rtaibah rtaibah closed this as completed Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant