mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
improve max exchange order query api
This commit is contained in:
parent
12dbab95a7
commit
35f75c7d12
|
@ -16,6 +16,17 @@ const (
|
||||||
Closed
|
Closed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type OrderState string
|
||||||
|
|
||||||
|
const (
|
||||||
|
OrderStateDone = OrderState("done")
|
||||||
|
OrderStateCancel = OrderState("cancel")
|
||||||
|
OrderStateWait = OrderState("wait")
|
||||||
|
OrderStateConvert = OrderState("convert")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
type OrderType string
|
type OrderType string
|
||||||
|
|
||||||
// Order types that the API can return.
|
// Order types that the API can return.
|
||||||
|
@ -50,19 +61,7 @@ type Order struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// All returns all orders for the authenticated account.
|
// All returns all orders for the authenticated account.
|
||||||
func (s *OrderService) All(market string, limit, page int, state OrderStateToQuery) ([]Order, error) {
|
func (s *OrderService) All(market string, limit, page int, states ...OrderState) ([]Order, error) {
|
||||||
var states []string
|
|
||||||
switch state {
|
|
||||||
case All:
|
|
||||||
states = []string{"done", "cancel", "wait", "convert"}
|
|
||||||
case Active:
|
|
||||||
states = []string{"wait", "convert"}
|
|
||||||
case Closed:
|
|
||||||
states = []string{"done", "cancel"}
|
|
||||||
default:
|
|
||||||
states = []string{"wait", "convert"}
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := map[string]interface{}{
|
payload := map[string]interface{}{
|
||||||
"market": market,
|
"market": market,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
|
@ -70,6 +69,7 @@ func (s *OrderService) All(market string, limit, page int, state OrderStateToQue
|
||||||
"state": states,
|
"state": states,
|
||||||
"order_by": "desc",
|
"order_by": "desc",
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := s.client.newAuthenticatedRequest("GET", "v2/orders", payload)
|
req, err := s.client.newAuthenticatedRequest("GET", "v2/orders", payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -204,6 +204,14 @@ func (c *RestClient) newAuthenticatedRequest(m string, refURL string, data inter
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(c.APIKey) == 0 {
|
||||||
|
return nil, errors.New("empty api key")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.APISecret) == 0 {
|
||||||
|
return nil, errors.New("empty api secret")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
req, err := c.newRequest(m, refURL, nil, p)
|
req, err := c.newRequest(m, refURL, nil, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user