* rounds number with given step * @param {float} qty - quantity to round * @param {float} stepSize - stepSize as specified by exchangeInfo * @return {float} - number
(qty, stepSize)
| 3569 | * @return {float} - number |
| 3570 | */ |
| 3571 | roundStep(qty, stepSize) { |
| 3572 | // Integers do not require rounding |
| 3573 | if (Number.isInteger(qty)) return qty; |
| 3574 | const qtyString = parseFloat(qty).toFixed(16); |
| 3575 | const desiredDecimals = Math.max(stepSize.indexOf('1') - 1, 0); |
| 3576 | const decimalIndex = qtyString.indexOf('.'); |
| 3577 | return parseFloat(qtyString.slice(0, decimalIndex + desiredDecimals + 1)); |
| 3578 | } |
| 3579 | |
| 3580 | /** |
| 3581 | * rounds price to required precision |