mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
ftx: define ordersHistory in rest client
This commit is contained in:
parent
28b5a14b5e
commit
54ca62ac5c
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type orderRequest struct {
|
||||
|
@ -114,3 +115,34 @@ func (r *orderRequest) OpenOrders(ctx context.Context, market string) (ordersRes
|
|||
|
||||
return o, nil
|
||||
}
|
||||
|
||||
func (r *orderRequest) OrdersHistory(ctx context.Context, market string, start, end time.Time, limit int) (ordersHistoryResponse, error) {
|
||||
p := map[string]interface{}{
|
||||
"market": market,
|
||||
"limit": limit,
|
||||
}
|
||||
|
||||
if start != (time.Time{}) {
|
||||
p["start_time"] = start.UnixNano() / int64(time.Second)
|
||||
}
|
||||
if end != (time.Time{}) {
|
||||
p["end_time"] = start.UnixNano() / int64(time.Second)
|
||||
}
|
||||
|
||||
resp, err := r.
|
||||
Method("GET").
|
||||
ReferenceURL("api/orders/history").
|
||||
Payloads(p).
|
||||
DoAuthenticatedRequest(ctx)
|
||||
|
||||
if err != nil {
|
||||
return ordersHistoryResponse{}, err
|
||||
}
|
||||
|
||||
var o ordersHistoryResponse
|
||||
if err := json.Unmarshal(resp.Body, &o); err != nil {
|
||||
return ordersHistoryResponse{}, fmt.Errorf("failed to unmarshal orders history response body to json: %w", err)
|
||||
}
|
||||
|
||||
return o, nil
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ type balances struct {
|
|||
} `json:"result"`
|
||||
}
|
||||
|
||||
type ordersHistoryResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Result []order `json:"result"`
|
||||
HasMoreData bool `json:"hasMoreData"`
|
||||
}
|
||||
|
||||
type ordersResponse struct {
|
||||
Success bool `json:"success"`
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user