-
-
Notifications
You must be signed in to change notification settings - Fork 278
/
stream_callbacks.go
69 lines (52 loc) · 1.64 KB
/
stream_callbacks.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Code generated by "callbackgen -type Stream -interface"; DO NOT EDIT.
package okex
import (
"github.com/c9s/bbgo/pkg/exchange/okex/okexapi"
)
func (s *Stream) OnCandleEvent(cb func(candle Candle)) {
s.candleEventCallbacks = append(s.candleEventCallbacks, cb)
}
func (s *Stream) EmitCandleEvent(candle Candle) {
for _, cb := range s.candleEventCallbacks {
cb(candle)
}
}
func (s *Stream) OnBookEvent(cb func(book BookEvent)) {
s.bookEventCallbacks = append(s.bookEventCallbacks, cb)
}
func (s *Stream) EmitBookEvent(book BookEvent) {
for _, cb := range s.bookEventCallbacks {
cb(book)
}
}
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)
}
}
func (s *Stream) OnAccountEvent(cb func(account okexapi.Account)) {
s.accountEventCallbacks = append(s.accountEventCallbacks, cb)
}
func (s *Stream) EmitAccountEvent(account okexapi.Account) {
for _, cb := range s.accountEventCallbacks {
cb(account)
}
}
func (s *Stream) OnOrderDetailsEvent(cb func(orderDetails []okexapi.OrderDetails)) {
s.orderDetailsEventCallbacks = append(s.orderDetailsEventCallbacks, cb)
}
func (s *Stream) EmitOrderDetailsEvent(orderDetails []okexapi.OrderDetails) {
for _, cb := range s.orderDetailsEventCallbacks {
cb(orderDetails)
}
}
type StreamEventHub interface {
OnCandleEvent(cb func(candle Candle))
OnBookEvent(cb func(book BookEvent))
OnEvent(cb func(event WebSocketEvent))
OnAccountEvent(cb func(account okexapi.Account))
OnOrderDetailsEvent(cb func(orderDetails []okexapi.OrderDetails))
}