MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / roundStep

Method roundStep

src/node-binance-api.ts:3571–3578  ·  view source on GitHub ↗

* rounds number with given step * @param {float} qty - quantity to round * @param {float} stepSize - stepSize as specified by exchangeInfo * @return {float} - number

(qty, stepSize)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

maxMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected