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.58k stars 289 forks source link

'NoneType' object has no attribute 'encode #26

Open gossip69 opened 3 years ago

gossip69 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

ss

It passes from the csv file though not all are parsed

gerlofvanek commented 3 years ago

Same error: 6701fc525f6bb7424da10736c2e13230

CyberPunkMetalHead commented 3 years ago

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

gerlofvanek commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

gossip69 commented 3 years ago

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 commented 3 years ago

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

gossip69 commented 3 years ago

'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 commented 3 years ago

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

gossip69 commented 3 years ago

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

orielswisa commented 3 years ago

@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 commented 3 years ago

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

ozeitis commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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