Get and Count() how many futures open order we have

Hi I would like to make a buy market order only if there is no other futures open order as condition statement, can someone provide the truly needed help ?

You can make use of this endpoint: Binance API Documentation, to check if there are any open orders on your account. If there are no open orders, this endpoint will return an empty JSON. From there. you can place your market order.

1 Like

Thanks, but I’m very novice in python so I would ask to explain the process please.
First how do you make the condition statement about the empty JSON ? On my script, I don’t use JSON but the futures_get_open_orders return empty square brackets.

Moreover, I tried this client.futures_get_open_orders(symbol=‘ADAUSDT’) even with this asset open position , it returns empty square brackets

I don’t know if you have already found a solution but the client.futures_get_open_orders() is only checking for orders that are not filled. In your case, you are in position on the ADAUSDT pair so you have to look for open positions and not open orders. One way I found to do this is to iterate over the possible positions in my account and only return the position were the coin amount is superior than zero. You can do this by this way :

positions = [obj for obj in client.futures_account()[‘positions’] if float(obj[‘positionAmt’]) > 0]

This will return a list of all the open positions in your account.
Also to check if your JSON is empty you can simply use :

if JSON_object == {}:
do something
do something else

Hope my answer is good for you !

1 Like