-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistoricalTrade.go
68 lines (53 loc) · 1.39 KB
/
HistoricalTrade.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
package wazirx_client
import (
"context"
"encoding/json"
"net/http"
helpers "github.com/yuvan11/wazirx-go/wazirx-client/Helpers"
api "github.com/yuvan11/wazirx-go/wazirx-client/endpoints"
)
type HistoricalTrades struct {
ID int64 `json:"id"`
IsBuyerMaker bool `json:"isBuyerMaker"`
Price string `json:"price"`
Quantity string `json:"qty"`
QuoteQuantity string `json:"quoteQty"`
Time int64 `json:"time"`
}
type HistoricalTradesService struct {
C *Client
Symbol string
Limit int32
}
func (s *HistoricalTradesService) SetSymbol(symbol string) *HistoricalTradesService {
s.Symbol = symbol
return s
}
func (s *HistoricalTradesService) SetLimit(limit int32) *HistoricalTradesService {
s.Limit = limit
return s
}
func (s *HistoricalTradesService) DisplayHistoricalTrade(ctx context.Context) (*[]HistoricalTrades, error) {
r := &Request{
Method: http.MethodGet,
Endpoint: api.HISTORICAL_TRADES,
SecType: SecTypeSigned,
RecvWindow: 10000,
TimeStamp: helpers.CurrentTimestamp(),
}
if s.Limit > 0 {
r.SetParam("limit", s.Limit)
}
if s.Symbol != "" {
r.SetParam("symbol", s.Symbol)
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
return &[]HistoricalTrades{}, err
}
result := new([]HistoricalTrades)
if err := json.Unmarshal(data, &result); err != nil {
return &[]HistoricalTrades{}, err
}
return result, nil
}