bbgo_origin/pkg/exchange/ftx/rest_order_request.go
2021-03-07 12:51:13 +08:00

31 lines
571 B
Go

package ftx
import (
"context"
"encoding/json"
"fmt"
)
type orderRequest struct {
*restRequest
}
func (r *orderRequest) OpenOrders(ctx context.Context, market string) (orders, error) {
resp, err := r.
Method("GET").
ReferenceURL("api/orders").
Payloads(map[string]interface{}{"market": market}).
DoAuthenticatedRequest(ctx)
if err != nil {
return orders{}, err
}
var o orders
if err := json.Unmarshal(resp.Body, &o); err != nil {
return orders{}, fmt.Errorf("failed to unmarshal open orders response body to json: %w", err)
}
return o, nil
}