We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should a handler subscribe to multiple Kline data simultaneously eth_usdt, 1m , btc,5m WsKlineServe("ETHBTC", "1m", func(event *WsKlineEvent) { }
The text was updated successfully, but these errors were encountered:
Multiple calls to WSKlineService if there don't have a interface to do that. @shuyabin
Sorry, something went wrong.
baseURL = "wss://fstream.binance.com/stream?streams=" func getStreamURL(cl []string) string { var streams []string for _, coin := range cl { streams = append(streams, fmt.Sprintf("%s@kline_1m", coin)) } return baseURL + strings.Join(streams, "/") }
import "github.com/coder/websocket" wsClient, resp, err := websocket.Dial(ctx, getStreamURL(cList), &websocket.DialOptions{ CompressionMode: websocket.CompressionContextTakeover, }, ) ... messageType, content, err := conn.Read(ctx) if messageType != websocket.MessageText { continue } ... j, err := newJSON(content) jData := j.Get("data") type WsCustomEvent struct { Event string `json:"e"` Symbol string `json:"s"` Kline futures.WsKline `json:"k"` } event := new(WsCustomEvent) event.Event = jData.Get("e").MustString() event.Symbol = jData.Get("s").MustString() if event.Event == "kline" { item := jData.Get("k") event.Kline = futures.WsKline{ Symbol: item.Get("s").MustString(), High: item.Get("h").MustString(), ... } }
The code works, but it would be nice to do this in the library itself
No branches or pull requests
How should a handler subscribe to multiple Kline data simultaneously
eth_usdt, 1m , btc,5m
WsKlineServe("ETHBTC", "1m", func(event *WsKlineEvent) { }
The text was updated successfully, but these errors were encountered: