This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
forked from adshao/go-binance
/
income_history.go
91 lines (81 loc) · 2.04 KB
/
income_history.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package futures
import (
"context"
"encoding/json"
)
// GetIncomeHistoryService get position margin history service
type GetIncomeHistoryService struct {
c *Client
symbol string
incomeType string
startTime *int64
endTime *int64
limit *int64
}
// Symbol set symbol
func (s *GetIncomeHistoryService) Symbol(symbol string) *GetIncomeHistoryService {
s.symbol = symbol
return s
}
// IncomeType set income type
func (s *GetIncomeHistoryService) IncomeType(incomeType string) *GetIncomeHistoryService {
s.incomeType = incomeType
return s
}
// StartTime set startTime
func (s *GetIncomeHistoryService) StartTime(startTime int64) *GetIncomeHistoryService {
s.startTime = &startTime
return s
}
// EndTime set endTime
func (s *GetIncomeHistoryService) EndTime(endTime int64) *GetIncomeHistoryService {
s.endTime = &endTime
return s
}
// Limit set limit
func (s *GetIncomeHistoryService) Limit(limit int64) *GetIncomeHistoryService {
s.limit = &limit
return s
}
// Do send request
func (s *GetIncomeHistoryService) Do(ctx context.Context, opts ...RequestOption) (res []*IncomeHistory, err error) {
r := &request{
method: "GET",
endpoint: "/fapi/v1/income",
secType: secTypeSigned,
}
r.setParam("symbol", s.symbol)
if s.incomeType != "" {
r.setParam("incomeType", s.incomeType)
}
if s.startTime != nil {
r.setParam("startTime", *s.startTime)
}
if s.endTime != nil {
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 = make([]*IncomeHistory, 0)
err = json.Unmarshal(data, &res)
if err != nil {
return nil, err
}
return res, nil
}
// IncomeHistory define position margin history info
type IncomeHistory struct {
Asset string `json:"asset"`
Income string `json:"income"`
IncomeType string `json:"incomeType"`
Info string `json:"info"`
Symbol string `json:"symbol"`
Time int64 `json:"time"`
TranID int64 `json:"tranId"`
TradeID string `json:"tradeId"`
}