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