2021-05-26 17:07:38 +00:00
|
|
|
// Code generated by "callbackgen -type Stream -interface"; DO NOT EDIT.
|
|
|
|
|
|
|
|
package okex
|
|
|
|
|
2021-05-27 17:14:11 +00:00
|
|
|
import (
|
|
|
|
"github.com/c9s/bbgo/pkg/exchange/okex/okexapi"
|
|
|
|
)
|
2021-05-26 17:07:38 +00:00
|
|
|
|
2021-05-27 10:35:34 +00:00
|
|
|
func (s *Stream) OnCandleData(cb func(candle Candle)) {
|
|
|
|
s.candleDataCallbacks = append(s.candleDataCallbacks, cb)
|
2021-05-26 17:07:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-27 10:35:34 +00:00
|
|
|
func (s *Stream) EmitCandleData(candle Candle) {
|
|
|
|
for _, cb := range s.candleDataCallbacks {
|
|
|
|
cb(candle)
|
2021-05-26 17:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-27 10:35:34 +00:00
|
|
|
func (s *Stream) OnBookData(cb func(book BookData)) {
|
2021-05-27 08:01:15 +00:00
|
|
|
s.bookDataCallbacks = append(s.bookDataCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2021-05-27 10:35:34 +00:00
|
|
|
func (s *Stream) EmitBookData(book BookData) {
|
2021-05-27 08:01:15 +00:00
|
|
|
for _, cb := range s.bookDataCallbacks {
|
2021-05-27 10:35:34 +00:00
|
|
|
cb(book)
|
2021-05-27 08:01:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stream) OnEvent(cb func(event WebSocketEvent)) {
|
|
|
|
s.eventCallbacks = append(s.eventCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stream) EmitEvent(event WebSocketEvent) {
|
|
|
|
for _, cb := range s.eventCallbacks {
|
|
|
|
cb(event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-27 17:14:11 +00:00
|
|
|
func (s *Stream) OnAccount(cb func(account okexapi.Account)) {
|
|
|
|
s.accountCallbacks = append(s.accountCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stream) EmitAccount(account okexapi.Account) {
|
|
|
|
for _, cb := range s.accountCallbacks {
|
|
|
|
cb(account)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-27 18:21:35 +00:00
|
|
|
func (s *Stream) OnOrderDetails(cb func(orderDetails []okexapi.OrderDetails)) {
|
|
|
|
s.orderDetailsCallbacks = append(s.orderDetailsCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stream) EmitOrderDetails(orderDetails []okexapi.OrderDetails) {
|
|
|
|
for _, cb := range s.orderDetailsCallbacks {
|
|
|
|
cb(orderDetails)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-26 17:07:38 +00:00
|
|
|
type StreamEventHub interface {
|
2021-05-27 10:35:34 +00:00
|
|
|
OnCandleData(cb func(candle Candle))
|
2021-05-27 08:01:15 +00:00
|
|
|
|
2021-05-27 10:35:34 +00:00
|
|
|
OnBookData(cb func(book BookData))
|
2021-05-27 08:01:15 +00:00
|
|
|
|
|
|
|
OnEvent(cb func(event WebSocketEvent))
|
2021-05-27 17:14:11 +00:00
|
|
|
|
|
|
|
OnAccount(cb func(account okexapi.Account))
|
2021-05-27 18:21:35 +00:00
|
|
|
|
|
|
|
OnOrderDetails(cb func(orderDetails []okexapi.OrderDetails))
|
2021-05-26 17:07:38 +00:00
|
|
|
}
|