Help with order confirmation - apierror(code=-2013): order does not exist

can anyone help with this?

here is my code for creating a position:

order_succeeded, quantity, entry_price = order(SIDE_SELL, TRADE_AMOUNT, TRADE_TICK, "LONG")

def order(side, quantity, symbol, positionSide, order_type=FUTURE_ORDER_TYPE_MARKET):

        print("\n---> sending order")
        order = client.futures_create_order(symbol=symbol, side=side, type=order_type, 
                                            positionSide=positionSide, quantity=quantity)
        order_id = int(order['orderId'])
        order_info = client.futures_get_order(symbol=TRADE_TICK, orderId=order_id)
        entry_price = float(order_info["avgPrice"])
        qty = float(order_info["executedQty"])
        print(f"\n\n---> completed {qty} @ ${entry_price}")

    except Exception as e:
        print(f"an exception occured - {e}")       
        return False

    return True, qty, entry_price 

if order_succeeded:

my issue is that the action will go to exchange and execute, but occasionally the response i get is:

apierror(code=-2013): order does not exist

even though the order did go through correctly…

looking for some ideas on how to approach this, thanks

From your code, the get order is immediately called after placing an order. Please note that it may take some time for the order to be stored in the database depending on the market volume. I suggest putting a sleep before calling the get order to prevent getting an order that has yet to be written to the database which may cause -2013: order does not exist error.