mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
kucoin: implement QueryClosedOrders
This commit is contained in:
parent
0cef2c52ef
commit
8c03147ff4
|
@ -134,8 +134,9 @@ func toGlobalOrderStatus(o kucoinapi.Order) types.OrderStatus {
|
||||||
var status types.OrderStatus
|
var status types.OrderStatus
|
||||||
if o.IsActive {
|
if o.IsActive {
|
||||||
status = types.OrderStatusNew
|
status = types.OrderStatusNew
|
||||||
} else if o.DealSize > 0 {
|
if o.DealSize > 0 {
|
||||||
status = types.OrderStatusPartiallyFilled
|
status = types.OrderStatusPartiallyFilled
|
||||||
|
}
|
||||||
} else if o.CancelExist {
|
} else if o.CancelExist {
|
||||||
status = types.OrderStatusCanceled
|
status = types.OrderStatusCanceled
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,6 +27,7 @@ type Exchange struct {
|
||||||
client *kucoinapi.RestClient
|
client *kucoinapi.RestClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func New(key, secret, passphrase string) *Exchange {
|
func New(key, secret, passphrase string) *Exchange {
|
||||||
client := kucoinapi.NewClient()
|
client := kucoinapi.NewClient()
|
||||||
|
|
||||||
|
@ -225,6 +226,32 @@ func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders [
|
||||||
return orders, err
|
return orders, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err error) {
|
||||||
|
req := e.client.TradeService.NewListOrdersRequest()
|
||||||
|
req.Symbol(toLocalSymbol(symbol))
|
||||||
|
req.Status("done")
|
||||||
|
req.EndAt(until)
|
||||||
|
req.StartAt(since)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
return orders, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) ([]types.Trade, error) {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (errs error) {
|
func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (errs error) {
|
||||||
for _, o := range orders {
|
for _, o := range orders {
|
||||||
req := e.client.TradeService.NewCancelOrderRequest()
|
req := e.client.TradeService.NewCancelOrderRequest()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user