node-binance-api
node-binance-api copied to clipboard
roundTicks - accept string & numeric
Hello,
I am getting the following error.
TypeError: Cannot read property 'length' of undefined
at Object.roundTicks (/backend/node_modules/node-binance-api/node-binance-api.js:1550:75)
It occurs when the tickSize=1.00000000. I overcame this by modifying the roundTicks function in the following manner:
const roundTicks = (price, tickSize) => {
const formatter = new Intl.NumberFormat('en-US', { style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 8 })
const value = formatter.format(tickSize).split('.')[1]
const precision = value === undefined ? 0 : value.length
if (typeof price === 'string') price = parseFloat(price);
return price.toFixed(precision)
}
I hope this helps the community! Thank you for the API!
thank you for your contribution 👍
The problem is still relevant for tickSize = 1, but the code suggested above works