This code is making order of buying 12 FLM quantity with usdt of 6$ as price of FLM is 0.5 at that time .
But what I want to make order is 12$ usdt as quantity parameter and whatever the quantity can be get during that market price should be place order.
I want to pass USDT as quantity parameter, The reason for this is, for specific quantity of any token, we need to fetch price to calculate quantity with available balance for trade, this consumes some time, I don’t want to waste that time.
Is there any way to make USDT as quantity parameter?
That’s known as “quoteOrderQt” in Spot (more info: Beginner's Guide to QuoteOrderQty Market Orders), however this feature is not yet available on Futures, but we’re aware of its demand.
Hi learner,
I am totally agree with you. Without quoteOrderQt in futures_create_order Futures mode, we can’t use all quotedCoin to hold a position.
This is not good for a high-frequency operation(204 times per year),after backtesting of my model, my ROI decrease almost 7% ,assum I use 99% quotedCoin to hold a position,so…quoteOrderQt is important for me to operate.
Hope @aisling can heard my request.
qtd_quote: The quantity of USDT you want to trade.
price: Use a WebSocket to get the market price in real time. You can set the price for Limit orders.
size: variable assigned to the quantity parameter.
round: rounds the quotient of the division.
3: the precision (number of digits after the coma) allowed for the asset you want to trade.
# Fetch current price (pseudo-code, replace with actual method to fetch price)
flm_price = bot.futures_price(symbol="FLMUSDT")
# Desired amount in USDT
qtd_quote = 100.00
# Calculate the quantity of FLM, rounded to 3 decimal places
flm_quantity = round(qtd_quote / flm_price, 3)
# Place the order
bot.futures_create_order(symbol="FLMUSDT", side="BUY", type="MARKET", quantity=flm_quantity)
The rounding precision (3 in round(qtd_quote / flm_price, 3) ) may need to be adjusted based on the minimum trade size and precision requirements of the specific trading pair on Binance.
To do this automatically, you can fetch info from the trading pair:
# Fetch trading pair information
exchange_info = bot.futures_exchange_info()
pair_info = next((item for item in exchange_info['symbols'] if item['symbol'] == 'FLMUSDT'), None)
# Determine precision for quantity (assuming 'quantityPrecision' is the relevant field)
quantity_precision = pair_info['quantityPrecision'] if pair_info else 3 # Default to 3 if pair info not found
# Fetch current price
flm_price = bot.futures_price(symbol="FLMUSDT")
# Desired amount in USDT
qtd_quote = 100.00
# Calculate the quantity of FLM, rounded to the determined precision
flm_quantity = round(qtd_quote / flm_price, quantity_precision)
# Place the order
bot.futures_create_order(symbol="FLMUSDT", side="BUY", type="MARKET", quantity=flm_quantity)
The field name (like 'quantityPrecision' in the example) might vary and should be verified against the Binance API documentation.