Skip to content

Commit

Permalink
Okx: Fix FillTime not parsed for PendingOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Sep 10, 2023
1 parent 16eef29 commit 267802c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
36 changes: 11 additions & 25 deletions exchanges/okx/okx_type_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,35 +212,21 @@ func (a *OrderDetail) UnmarshalJSON(data []byte) error {
}

// UnmarshalJSON deserializes JSON, and timestamp information.
func (a *PendingOrderItem) UnmarshalJSON(data []byte) error {
func (o *PendingOrderItem) UnmarshalJSON(data []byte) error {
type Alias PendingOrderItem
chil := &struct {
a := &struct {
*Alias
Side string `json:"side"`
UpdateTime string `json:"uTime"`
CreationTime string `json:"cTime"`
UpdateTime okxUnixMilliTime `json:"uTime"`
CreationTime okxUnixMilliTime `json:"cTime"`
FillTime okxUnixMilliTime `json:"fillTime"`
}{
Alias: (*Alias)(a),
}
err := json.Unmarshal(data, chil)
if err != nil {
return err
}
uTime, err := strconv.ParseInt(chil.UpdateTime, 10, 64)
if err != nil {
return err
Alias: (*Alias)(o),
}
cTime, err := strconv.ParseInt(chil.CreationTime, 10, 64)
if err != nil {
return err
}
a.Side, err = order.StringToOrderSide(chil.Side)
if err != nil {
return err
}
a.CreationTime = time.UnixMilli(cTime)
a.UpdateTime = time.UnixMilli(uTime)
return nil
err := json.Unmarshal(data, a)
o.CreationTime = a.CreationTime.Time()
o.UpdateTime = a.UpdateTime.Time()
o.FillTime = a.FillTime.Time()
return err
}

// UnmarshalJSON deserializes JSON, and timestamp information.
Expand Down
2 changes: 1 addition & 1 deletion exchanges/okx/okx_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ type PendingOrderItem struct {
FeeCurrency string `json:"feeCcy"`
LastFilledPrice convert.StringToFloat64 `json:"fillPx"`
LastFilledSize convert.StringToFloat64 `json:"fillSz"`
FillTime string `json:"fillTime"`
FillTime time.Time `json:"fillTime"`
InstrumentID string `json:"instId"`
InstrumentType string `json:"instType"`
Leverage convert.StringToFloat64 `json:"lever"`
Expand Down

0 comments on commit 267802c

Please sign in to comment.