mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
kucoin: fix kucoin order query
This commit is contained in:
parent
1652c17e33
commit
6d5ab33d17
|
@ -106,7 +106,6 @@ var historyOrdersCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
|
||||
|
||||
// usage:
|
||||
// go run ./examples/kucoin orders place --symbol LTC-USDT --price 50 --size 1 --order-type limit --side buy
|
||||
var placeOrderCmd = &cobra.Command{
|
||||
|
|
|
@ -295,15 +295,24 @@ func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since,
|
|||
req := e.client.TradeService.NewListOrdersRequest()
|
||||
req.Symbol(toLocalSymbol(symbol))
|
||||
req.Status("done")
|
||||
req.EndAt(until)
|
||||
req.StartAt(since)
|
||||
|
||||
// kucoin:
|
||||
// When you query orders in active status, there is no time limit.
|
||||
// However, when you query orders in done status, the start and end time range cannot exceed 7* 24 hours.
|
||||
// An error will occur if the specified time window exceeds the range.
|
||||
// If you specify the end time only, the system will automatically calculate the start time as end time minus 7*24 hours, and vice versa.
|
||||
if until.Sub(since) < 7 * 24 * time.Hour {
|
||||
req.EndAt(until)
|
||||
} else {
|
||||
req.EndAt(since.Add(7 * 24 * time.Hour - time.Minute))
|
||||
}
|
||||
|
||||
orderList, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
return orders, err
|
||||
}
|
||||
|
||||
// TODO: support pagination (right now we can only get 50 items from the first page)
|
||||
for _, o := range orderList.Items {
|
||||
order := toGlobalOrder(o)
|
||||
orders = append(orders, order)
|
||||
|
|
|
@ -80,6 +80,11 @@ func (s *OrderService) Sync(ctx context.Context, exchange types.Exchange, symbol
|
|||
continue
|
||||
}
|
||||
|
||||
// skip canceled and not filled orders
|
||||
if order.Status == types.OrderStatusCanceled && order.ExecutedQuantity == 0.0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := s.Insert(order); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user