forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_trade.go
77 lines (69 loc) · 2 KB
/
convert_trade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package binance
import (
"context"
"net/http"
)
type ConvertTradeHistoryService struct {
c *Client
startTime int64
endTime int64
limit *int32
}
// StartTime set startTime
func (s *ConvertTradeHistoryService) StartTime(startTime int64) *ConvertTradeHistoryService {
s.startTime = startTime
return s
}
// EndTime set endTime
func (s *ConvertTradeHistoryService) EndTime(endTime int64) *ConvertTradeHistoryService {
s.endTime = endTime
return s
}
// Limit set limit
func (s *ConvertTradeHistoryService) Limit(limit int32) *ConvertTradeHistoryService {
s.limit = &limit
return s
}
// Do send request
func (s *ConvertTradeHistoryService) Do(ctx context.Context, opts ...RequestOption) (*ConvertTradeHistory, error) {
r := &request{
method: http.MethodGet,
endpoint: "/sapi/v1/convert/tradeFlow",
secType: secTypeSigned,
}
r.setParam("startTime", s.startTime)
r.setParam("endTime", s.endTime)
if s.limit != nil {
r.setParam("limit", *s.limit)
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res := ConvertTradeHistory{}
if err = json.Unmarshal(data, &res); err != nil {
return nil, err
}
return &res, nil
}
// ConvertTradeHistory define the convert trade history
type ConvertTradeHistory struct {
List []ConvertTradeHistoryItem `json:"list"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
Limit int32 `json:"limit"`
MoreData bool `json:"moreData"`
}
// ConvertTradeHistoryItem define a convert trade history item
type ConvertTradeHistoryItem struct {
QuoteId string `json:"quoteId"`
OrderId int64 `json:"orderId"`
OrderStatus string `json:"orderStatus"`
FromAsset string `json:"fromAsset"`
FromAmount string `json:"fromAmount"`
ToAsset string `json:"toAsset"`
ToAmount string `json:"toAmount"`
Ratio string `json:"ratio"`
InverseRatio string `json:"inverseRatio"`
CreateTime int64 `json:"createTime"`
}