1

I create future order with mandatory parameters

import datetime
from binance.client import Client

client = Client(API_KEY, API_SECRET)
timestamp = datetime.datetime.now().timestamp()

trade = client.futures_create_order(symbol='BTCUSDT', type='LIMIT', timeInForce='GTC', price=48000, side='BUY', quantity=0.00005, timestamp=timestamp )

This code gives error:

binance.exceptions.BinanceAPIException: APIError(code=-1102): Mandatory parameter '5e-05' was not sent, was empty/null, or malformed.

Binance-Doc link: https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

apaderno
  • 28,547
  • 16
  • 75
  • 90
Kusal Thiwanka
  • 151
  • 1
  • 4

2 Answers2

1

My problem was I'm not setting my price and quantity to a supported precision value. So 1st I get the price precision and quantity precision data and then convert my price and quantity according to that precision

symbol = 'FTMUSDT'
price = 1.38
quantity = 4.5

for info in info['symbols']:
    if info['pair'] == symbol:
        pricePrecision = info['pricePrecision']
        quantityPrecision = info['quantityPrecision']

final_price = "{:0.0{}f}".format(price, pricePrecision)
final_quantity = "{:0.0{}f}".format(quantity, quantityPrecision)
Kusal Thiwanka
  • 151
  • 1
  • 4
0

Maybe you should try "LONG" instead of "BUY" at the parameters of

futures_create_order()

function.

mervfar
  • 1
  • 1
  • nope. parameter 'side' must be "BUY" or "SELL". 'positionSide' should be "BOTH", "LONG", "SHORT". But for future LIMIT order we don't need to pass 'positionSide'. It has a default value ("BOTH") – Kusal Thiwanka Dec 13 '21 at 03:37