Binance-News-Sentiment-Bot icon indicating copy to clipboard operation
Binance-News-Sentiment-Bot copied to clipboard

'NoneType' object has no attribute 'encode

Open gossip69 opened this issue 3 years ago • 17 comments

create test order before pushing an actual order

        test_order = client.create_test_order(symbol=coin+PAIRING, side='BUY', type='MARKET', quantity=volume[coin+PAIRING])

over in this line im getting error message "'NoneType' object has no attribute 'encode", while it says preparing to buy xxx with USDT at xxx price.

Can help help me solve this issue?

Thanks.

gossip69 avatar Apr 21 '21 18:04 gossip69

It sounds to me like you’re not passing anything from the csv file. Is this located in the same directory as your script?

CyberPunkMetalHead avatar Apr 21 '21 18:04 CyberPunkMetalHead

ss

It passes from the csv file though not all are parsed

gossip69 avatar Apr 21 '21 18:04 gossip69

Same error: 6701fc525f6bb7424da10736c2e13230

gerlofvanek avatar Apr 21 '21 18:04 gerlofvanek

I'm unable to replicate your issue. Are you using the Binance Testnet?

CyberPunkMetalHead avatar Apr 22 '21 09:04 CyberPunkMetalHead

I'm unable to replicate your issue. Are you using the Binance Testnet?

@CyberPunkMetalHead Yes using testnet - What for vars do you set for Live/Mainnet?

gerlofvanek avatar Apr 22 '21 09:04 gerlofvanek

For mainnet the API keys and secret would have to be changed and the API.URL line removed.

But if you’re using it on the testnet that shouldn’t be an issue since the bot is made work on the testnet first and foremost.

Can you create a simple test order outside of the buy function and see what it returns? Give it explicit lot sizes and coin.

CyberPunkMetalHead avatar Apr 22 '21 09:04 CyberPunkMetalHead

Yes sir, I have my all mine set up from testnet.binance.vision.

gossip69 avatar Apr 22 '21 09:04 gossip69

same error 'NoneType' object has no attribute 'encode'

i wrote

volume = calculate_volume() buy_limit = client.create_order( symbol=coin+PAIRING, side='BUY', type='MARKET', quantity=volume[coin+PAIRING] )

after the def calculate_volume():

gossip69 avatar Apr 22 '21 11:04 gossip69

Does your code return anything when you run client.get_account() ?

CyberPunkMetalHead avatar Apr 22 '21 12:04 CyberPunkMetalHead

'NoneType' object has no attribute 'encode'

same error. so there is something wrong with the connection?

am using the credentials from HMAC_SHA256

with

client.API_URL = 'https://testnet.binance.vision/api'

gossip69 avatar Apr 22 '21 13:04 gossip69

It looks like the API can't process your request. You can try updating the python-binance library and retry.

CyberPunkMetalHead avatar Apr 23 '21 07:04 CyberPunkMetalHead

still not working, would you mind if i dm you and we can sort this problem out live?

gossip69 avatar Apr 23 '21 07:04 gossip69

@gossip69 @CyberPunkMetalHead I had the same problame and that fixed my issuse: Try to generate new HMAC_SHA256 Key and write the directly in news-analysis.py

orielswisa avatar Apr 23 '21 09:04 orielswisa

I am also having this issue with no solution in sight. I tried it all.

ozeitis avatar Apr 23 '21 16:04 ozeitis

Created API key from https://testnet.binance.vision , but I dont know how it connects to my actual Binance account if that makes sense or adds to the issue

BUY CHECKS: Sentiment not positive enough for BTC, or not enough headlines analysed or already bought: -0.13484444444444443, 9 preparing to buy 0.00433 ETH with USDT at 2311.43000000 Traceback (most recent call last): File "news-analysis.py", line 463, in <module> buy(compiled_sentiment, headlines_analysed) File "news-analysis.py", line 356, in buy test_order = client.create_test_order( File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 1723, in create_test_order return self._post('order/test', True, data=params) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 323, in _post return self._request_api('post', path, signed, version, **kwargs) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 265, in _request_api return self._request(method, uri, signed, **kwargs) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 243, in _request kwargs['data']['signature'] = self._generate_signature(kwargs['data']) File "/usr/local/lib/python3.8/dist-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'

ozeitis avatar Apr 23 '21 16:04 ozeitis

@Ozeitis your testnet acc is not connected to your live account, just your GitHub account. It does look like an issue with your python-binance setup, unfortunately I'm unable to replicate it. I will update you if I come accross this issue. In the meantime you could try looking for this issue, or opening an issue in the python-binance lib.

CyberPunkMetalHead avatar Apr 23 '21 18:04 CyberPunkMetalHead

Creé la clave de API de https://testnet.binance.vision , pero no sé cómo se conecta a mi cuenta de Binance real si eso tiene sentido o se suma al problema

BUY CHECKS: Sentiment not positive enough for BTC, or not enough headlines analysed or already bought: -0.13484444444444443, 9 preparing to buy 0.00433 ETH with USDT at 2311.43000000 Traceback (most recent call last): File "news-analysis.py", line 463, in <module> buy(compiled_sentiment, headlines_analysed) File "news-analysis.py", line 356, in buy test_order = client.create_test_order( File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 1723, in create_test_order return self._post('order/test', True, data=params) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 323, in _post return self._request_api('post', path, signed, version, **kwargs) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 265, in _request_api return self._request(method, uri, signed, **kwargs) File "/usr/local/lib/python3.8/dist-packages/binance/client.py", line 243, in _request kwargs['data']['signature'] = self._generate_signature(kwargs['data']) File "/usr/local/lib/python3.8/dist-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'

+1

jgsaez9 avatar Apr 27 '21 00:04 jgsaez9