diff --git a/exchanges/okx/okx.go b/exchanges/okx/okx.go index af87f2d8..1c16640d 100644 --- a/exchanges/okx/okx.go +++ b/exchanges/okx/okx.go @@ -4200,7 +4200,13 @@ func (ok *Okx) SendHTTPRequest(ctx context.Context, ep exchange.URL, f request.E if err != nil { return err } - var intermediary json.RawMessage + resp := struct { + Code string `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` + }{ + Data: result, + } newRequest := func() (*request.Item, error) { utcTime := time.Now().UTC().Format(time.RFC3339) payload := []byte("") @@ -4238,7 +4244,7 @@ func (ok *Okx) SendHTTPRequest(ctx context.Context, ep exchange.URL, f request.E Path: path, Headers: headers, Body: bytes.NewBuffer(payload), - Result: &intermediary, + Result: &resp, AuthRequest: authenticated, Verbose: ok.Verbose, HTTPDebugging: ok.HTTPDebugging, @@ -4249,21 +4255,10 @@ func (ok *Okx) SendHTTPRequest(ctx context.Context, ep exchange.URL, f request.E if err != nil { return err } - type errCap struct { - Code string `json:"code"` - Msg string `json:"msg"` - Data interface{} `json:"data"` - } - var errMessage errCap - errMessage.Data = result - err = json.Unmarshal(intermediary, &errMessage) - if err != nil { - return err - } - code, err := strconv.ParseInt(errMessage.Code, 10, 64) + code, err := strconv.ParseInt(resp.Code, 10, 64) if err == nil && code != 0 { - if errMessage.Msg != "" { - return fmt.Errorf(" error code: %d message: %s", code, errMessage.Msg) + if resp.Msg != "" { + return fmt.Errorf("error code: %d message: %s", code, resp.Msg) } err, okay := ErrorCodes[strconv.FormatInt(code, 10)] if okay { diff --git a/exchanges/okx/okx_types.go b/exchanges/okx/okx_types.go index 2f14c001..75be135c 100644 --- a/exchanges/okx/okx_types.go +++ b/exchanges/okx/okx_types.go @@ -671,7 +671,7 @@ type OrderDetail struct { Category string `json:"category"` // normal, twap, adl, full_liquidation, partial_liquidation, delivery, ddh AccumulatedFillSize okxNumericalValue `json:"accFillSz"` FillPrice okxNumericalValue `json:"fillPx"` - FillSize float64 `json:"fillSz"` + FillSize okxNumericalValue `json:"fillSz"` RebateAmount okxNumericalValue `json:"rebate"` FeeCurrency string `json:"feeCcy"` TransactionFee okxNumericalValue `json:"fee"` diff --git a/exchanges/okx/okx_wrapper.go b/exchanges/okx/okx_wrapper.go index 80d81950..445cfc05 100644 --- a/exchanges/okx/okx_wrapper.go +++ b/exchanges/okx/okx_wrapper.go @@ -1224,8 +1224,8 @@ allOrders: Amount: orderList[i].Size.Float64(), Pair: pair, Price: orderList[i].Price.Float64(), - ExecutedAmount: orderList[i].FillSize, - RemainingAmount: orderList[i].Size.Float64() - orderList[i].FillSize, + ExecutedAmount: orderList[i].FillSize.Float64(), + RemainingAmount: orderList[i].Size.Float64() - orderList[i].FillSize.Float64(), Fee: orderList[i].TransactionFee.Float64(), FeeAsset: currency.NewCode(orderList[i].FeeCurrency), Exchange: ok.Name,