Hi.
I use python 3.9.4 with BINANCE API.
I use the function “send_signed_request” of this sample : https://github.com/binance-exchange/binance-signature-examples/blob/master/python/delivery-futures.py
I have no probleme to send requests for get account info or price market.
But when I want to make new order :
-
Postman
With Postman there is no probleme with :{{url}}/fapi/v1/order?symbol=LTCUSDT&side=SELL&positionSide=BOTH&type=MARKET&quantity=0.150×tamp={{timestamp}}&signature={{signature}}
-
Python
with pyton :
https://fapi.binance.com/fapi/v1/order?symbol=LTCUSDT&side=BUY&positionSide=BOTH&type=MARKET&quantity=0.084×tamp=1620408669292&signature=7fdb0.....
I have error messages :
{'code': -1022, 'msg': 'Signature for this request is not valid.'}
Note:
I maked a little change on function “send_signed_request” because ? became & just behind timestamp
Before :
def send_signed_request(http_method, url_path, payload={}):
…
if query_string:
query_string = “{}×tamp={}”.format(query_string, get_timestamp())
else:
query_string = ‘timestamp={}’.format(get_timestamp())url = BASE_URL + url_path + ‘?’ + query_string + ‘&signature=’ + hashing(query_string)
…
After :
def send_signed_request(http_method, url_path, payload={},**defaultItemTimestamp='?'**): if query_string: query_string = "{}"+**defaultItemTimestamp**+"timestamp={}".format(query_string, get_timestamp()) else: query_string = 'timestamp={}'.format(get_timestamp()) url = BASE_URL + url_path + **defaultItemTimestamp** + query_string + '&signature=' + hashing(query_string)
So, with this function it’s always ok for get account info or price market, but KO for make new order
I not understand…
Thank for your help