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

'NoneType' object has no attribute 'encode #26

Open
gossip69 opened this issue Apr 21, 2021 · 17 comments
Open

'NoneType' object has no attribute 'encode #26

gossip69 opened this issue Apr 21, 2021 · 17 comments

Comments

@gossip69
Copy link

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.

@CyberPunkMetalHead
Copy link
Owner

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

@gossip69
Copy link
Author

ss

It passes from the csv file though not all are parsed

@gerlofvanek
Copy link

Same error:
6701fc525f6bb7424da10736c2e13230

@CyberPunkMetalHead
Copy link
Owner

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

@gerlofvanek
Copy link

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?

@CyberPunkMetalHead
Copy link
Owner

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.

@gossip69
Copy link
Author

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

@gossip69
Copy link
Author

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():

@CyberPunkMetalHead
Copy link
Owner

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

@gossip69
Copy link
Author

gossip69 commented Apr 22, 2021

'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'

@CyberPunkMetalHead
Copy link
Owner

CyberPunkMetalHead commented Apr 23, 2021

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

@gossip69
Copy link
Author

gossip69 commented Apr 23, 2021

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

@orielswisa
Copy link

@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

@ozeitis
Copy link

ozeitis commented Apr 23, 2021

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

@ozeitis
Copy link

ozeitis commented Apr 23, 2021

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'

@CyberPunkMetalHead
Copy link
Owner

@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.

@jgsaez9
Copy link

jgsaez9 commented Apr 27, 2021

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

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

6 participants