forked from nntaoli-project/goex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuturesWs_test.go
45 lines (33 loc) · 1016 Bytes
/
FuturesWs_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
package binance
import (
"github.com/nntaoli-project/goex"
"log"
"os"
"testing"
"time"
)
var futuresWs *FuturesWs
func createFuturesWs() {
os.Setenv("HTTPS_PROXY", "socks5://127.0.0.1:1080")
futuresWs = NewFuturesWs()
futuresWs.DepthCallback(func(depth *goex.Depth) {
log.Println(depth)
})
futuresWs.TickerCallback(func(ticker *goex.FutureTicker) {
log.Println(ticker.Ticker, ticker.ContractType)
})
}
func TestFuturesWs_DepthCallback(t *testing.T) {
createFuturesWs()
futuresWs.SubscribeDepth(goex.LTC_USDT, goex.SWAP_USDT_CONTRACT)
futuresWs.SubscribeDepth(goex.LTC_USDT, goex.SWAP_CONTRACT)
futuresWs.SubscribeDepth(goex.LTC_USDT, goex.QUARTER_CONTRACT)
time.Sleep(30 * time.Second)
}
func TestFuturesWs_SubscribeTicker(t *testing.T) {
createFuturesWs()
futuresWs.SubscribeTicker(goex.BTC_USDT, goex.SWAP_USDT_CONTRACT)
futuresWs.SubscribeTicker(goex.BTC_USDT, goex.SWAP_CONTRACT)
futuresWs.SubscribeTicker(goex.BTC_USDT, goex.QUARTER_CONTRACT)
time.Sleep(30 * time.Second)
}