zyairelai / futures-hero

❗ HIGH RISK ❗ Scalping Trading on Binance Futures
163 stars 48 forks source link

error #1

Closed cleitondm closed 3 years ago

cleitondm commented 3 years ago

run python run.py

Traceback (most recent call last): File "run.py", line 17, in if binance_futures.position_information()[0].get('marginType') != "isolated": binance_futures.change_margin_to_ISOLATED() File "D:\botbinance\bot\futures-omax\binance_futures.py", line 31, in position_information return client.futures_position_information(symbol=config.pair, timestamp=get_timestamp()) File "C:\ProgramData\Anaconda3\envs\p37\lib\site-packages\binance\client.py", line 3688, in futures_position_information return self._request_futures_api('get', 'positionRisk', True, data=params) File "C:\ProgramData\Anaconda3\envs\p37\lib\site-packages\binance\client.py", line 222, in _request_futures_api return self._request(method, uri, signed, True, **kwargs) File "C:\ProgramData\Anaconda3\envs\p37\lib\site-packages\binance\client.py", line 180, in _request kwargs['data']['signature'] = self._generate_signature(kwargs['data']) File "C:\ProgramData\Anaconda3\envs\p37\lib\site-packages\binance\client.py", line 135, 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'

zyairelai commented 3 years ago

Hi, you can try to rerun the code again with the proper API key generated from Binance. Besides, are you sure you have proper key generated from your Binance Account? As if you run this code on Binance Futures Testnet it would return the same problem due to Binance Testnet are not complete integrated with the API development.

cleitondm commented 3 years ago

Yes, this is correct api binance

Python squeegee check.py ok

Returns

option

python check.py What do you want to check?

  1. trend 2 minutes
  2. position
  3. noticedPNL

Enter a number: 2 Pair name: BTCUSDT Amount of trade: 0.001 BTC

Do you want to loop? [Y / n] a ← [32mRECENT 1 MINUTE: GREEN_INDECISIVE ← [0m ← [31mRECENT 5 MINUTE: RED ← [0m Elapsed time: 0.9510176181793213 seconds

Have run.py not working :(

help

cleitondm commented 3 years ago

python run.py Pair Name : BTCUSDT Trade Quantity : 0.001 BTC

Traceback (most recent call last): File "run.py", line 16, in if binance_futures.position_information()[0].get('marginType') != "isolated": binance_futures.change_margin_to_ISOLATED() File "D:\botbinance\bot\futures-omax\binance_futures.py", line 31, in position_information return client.futures_position_information(symbol=config.pair, timestamp=get_timestamp()) File "C:\ProgramData\Anaconda3\envs\p36\lib\site-packages\binance\client.py", line 5070, in futures_position_information return self._request_futures_api('get', 'positionRisk', True, data=params) File "C:\ProgramData\Anaconda3\envs\p36\lib\site-packages\binance\client.py", line 222, in _request_futures_api return self._request(method, uri, signed, True, **kwargs) File "C:\ProgramData\Anaconda3\envs\p36\lib\site-packages\binance\client.py", line 180, in _request kwargs['data']['signature'] = self._generate_signature(kwargs['data']) File "C:\ProgramData\Anaconda3\envs\p36\lib\site-packages\binance\client.py", line 135, 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'

zyairelai commented 3 years ago

Due to the check.py does not require signature of the API, therefore it could return you with result.

Could you recheck your API key and ensure it is in string form quoted with " "?

Once again, please ensure your API key are generated from your Binance Account with Spot, Margin and Futures trading enabled.

https://stackoverflow.com/questions/38133665/python-encoded-message-with-hmac-sha256

cleitondm commented 3 years ago

yes quoted with " "

https://imgur.com/a/WqluZyW

:( python version 3.7

cleitondm commented 3 years ago

I made some changes.

and put

print (binance_futures.position_information ())

python run.py Pair Name: BTCUSDT Trade Quantity: 0.001 BTC

[{'symbol': 'BTCUSDT', 'positionAmt': '0.000', 'entryPrice': '0.00000', 'markPrice': '48014.57513352', 'unRealizedProfit': '0.00000000', 'liquidationPrice': '0', 'leverage': '20', 'maxNotionalValue': '5000000', 'marginType': 'cross',' isolatedMargin ':' 0.00000000 ',' isAutoAddMargin ':' false ',' positionSide ':' BOTH ',' notional ':' 0 ',' isolatedWallet ':' 0 '}]

Traceback (most recent call last): File "run.py", line 16, in if binance_futures.position_information () [0] .get ('marginType')! = "isolated": binance_futures.change_margin_to_ISOLATED () File "D: \ botbinance \ bot \ futures-omax \ binance_futures.py", line 22, in change_margin_to_ISOLATED return client.futures_change_margin_type (symbol = config.pair, marginType = "ISOLATED", timestamp = get_timestamp ()) File "C: \ ProgramData \ Anaconda3 \ envs \ p36 \ lib \ site-packages \ binance \ client.py", line 3664, in futures_change_margin_type return self._request_futures_api ('post', 'marginType', True, data = params) File "C: \ ProgramData \ Anaconda3 \ envs \ p36 \ lib \ site-packages \ binance \ client.py", line 222, in _request_futures_api return self._request (method, uri, signed, True, ** kwargs) File "C: \ ProgramData \ Anaconda3 \ envs \ p36 \ lib \ site-packages \ binance \ client.py", line 197, in _request return self._handle_response () File "C: \ ProgramData \ Anaconda3 \ envs \ p36 \ lib \ site-packages \ binance \ client.py", line 230, in _handle_response raise BinanceAPIException (self.response) binance.exceptions.BinanceAPIException: APIError (code = -2015): Invalid API-key, IP, or permissions for action

cleitondm commented 3 years ago

run :)

python run.py Pair Name : BTCUSDT Trade Quantity : 0.001 BTC

[{'symbol': 'BTCUSDT', 'positionAmt': '0.000', 'entryPrice': '0.00000', 'markPrice': '48084.99020718', 'unRealizedProfit': '0.00000000', 'liquidationPrice': '0', 'leverage': '20', 'maxNotionalValue': '5000000', 'marginType': 'cross', 'isolatedMargin': '0.00000000', 'isAutoAddMargin': 'false', 'positionSide': 'BOTH', 'notional': '0', 'isolatedWallet': '0'}] CURRENT POSITION : NO_POSITION ←[32mRECENT 5 MINUTE : GREEN←[0m ←[32mRECENT 1 MINUTE : GREEN_INDECISIVE←[0m CURRENT POSITION : NO_POSITION ←[32mRECENT 5 MINUTE : GREEN←[0m ←[32mRECENT 1 MINUTE : GREEN_INDECISIVE←[0m CURRENT POSITION : NO_POSITION ←[32mRECENT 5 MINUTE : GREEN←[0m ←[32mRECENT 1 MINUTE : GREEN_INDECISIVE←[0m CURRENT POSITION : NO_POSITION ←[32mRECENT 5 MINUTE : GREEN←[0m ←[31mRECENT 1 MINUTE : RED←[0m

zyairelai commented 3 years ago

You had mixed up the os.getenv() with your API key. The os.getenv() is supposed to get your API key that you stored in your OS environment for security purpose. In your case, you could replace line 7-10 on binance_futures.py as per following:

api_owner  = "Your_username"
api_key    = "asdfghjkl123456_yourkey"
api_secret = "asdfghjkl123456_yoursecretkey"
client     = Client(api_key, api_secret)