params error: Qty invalid (ErrCode: 10001) being returned by ByBit API

1.3k Views Asked by At

Order details being submitted:

order_id=None 
symbol='BTCUSDT' 
order_type='Limit' 
side='Buy' price=26050.0 
qty=0.002876 
take_profit=26080.0 
stop_loss=26040.0 
time_in_force='GTC' 
reduce_only=None 
leverage=2 
percentage=100

Results in an error being returned as follows:

params error: Qty invalid (ErrCode: 10001) (ErrTime: 13:43:23).
Request → POST https://api.bybit.com/v5/order/create: {"category": "linear", "symbol": "BTCUSDT", "side": "Buy", "orderType": "Limit", "qty": "0.002876", "price": "26050.0", "timeInForce": "GTC", "reduceOnly": false, "closeOnTrigger": false, "takeProfit": "26080.0", "tpTriggerBy": "LastPrice", "stopLoss": "26040.0", "slTriggerBy": "LastPrice", "positionIdx": 0}.
    INFO:     84.194.82.153:52266 - "POST /bybit/futures/order/limit HTTP/1.1" 500 Internal Server Error

All of a sudden there is a qty issue, but everything seems filled in fine ...

Checked everything, manually put the order on ByBit and it works, but on API there seems to be an issue with the qty value

1

There are 1 best solutions below

0
On

The problem you are having here is related to the quantity step value which is a property of the instrument pair that you are trying to buy (BTCUSDT in this case).

If you query the instrument details for BTCUSDT using the endoint "/v5/market/instruments-info" of the ByBit V5 API (ByBit API documentation for "Get Instrument Info"), you can see the "qtyStep" value returned for this pair is "0.001".

In your case, you are trying to place an order with "qty=0.002876". As you can see, this does not fit the quantity step value set by the API. To fix this, you need to reformat the quantity you are trying to buy to comply.

So you would need to either round the quantity up or down. In your case for example, if you want to round the quantity up to comply, your "qty" value should be: "0.003", or if you want to round down to comply, your "qty" value should be "0.002".

Both of these values would comply with the qtyStep requirement, and will allow your order to be placed (as long as all of the other values are correct and compliant).