-
Notifications
You must be signed in to change notification settings - Fork 34
/
allMarketPrice.go
38 lines (35 loc) · 1.27 KB
/
allMarketPrice.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
package main
import (
"fmt"
"github.com/dirname/binance/futures/usd/websocket/market"
logger "github.com/dirname/binance/logging"
"github.com/dirname/binance/model"
"time"
)
func main() {
client := futuresusdt.NewUSDFuturesAllMarketPriceWebsocketClient("!markPrice@arr")
client.SetReadTimerInterval(5 * time.Second)
client.SetReconnectWaitTime(5 * time.Second)
client.SetHandler(func() {
client.Subscribe(123, "!markPrice@arr@1s", "!markPrice@3s")
client.SetCombined(true, 123)
}, func(response interface{}) {
switch response.(type) {
case futuresusdt.AllMarketPriceResponse:
logger.Info("AllMarket Response: %v", response.(futuresusdt.AllMarketPriceResponse))
case futuresusdt.AllMarketPriceCombinedResponse:
logger.Info("AllMarketCombinedResponse: %v", response.(futuresusdt.AllMarketPriceCombinedResponse))
case model.WebsocketCommonResponse:
logger.Info("Websocket Response: %v", response.(model.WebsocketCommonResponse))
case model.WebsocketErrorResponse:
logger.Info("Websocket Error Response: %v", response.(model.WebsocketErrorResponse))
default:
logger.Info("Unknown Response: %v", response)
}
})
client.Connect(true)
fmt.Scanln()
client.Unsubscribe(123, "!markPrice@arr@1s", "!markPrice@3s")
client.Close()
logger.Info("Client closed")
}