Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The last four digits of the excessively long orderId were incorrectly rounded. #360

Closed
0xfuckcode opened this issue Aug 17, 2023 · 2 comments

Comments

@0xfuckcode
Copy link

const { USDMClient, DefaultLogger} = require('binance');
const param = {
  symbol:'ETHUSDT',
  side:'SELL,
  quantity:1,
  type:'LIMIT',
  price:1850,
  timeInForce:'GTC'
}
const order = await client.submitNewOrder(param);
console.log(order);

The returned orderId should be a number like 8389765612825190229, but the current returned orderId has its last three digits rounded, resulting in 8389765612825190000.
The orderId for some trading pairs may exceed the maximum integer value that JavaScript's built-in Number type can accurately represent. It is necessary to use the string type or BigInt instead of the Number type.

https://github.com/tiagosiebler/binance/blob/6476fcf365f9c00325d2c070e71efe8a14703241/src/types/futures.ts#L407C19-L407C19

@tiagosiebler
Copy link
Owner

Totally agree this should be a string type. Unfortunately the JSON returned by binance's API is using a number type for this property.

There's no simple fix for the order ID value without pre-processing the JSON response before attempting to parse it into an object:
https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

The suggested workaround commonly used by others, is to instead use a custom order ID before sending the order, and using that for tracking instead - take a look at this thread:
#208 (comment)

@0xfuckcode
Copy link
Author

Using custom order ID can be a compromise solution. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants