pkg/exchange: remove the query after place order

This commit is contained in:
edwin 2024-03-13 14:54:29 +08:00
parent 8197dbd63a
commit 2904759113

View File

@ -260,6 +260,7 @@ func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (*t
orderReq.ClientOrderID(order.ClientOrderID) orderReq.ClientOrderID(order.ClientOrderID)
} }
timeNow := time.Now()
orders, err := orderReq.Do(ctx) orders, err := orderReq.Do(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
@ -269,16 +270,21 @@ func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (*t
return nil, fmt.Errorf("unexpected length of order response: %v", orders) return nil, fmt.Errorf("unexpected length of order response: %v", orders)
} }
orderRes, err := e.QueryOrder(ctx, types.OrderQuery{ orderID, err := strconv.ParseUint(orders[0].OrderID, 10, 64)
Symbol: order.Symbol,
OrderID: orders[0].OrderID,
ClientOrderID: orders[0].ClientOrderID,
})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to query order by id: %s, clientOrderId: %s, err: %w", orders[0].OrderID, orders[0].ClientOrderID, err) return nil, fmt.Errorf("failed to parse response order id: %w", err)
} }
return orderRes, nil return &types.Order{
SubmitOrder: order,
Exchange: types.ExchangeOKEx,
OrderID: orderID,
Status: types.OrderStatusNew,
ExecutedQuantity: fixedpoint.Zero,
IsWorking: true,
CreationTime: types.Time(timeNow),
UpdateTime: types.Time(timeNow),
}, nil
// TODO: move this to batch place orders interface // TODO: move this to batch place orders interface
/* /*