mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-15 23:16:48 +00:00
OKX: Fix GetActiveOrders bug and remove redundant json.Unmarshal call (#1176)
* Fix GetActiveOrders bug and remove redundant json.unmarshal call. * @thrasher- eagle eye nits --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user