forked from nntaoli-project/goex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHuobiPro_test.go
141 lines (121 loc) · 2.82 KB
/
HuobiPro_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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package huobi
import (
"github.com/nntaoli-project/goex"
"github.com/nntaoli-project/goex/internal/logger"
"github.com/stretchr/testify/assert"
"net"
"net/http"
"net/url"
"testing"
"time"
)
var httpProxyClient = &http.Client{
Transport: &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
return &url.URL{
Scheme: "socks5",
Host: "127.0.0.1:1080"}, nil
},
Dial: (&net.Dialer{
Timeout: 10 * time.Second,
}).Dial,
},
Timeout: 10 * time.Second,
}
var (
apikey = ""
secretkey = ""
)
//
var hbpro *HuoBiPro
func init() {
logger.Log.SetLevel(logger.DEBUG)
hbpro = NewHuoBiProSpot(httpProxyClient, apikey, secretkey)
}
func TestHuobiPro_GetTicker(t *testing.T) {
ticker, err := hbpro.GetTicker(goex.XRP_BTC)
assert.Nil(t, err)
t.Log(ticker)
}
func TestHuobiPro_GetDepth(t *testing.T) {
dep, err := hbpro.GetDepth(2, goex.LTC_USDT)
assert.Nil(t, err)
t.Log(dep.AskList)
t.Log(dep.BidList)
}
func TestHuobiPro_GetAccountInfo(t *testing.T) {
return
info, err := hbpro.GetAccountInfo("point")
assert.Nil(t, err)
t.Log(info)
}
//获取点卡剩余
func TestHuoBiPro_GetPoint(t *testing.T) {
return
point := NewHuoBiProPoint(httpProxyClient, apikey, secretkey)
acc, _ := point.GetAccount()
t.Log(acc.SubAccounts[HBPOINT])
}
//获取现货资产信息
func TestHuobiPro_GetAccount(t *testing.T) {
return
acc, err := hbpro.GetAccount()
assert.Nil(t, err)
t.Log(acc.SubAccounts)
}
func TestHuobiPro_LimitBuy(t *testing.T) {
return
ord, err := hbpro.LimitBuy("", "0.09122", goex.BCC_BTC)
assert.Nil(t, err)
t.Log(ord)
}
func TestHuobiPro_LimitSell(t *testing.T) {
return
ord, err := hbpro.LimitSell("1", "0.212", goex.BCC_BTC)
assert.Nil(t, err)
t.Log(ord)
}
func TestHuobiPro_MarketSell(t *testing.T) {
return
ord, err := hbpro.MarketSell("0.1738", "0.212", goex.BCC_BTC)
assert.Nil(t, err)
t.Log(ord)
}
func TestHuobiPro_MarketBuy(t *testing.T) {
return
ord, err := hbpro.MarketBuy("0.02", "", goex.BCC_BTC)
assert.Nil(t, err)
t.Log(ord)
}
func TestHuobiPro_GetUnfinishOrders(t *testing.T) {
return
ords, err := hbpro.GetUnfinishOrders(goex.ETC_USDT)
assert.Nil(t, err)
t.Log(ords)
}
func TestHuobiPro_CancelOrder(t *testing.T) {
return
r, err := hbpro.CancelOrder("600329873", goex.ETH_USDT)
assert.Nil(t, err)
t.Log(r)
t.Log(err)
}
func TestHuobiPro_GetOneOrder(t *testing.T) {
ord, err := hbpro.GetOneOrder("165062634284339", goex.BTC_USDT)
assert.Nil(t, err)
t.Log(ord)
}
func TestHuobiPro_GetOrderHistorys(t *testing.T) {
ords, err := hbpro.GetOrderHistorys(
goex.NewCurrencyPair2("BTC_USDT"),
goex.OptionalParameter{}.Optional("start-date","2020-11-30"))
t.Log(err)
t.Log(ords)
}
func TestHuobiPro_GetCurrenciesList(t *testing.T) {
hbpro.GetCurrenciesList()
}
func TestHuobiPro_GetCurrenciesPrecision(t *testing.T) {
//return
t.Log(hbpro.GetCurrenciesPrecision())
}