From f2eca7a3657317d1b35f7ac4f580e18fa0d5c9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Rasc=C3=A3o?= Date: Tue, 18 Jan 2022 03:44:46 +0000 Subject: [PATCH] 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. --- exchanges/huobi/huobi_futures.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exchanges/huobi/huobi_futures.go b/exchanges/huobi/huobi_futures.go index 1056199c..e9d5bc49 100644 --- a/exchanges/huobi/huobi_futures.go +++ b/exchanges/huobi/huobi_futures.go @@ -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) {