-
Notifications
You must be signed in to change notification settings - Fork 38
/
api_linear_test.go
102 lines (93 loc) · 1.92 KB
/
api_linear_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
94
95
96
97
98
99
100
101
102
package rest
import (
"testing"
"time"
)
func TestLinear_GetOrderBook(t *testing.T) {
b := newByBit()
_, _, ob, err := b.GetOrderBook("BTCUSDT")
if err != nil {
t.Error(err)
return
}
for _, v := range ob.Asks {
t.Logf("Ask: %#v", v)
}
for _, v := range ob.Bids {
t.Logf("Bid: %#v", v)
}
t.Logf("%v", ob.Time)
}
func TestByBit_LinearGetKLine(t *testing.T) {
b := newByBit()
from := time.Now().Add(-1 * time.Hour).Unix()
_, _, ohlcs, err := b.LinearGetKLine("BTCUSDT", "1", from, 10)
if err != nil {
t.Error(err)
return
}
for _, v := range ohlcs {
t.Logf("%#v", v)
}
}
func TestByBit_LinearCreateOrder(t *testing.T) {
b := newByBit()
_, _, order, err := b.LinearCreateOrder("Buy", "Limit", 35000, 1, "GoodTillCancel", 0,
0, false, false, "", "BTCUSDT")
if err != nil {
t.Error(err)
return
}
t.Logf("%#v", order)
}
func TestByBit_LinearGetOrders(t *testing.T) {
b := newByBit()
_, _, orders, err := b.LinearGetOrders("BTCUSDT", "Created,New", 10, 0)
if err != nil {
t.Error(err)
return
}
t.Logf("%#v", orders.Data)
}
func TestByBit_LinearCancelOrder(t *testing.T) {
b := newByBit()
_, _, ret, err := b.LinearCancelOrder("d328974d-bfe8-484f-a0e9-30159bc78aaf", "", "BTCUSDT")
if err != nil {
t.Error(err)
return
}
t.Logf("%#v", ret)
}
func TestByBit_LinearCancelAllOrder(t *testing.T) {
b := newByBit()
_, _, ret, err := b.LinearCancelAllOrder("BTCUSDT")
if err != nil {
t.Error(err)
return
}
t.Logf("%#v", ret)
}
func TestByBit_LinearGetPositions(t *testing.T) {
b := newByBit()
_, _, ret, err := b.LinearGetPositions() // BTCUSDT
if err != nil {
t.Error(err)
return
}
// t.Logf("%#v", ret)
for _, v := range ret {
if !v.IsValid || v.Data.Size == 0 {
continue
}
t.Logf("%#v", v)
}
}
func TestByBit_LinearGetPosition(t *testing.T) {
b := newByBit()
_, _, ret, err := b.LinearGetPosition("BTCUSDT")
if err != nil {
t.Error(err)
return
}
t.Logf("%#v", ret)
}