 # precision vs scale for "quantityPrecision"

I have the following example:

``````  "symbol": "ETHBTC",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quoteAssetPrecision": 8,
"lotSizeFilter": {
"filterType":	"LOT_SIZE",
"minQuantity": "0.00100000",
"maxQuantity": "100000.00000000",
"stepSize": "0.00100000"
}
``````

When placing an order and setting the quantity for the order, I must set the correct precision for that quantity (to avoid a LOT_SIZE_FILTER error). In compare to baseAssetPrecision and quoteAssetPrecision, I do not have a property called quantityPrecision, so I must derive the precision by the a number from “lotSizeFilter”. Am I right? If so, which number should I take? Which precision is right?

``````stepSize: "0.00100000" has precision = 1
stepSize: "0.00100000" has scale = 3

maxQuantity: "100000.00000000" has precision = 7
maxQuantity: "100000.00000000" has scale = 1``````

Hi. When it comes to quantity related term, you have to look at the base asset. On the other hand, if it’s quote quantity related, please refer to quote asset. (/fapi/v1/exchangeInfo has quantityPrecision provided but /api/v3/exchangeInfo does not.)
Regarding the lot size precision, both baseAssetPrecision and stepSize have to be taken into account, whichever is stricter and less flexible.
For example, given baseAssetPrecision = 8, stepSize = 0.00100000, minQuantity = 0.00100000, maxQuantity = 100000.00000000
The allowed quantity, q, satisfies

• 0.00100000 <= q <= 100000.00000000
• q = 0.00100000 + n * 0.00100000, n can be any non-negative integer

@ishuen Please explain by the following example:

``````"symbol": "BNBBTC",
"baseAsset": "BNB",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quoteAssetPrecision": 8,
"lotSizeFilter": {
"filterType":	"LOT_SIZE",
"minQuantity": "0.01000000",
"maxQuantity": "100000.00000000",
"stepSize": "0.01000000"
}
``````

I have “BNBBTC”. I want to make a buy order:

I have 1 BTC and want to buy x BNB with 1 BTC. The actual ask price for BNB is 0.01129063BTC.

The calculation:

`Buy-Quantity of BNB = 1 BTC / 0.01129063 BTC = 88.56901696362382`

So I can buy 88.56901696362382 shares of BNB for 1 BTC.
However, I must round this value to a precision eligable for Binance.

Before doing so, here are the mathematical definitions for precision and scale:

• precision: total number of significant digits
• scale: number of digits to the right of the decimal point

I suppose that I have to round to 3 digits (because stepSize has a scale of 3 even if its precision is 1), so the eligable quantity is:

`88.56901696362382 => 88.569`

The questions:

1. Am I right with the assumption, that Binance does not distinct between precision and scale?

2. Which general formula must I take to get the quantity always with the right precision and scale?

3. Maybe it would be good to enhance /api/x/exchangeInfo with “quantityPrecision”-property to make it easier for the user. Are there any plans for this?

1. The definition of precision here is actually the scale. It represents the digit at the right of the decimal point.
2. This equation should be good enough to determine the quantity.
`quantity = minQuantity + n * stepSize <= maxQuantity` , n can be any non-negative integer
3. Thanks for your feedback, we already share the info about the confusion over the step size and precision to the team. It’s still under discussion.

@ishuen Thanks. I have a question related to the formula:

`quantity = minQuantity + n * stepSize <= maxQuantity , n can be any non-negative integer`

I want to buy x shares of BNB with 1BTC. The BNB ask price is 0.01129063 BTC (for one share BNB). How can I use the above formula to calculate the buy quantity for BNB?

`quantity = 0.01000000 + N * 0.01000000`, what is N in my case?

First of all, the size of N is related to your budget (quote quantity) per order.
In this example, the quoteQty = 1 BTC and the BNB price is 0.01129063 BTC.
So we have to first know how many BNB is allowed to buy.
1 (BTC, quoteQty) = quantity * 0.01129063 (price)
quantity = 88.56901696 --> This is not a valid number as it breaks the filter rule. We have to find out the acceptable number close to 88.56901696.
quantity = 0.01000000 + N * 0.01000000 <= 88.56901696.
N = (88.56901696 - 0.01000000) / 0.01000000 = 8855.90169636 => 8855
Hence, the quantity we can specify is 0.01000000 + 8855 * 0.01000000 = 88.56

1 Like