i use golang and the framework adshao
https://pkg.go.dev/github.com/adshao/go-binance/[email protected]
i want to process the stream as it arrives and i have no idea how to do that.
the stream arrives in this variable event,and i need to separate the pairs so that i can process them.so i can’t loop through it,i can’t use string separator,i can’t add it to a map.how to do this?
package main
import (
"fmt"
"github.com/adshao/go-binance/v2"
)
func main() {
pairs := map[string]string{"ETHBTC":"1s","BTCUSDT":"1s","LTCBTC":"1s"}
wsKlineHandler := func(event *binance.WsKlineEvent) {
fmt.Println(event.Symbol,event.Kline.Open)
}
errHandler := func(err error) {
fmt.Println(err)
}
doneC, _, err := binance.WsCombinedKlineServe(pairs, wsKlineHandler, errHandler)
if err != nil {
fmt.Println(err)
return
}
<-doneC
}
this is the stream i get
ETHBTC 0.05150000
LTCBTC 0.00110300
BTCUSDT 66311.48000000
ETHBTC 0.05150000
LTCBTC 0.00110300
BTCUSDT 66311.47000000
ETHBTC 0.05150000
LTCBTC 0.00110300
BTCUSDT 66311.47000000
ETHBTC 0.05151000
LTCBTC 0.00110400
BTCUSDT 66306.01000000