This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
fill_test.go
93 lines (86 loc) · 2.04 KB
/
fill_test.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
92
93
package kumex
import (
"testing"
)
func TestApiService_Fills(t *testing.T) {
s := NewApiServiceFromEnv()
p := &PaginationParam{CurrentPage: 1, PageSize: 10}
rsp, err := s.Fills(map[string]string{}, p)
if err != nil {
t.Fatal(err)
}
fs := FillsModel{}
if _, err := rsp.ReadPaginationData(&fs); err != nil {
t.Fatal(err)
}
for _, f := range fs {
t.Log(ToJsonString(f))
switch {
case f.Symbol == "":
t.Error("Empty key 'symbol'")
case f.TradeId == "":
t.Error("Empty key 'tradeId'")
case f.OrderId == "":
t.Error("Empty key 'orderId'")
case f.Side == "":
t.Error("Empty key 'side'")
case f.SettleCurrency == "":
t.Error("Empty key 'settleCurrency'")
case f.TradeTime == 0:
t.Error("Empty key 'tradeTime'")
}
}
}
func TestApiService_RecentFills(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.RecentFills()
if err != nil {
t.Fatal(err)
}
fs := FillsModel{}
if err := rsp.ReadData(&fs); err != nil {
t.Fatal(err)
}
for _, f := range fs {
t.Log(ToJsonString(f))
switch {
case f.Symbol == "":
t.Error("Empty key 'symbol'")
case f.TradeId == "":
t.Error("Empty key 'tradeId'")
case f.OrderId == "":
t.Error("Empty key 'orderId'")
case f.Side == "":
t.Error("Empty key 'side'")
case f.SettleCurrency == "":
t.Error("Empty key 'settleCurrency'")
case f.TradeTime == 0:
t.Error("Empty key 'tradeTime'")
}
}
}
func TestApiService_OpenOrderStatistics(t *testing.T) {
t.SkipNow()
s := NewApiServiceFromEnv()
rsp, err := s.OpenOrderStatistics("XBTUSDM")
if err != nil {
t.Fatal(err)
}
o := &OpenOrderStatisticsModel{}
if err := rsp.ReadData(o); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(o))
switch {
case o.OpenOrderBuySize < 0:
t.Error("Empty key 'OpenOrderBuySize'")
case o.OpenOrderSellSize < 0:
t.Error("Empty key 'OpenOrderSellSize'")
case o.OpenOrderBuyCost == "":
t.Error("Empty key 'OpenOrderBuyCost'")
case o.OpenOrderSellCost == "":
t.Error("Empty key 'OpenOrderSellCost'")
case o.SettleCurrency == "":
t.Error("Empty key 'SettleCurrency'")
}
}