Closed BrandonDR closed 1 year ago
I found a work around, by converting it to a string myself
function convertDecimalToString(decimal) {
// Convert the decimal value to a string with 20 decimal places
let str = decimal.toFixed(20);
// Remove trailing zeros
str = str.replace(/0+$/, '');
// Remove the decimal point if there are no decimal places remaining
if (str.charAt(str.length - 1) === '.') {
str = str.slice(0, -1);
}
return str;
}
await client.newOrder("RVNBTC", 'SELL', 'LIMIT', {
price: convertDecimalToString(0.0000008),
quantity: 200,
timeInForce: 'GTC'
}).catch(err => {
console.error(err);
throw err;
});
Thanks for the feedback, for now it's recommended to provide the price as string:
await client.newOrder("RVNBTC", 'SELL', 'LIMIT', {
price: '0.0000008',
quantity: 200,
timeInForce: 'GTC'
}).catch(err => {
console.error(err);
throw err;
});
Issue subject
When trying to sell RVN to BTC, I am getting a 400 error from the API.
Because the
price
is validated on the endpoint with this rule: "Illegal characters found in parameter 'price'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'." The floating point / scientific notion of "8e-7" is not valid.Expected behaviour
The
price
must not be shortened and remain in long form, price=0.0000008.Actual behaviour
This POST request is made instead, price=8e-7.
Steps to reproduce
Make a newOrder with a very small
price
.Environment
(I wonder if v3 rc would not have this issue?)