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

'NoneType' object has no attribute 'encode #50

Closed VadimS42 closed 3 years ago

VadimS42 commented 3 years ago

I know there is an error abt that but any solution? I'm using real keys, not test. preparing to buy 3.72 XRP with USDT at 1.34310000 'NoneType' object has no attribute 'encode' Sentiment not positive enough for BTC, or not enough headlines analysed or already bought: 0.0170875, 8 preparing to buy 0.00184 ETH with USDT at 2718.69000000 'NoneType' object has no attribute 'encode' Inserted the keys. have balance. Testnet set to false. python-binance library updated.

VadimS42 commented 3 years ago

If i run client.get_account() i get that Traceback (most recent call last): File "D:\BinanceBot\Binance-News-Sentiment-Bot-main\news-analysis.py", line 567, in <module> client.get_account() File "C:\Users\geood\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 1912, in get_account return self._get('account', True, data=params) File "C:\Users\geood\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 320, in _get return self._request_api('get', path, signed, version, **kwargs) File "C:\Users\geood\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 265, in _request_api return self._request(method, uri, signed, **kwargs) File "C:\Users\geood\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 243, in _request kwargs['data']['signature'] = self._generate_signature(kwargs['data']) File "C:\Users\geood\AppData\Local\Programs\Python\Python39\lib\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' Press Ctrl-Q to stop the script

CyberPunkMetalHead commented 3 years ago

I think it might be due to how you're storing the api keys. In the script you can see something like api_key = os.getenv('binance_testnet_key'). So here I actually stored the key as an environment variable in Windows and I'm then pulling its value using the os module.

You don't have to go about it that way, you can simply refactor your api_key and secret to be api_key="YOUR_KEY_HERE"

VadimS42 commented 3 years ago

I think it might be due to how you're storing the api keys. In the script you can see something like api_key = os.getenv('binance_testnet_key'). So here I actually stored the key as an environment variable in Windows and I'm then pulling its value using the os module.

You don't have to go about it that way, you can simply refactor your api_key and secret to be api_key="YOUR_KEY_HERE"

Thank u a lot for fast reply. I was about to comment that myself. Googling showed me similiar solution here https://github.com/zyairelai/futures-hero/issues/1#event-4325774265

CyberPunkMetalHead commented 3 years ago

No worries, let me know if that fixes your issue.

VadimS42 commented 3 years ago

No worries, let me know if that fixes your issue.

It solved the issue, thanks. I saw that quite some ppl have that issue, maybe in next version you should specify that somewhere. Thanks for the amazing bot btw!