1

I have quite hard time to understand how to use this. I'm playing with testing account, and succeeded to "buy" xrp with my usdt like this: NOTE: I use binance, and my orders is based on quote price.

   params = {
        'quoteOrderQty': 20,
    }
    const order = await binance.createOrder('XRP/USDT', 'market', 'buy', null, null, params)
    order.push(order)

later, I tried to sell my xrp for usdt, by I keep getting precision error:

binance order amount should be evenly divisible by lot size

And I read that the amountToPrecision is the answet, but I didn't get yet how to use this.

I tried like this without any success:

params = {
    'quoteOrderQty': binance.amountToPrecision('XRP/USDT', 20),
}
const order = await binance.createOrder('XRP/USDT', 'market', 'sell', null, null, params)

Any ideas how can I solve this problem?

Masksway
  • 205
  • 3
  • 11

1 Answers1

1

I used this, passing amount and price on the signature of the createOrder method:

let formattedAmount = binance.amountToPrecision(symbol, amount);
let formattedPrice = binance.priceToPrecision(symbol, price);
let order = await binance.createOrder(symbol, type, side, formattedAmount, formattedPrice, params);
Stefano Liboni
  • 149
  • 2
  • 11
  • It doesn't work for me as it should. Given I want to buy ETH for $100 while ETH price is `1573.63`, I should have `0.06354733959062804` of ETH, instead it formats me to `0.06354` which at the end is worth of $99.9884502 instead of $100 as planned – aspirinemaga Sep 02 '22 at 22:49
  • The exchange doesnt allow you do go to that precision the functions provided in CCXT trucate to those limitations. – Nath Jun 08 '23 at 08:12