CyberPunkMetalHead / Binance-volatility-trading-bot

This is a fully functioning Binance trading bot that measures the volatility of every coin on Binance and places trades with the highest gaining coins If you like this project consider donating though the Brave browser to allow me to continuously improve the script.
MIT License
3.42k stars 779 forks source link

'NoneType' object has no attribute 'encode' #15

Closed Dogepot2 closed 3 years ago

Dogepot2 commented 3 years ago

I get the following when the script tries to buy:

RLCUSDT has gained 9.972% in the last 5 minutes, calculating volume in USDT CTXCUSDT has gained 7.022% in the last 5 minutes, calculating volume in USDT TRBUSDT has gained 3.737% in the last 5 minutes, calculating volume in USDT preparing to buy 9.17 RLCUSDT 'NoneType' object has no attribute 'encode' preparing to buy 175.99 CTXCUSDT 'NoneType' object has no attribute 'encode' preparing to buy 0.77 TRBUSDT 'NoneType' object has no attribute 'encode'

The coins_bought.json is there but only has "{}" written in it

Frittaters commented 3 years ago

Having the same problem, i'm trying to find solutions

CyberPunkMetalHead commented 3 years ago

This is likely an issue with your API keys. The code uses environment variables stored on the machine, but you don't have to do that. Please reformat your API_KEYS to be api_key = "YOUR_API_KEY" instead of api_key = os.getenv('some_key')and try again.

krczk commented 3 years ago

First thank you for the advice.

Please reformat your API_KEYS to be api_key = "YOUR_API_KEY" instead of api_key = os.getenv('some_key')and try again.

So it should look like this right? (xxx - real api keys in quotes)

api_key_live = "xxxx" api_secret_live = "xxxx" it ends with same problem

'NoneType' object has no attribute 'encode'

Frittaters commented 3 years ago

This is likely an issue with your API keys. The code uses environment variables stored on the machine, but you don't have to do that. Please reformat your API_KEYS to be api_key = "YOUR_API_KEY" instead of api_key = os.getenv('some_key')and try again.

Tried it and it works, I used single quotes instead of double, but that should make no difference as far as I know.

api_key_live = 'xxxx' api_secret_live = 'xxxx'

krczk commented 3 years ago

I've made new keys and it worked, with single quotes, I dont want to know was it the coma or the key ;) but there is next one in front of me

UTKUSDT has gained 4.8% in the last 5 minutes, calculating volume in USDT preparing to buy 31.91 UTKUSDT Traceback (most recent call last) File "BoBi2.py", line 296, in update_porfolio(orders, last_price, volume) File "BoBi2.py", line 264, in update_porfolio symbol': orders[coin][0]['symbol'],` IndexError: list index out of range

CyberPunkMetalHead commented 3 years ago

@krczk please use the latest commit, that issue is fixed now

notflip commented 3 years ago

@CyberPunkMetalHead I just came across this issue after having pulled the latest, it happens in this context

TP or SL reached, selling 0.15 BNBUSDT...
Traceback (most recent call last):
  File "/Users/miguelstevens/Desktop/bot/Binance Detect Moonings.py", line 327, in <module>
    coins_sold = sell_coins()
  File "/Users/miguelstevens/Desktop/bot/Binance Detect Moonings.py", line 253, in sell_coins
    test_order = client.create_test_order(symbol=coin, side='SELL', type='MARKET', quantity=coins_bought[coin]['volume'])
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 1762, in create_test_order
    return self._post('order/test', True, data=params)
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 368, in _post
    return self._request_api('post', path, signed, version, **kwargs)
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 328, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 306, in _request
    kwargs = self._get_request_kwargs(method, signed, force_params, **kwargs)
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 262, in _get_request_kwargs
    kwargs['data']['signature'] = self._generate_signature(kwargs['data'])
  File "/Users/miguelstevens/Library/Python/3.9/lib/python/site-packages/binance/client.py", line 221, in _generate_signature
    m = hmac.new(self.API_SECRET.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)