huobi futures: fix client order id submit order (#876)

As per Huobi Futures documentation, client order id must be an
integer field in the request. For most other exchanges this is a string
field so to accomodate we keep the string representation and convert
to a number right before the request goes on the wire.
This commit is contained in:
Luis Rascão
2022-01-18 03:44:46 +00:00
committed by GitHub
parent 10d5986254
commit f2eca7a365

View File

@@ -716,7 +716,14 @@ func (h *HUOBI) FOrder(ctx context.Context, contractCode currency.Pair, symbol,
req["contract_code"] = codeValue
}
if clientOrderID != "" {
req["client_order_id"] = clientOrderID
// Client order id is an integer, convert it here
// https://huobiapi.github.io/docs/dm/v1/en/#place-an-order
id, err := strconv.Atoi(clientOrderID)
if err != nil {
return resp,
fmt.Errorf("unable to convert client order id to integer, %s: %w", clientOrderID, err)
}
req["client_order_id"] = id
}
req["direction"] = direction
if !common.StringDataCompareInsensitive(validOffsetTypes, offset) {