How to create market order for a certain amount of (BUSD e.t.c.), not quantity (binance-futures-connector) ?

My case:
I want to create python script, which will create market order by certain amount of BUSD. (like: buy or sell (short \ long) ETH for such amount of BUSD (like: 2 BUSD in margin and i want to create market order with short position, for 1.5 BUSD on 20x leverage ). But my problem is: i don’t want to create order with variable - quantity (of ETH), i don’t even know, how much i need ETH for creating order.

P.S. Sorry for my English


asset = 1.5 # BUSD
try:
    response = um_futures_client.new_order(
        symbol="ETHBUSD",
        side="BUY",
        type="MARKET",
        quantity=0.01 # <- this variable - my problem :(
        #quantityOfAsset=asset <- i want something like that
    )
    logging.info(response)
except ClientError as error:
    logging.error(
        "Found error. status: {}, error code: {}, error message: {}".format(
            error.status_code, error.error_code, error.error_message
        )
    )

It’s not possible. You are expected to work out the conversion before placing the order.

It is rare that Binance offers us the quoteOrderQty option only for spot and not for margin, this would save many of us a lot of headaches; In order to calculate the amount to buy of your base asset you need the market price which you could consult with this entry Binance API Documentation, Once you have the price, divide the amount of BUSD you want to buy by the price you obtained and obtain the amount of your asset. For example, suppose you want to buy 2.5BUSD when the price of ETH is 1,500BUSD, then you would have 2.5 / 1,500 = 0.0016666666666667ETH , you would have to apply the stepsize filter to this amount, which you can consult with the GET /api/v3/exchangeInfo entry in the filters field, which in the case of ETHBUSD is 0.0001, which means that your amount would have to be truncated to 4 decimals remaining 0.0016ETH

Correction since the minimum that can be purchased must be greater than 10USDT this example does not apply with 2.5USDT otherwise you would have an error when placing the order so just change the value for 25USDT hehe