package collector import ( "github.com/adshao/go-binance/v2/futures" "gitlab.home/root/bitrader/utils" ) type KlineCollector struct { collectorBase Symbol string Interval string doneC chan struct{} stopC chan struct{} } func init() { futures.WebsocketKeepalive = true } func CreateKlineCollector(symbol, interval string) *KlineCollector { k := &KlineCollector{ Symbol: symbol, Interval: interval, } k.collectorBase.Init(symbol + "@" + interval) var err error k.doneC, k.stopC, err = futures.WsKlineServe(symbol, interval, k.handler, k.err) utils.PanicIf(err) return k } func (k *KlineCollector) handler(event *futures.WsKlineEvent) { k.logger.Info("%#v", event) } func (k *KlineCollector) err(e error) { k.logger.Error("%#v", e) } func (k *KlineCollector) Wait() { <-k.doneC }