forked from nntaoli-project/goex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinance_test.go
95 lines (78 loc) · 2.2 KB
/
Binance_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
package binance
import (
"fmt"
"github.com/nntaoli-project/goex"
"net/http"
"testing"
"time"
)
var ba = NewWithConfig(
&goex.APIConfig{
HttpClient: http.DefaultClient,
Endpoint: "https://api.binancezh.pro",
})
func TestBinance_GetTicker(t *testing.T) {
ticker, err := ba.GetTicker(goex.NewCurrencyPair2("USDT_USD"))
t.Log(ticker, err)
}
func TestBinance_LimitBuy(t *testing.T) {
order, err := ba.LimitBuy("3", "68.5", goex.LTC_USDT)
t.Log(order, err)
}
func TestBinance_LimitSell(t *testing.T) {
order, err := ba.LimitSell("1", "90", goex.LTC_USDT)
t.Log(order, err)
}
func TestBinance_CancelOrder(t *testing.T) {
r, er := ba.CancelOrder("3848718241", goex.BTC_USDT)
if !r {
t.Log((er.(goex.ApiError)).ErrCode)
}
}
func TestBinance_GetOneOrder(t *testing.T) {
odr, err := ba.GetOneOrder("3874087228", goex.BTC_USDT)
t.Log(err, odr)
}
func TestBinance_GetDepth(t *testing.T) {
//return
dep, err := ba.GetDepth(5, goex.NewCurrencyPair2("BTC_USDT"))
t.Log(err)
if err == nil {
t.Log(dep.AskList)
t.Log(dep.BidList)
}
}
func TestBinance_GetAccount(t *testing.T) {
account, err := ba.GetAccount()
t.Log(err, account)
}
func TestBinance_GetUnfinishOrders(t *testing.T) {
orders, err := ba.GetUnfinishOrders(goex.NewCurrencyPair2("BTC_USDT"))
t.Log(orders, err)
}
func TestBinance_GetKlineRecords(t *testing.T) {
startTime := time.Now().Add(-24*time.Hour).Unix() * 1000
endTime := time.Now().Add(-5*time.Hour).Unix() * 1000
kline, _ := ba.GetKlineRecords(goex.ETH_BTC, goex.KLINE_PERIOD_5MIN, 100,
goex.OptionalParameter{}.Optional("startTime", fmt.Sprint(startTime)).Optional("endTime", fmt.Sprint(endTime)))
for _, k := range kline {
tt := time.Unix(k.Timestamp, 0)
t.Log(tt, k.Open, k.Close, k.High, k.Low, k.Vol)
}
}
func TestBinance_GetTrades(t *testing.T) {
t.Log(ba.GetTrades(goex.BTC_USDT, 0))
}
func TestBinance_GetTradeSymbols(t *testing.T) {
t.Log(ba.GetTradeSymbol(goex.BTC_USDT))
}
func TestBinance_SetTimeOffset(t *testing.T) {
t.Log(ba.setTimeOffset())
t.Log(ba.timeOffset)
}
func TestBinance_GetOrderHistorys(t *testing.T) {
t.Log(ba.GetOrderHistorys(goex.BTC_USDT,
goex.OptionalParameter{}.
Optional("startTime", "1607656034333").
Optional("limit", "5")))
}