mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
Merge pull request #1147 from c9s/max/get-order/client-order-id
FEATURE: max get-order v3 api support client order id parameter
This commit is contained in:
commit
99e393e93c
|
@ -210,16 +210,30 @@ func (e *Exchange) QueryOrderTrades(ctx context.Context, q types.OrderQuery) ([]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error) {
|
func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error) {
|
||||||
if q.OrderID == "" {
|
if len(q.OrderID) == 0 && len(q.ClientOrderID) == 0 {
|
||||||
return nil, errors.New("max.QueryOrder: OrderID is required parameter")
|
return nil, errors.New("max.QueryOrder: one of OrderID/ClientOrderID is required parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
orderID, err := strconv.ParseInt(q.OrderID, 10, 64)
|
if len(q.OrderID) != 0 && len(q.ClientOrderID) != 0 {
|
||||||
if err != nil {
|
return nil, errors.New("max.QueryOrder: only accept one parameter of OrderID/ClientOrderID")
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maxOrder, err := e.v3order.NewGetOrderRequest().Id(uint64(orderID)).Do(ctx)
|
request := e.v3order.NewGetOrderRequest()
|
||||||
|
|
||||||
|
if len(q.OrderID) != 0 {
|
||||||
|
orderID, err := strconv.ParseInt(q.OrderID, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
request.Id(uint64(orderID))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(q.ClientOrderID) != 0 {
|
||||||
|
request.ClientOrderID(q.ClientOrderID)
|
||||||
|
}
|
||||||
|
|
||||||
|
maxOrder, err := request.Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user