Igosuki / binance-rs-async

Async client for the Binance APIs
https://crates.io/crates/binance-rs-async
Other
171 stars 113 forks source link

Change order_id to String for MarginOrderCancellation #96

Closed noahbclarkson closed 5 months ago

noahbclarkson commented 12 months ago

Change order_id to String for MarginOrderCancellation and MarginOrderCacellationResult because the API returns a String.

When cancelling a Margin order the API will return:

error decoding response body: invalid type: string "xxxxxxxxxx", expected u64 at line 1 column 23

Effectively, this is because the MarginOrderCancellation and MarginOrderCancellationResult structs have their order_id set to a u64 instead of a string when the API returns a string. It could also be possible to parse the String into a u64 because the default order ID is always a valid u64. However, users can pass a custom order_id into an order that can't be parsed into a u64 which suggests that this value should really be a String. Do what you will with this, but I'll be using this version of binance-rs-async until this is fixed.

noahbclarkson commented 12 months ago

On further testing it seems that on cancelling the order, the order_id is a String and on creating a new one the order_id is a u64. We will probably need to parse the order id from a u64 to a string or vice versa.

Igosuki commented 5 months ago

It only really matters for results, and so as to not disrupt existing code I added an optional serde https://github.com/Igosuki/binance-rs-async/commit/b21701344d93bf89fcdd2ad968f59ef8413548a4