Home > Enterprise >  Place Binance Future Order using python-binance wrapper. Error: APIError(code=-1102): Mandatory para
Place Binance Future Order using python-binance wrapper. Error: APIError(code=-1102): Mandatory para

Time:12-13

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

CodePudding user response:

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

futures_create_order()

function.

CodePudding user response:

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)
  • Related