-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathswap_ws_test.go
47 lines (42 loc) · 1.15 KB
/
swap_ws_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
package okex
import (
"github.com/spf13/viper"
"log"
"testing"
)
func newSwapWSForTest() *SwapWS {
viper.SetConfigName("test_config")
viper.AddConfigPath("./conf")
err := viper.ReadInConfig()
if err != nil {
log.Panic(err)
}
accessKey := viper.GetString("access_key")
secretKey := viper.GetString("secret_key")
passphrase := viper.GetString("passphrase")
wsURL := "wss://real.okex.com:8443/ws/v3"
ws := NewSwapWS(wsURL, accessKey, secretKey, passphrase, true)
err = ws.SetProxy("socks5://127.0.0.1:1080")
////ws.SetProxy("http://127.0.0.1:1080")
if err != nil {
log.Fatal(err)
}
return ws
}
func TestSwapWS_AllInOne(t *testing.T) {
ws := newSwapWSForTest()
ws.SetTickerCallback(func(tickers []WSTicker) {
log.Printf("%#v", tickers)
})
ws.SetAccountCallback(func(accounts []WSAccount) {
log.Printf("%#v", accounts)
})
//ws.SubscribeTicker("ticker_1", "BTC-USD-SWAP")
//ws.SubscribeTrade("trade_1", "BTC-USD-SWAP")
//ws.SubscribeDepthL2Tbt("depthL2_1", "BTC-USD-SWAP")
//ws.SubscribeOrder("order_1", "BTC-USD-SWAP")
ws.SubscribePosition("position_1", "BTC-USD-SWAP")
ws.SubscribeAccount("account_1", "BTC-USD-SWAP")
ws.Start()
select {}
}