bbgo_origin/pkg/exchange/ftx/rest_order_request.go

32 lines
691 B
Go
Raw Normal View History

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