bbgo_origin/bbgo/exchange/binance/privatestream_callbacks.go

196 lines
4.8 KiB
Go
Raw Normal View History

2020-07-11 08:07:09 +00:00
// Code generated by "callbackgen -type PrivateStream -interface"; DO NOT EDIT.
package binance
import (
"reflect"
)
func (s *PrivateStream) OnConnect(cb func(stream *PrivateStream)) {
s.connectCallbacks = append(s.connectCallbacks, cb)
}
func (s *PrivateStream) EmitConnect(stream *PrivateStream) {
for _, cb := range s.connectCallbacks {
cb(stream)
}
}
func (s *PrivateStream) RemoveOnConnect(needle func(stream *PrivateStream)) (found bool) {
var newcallbacks []func(stream *PrivateStream)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.connectCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.connectCallbacks = newcallbacks
}
return found
}
func (s *PrivateStream) OnKLineEvent(cb func(event *KLineEvent)) {
s.kLineEventCallbacks = append(s.kLineEventCallbacks, cb)
}
func (s *PrivateStream) EmitKLineEvent(event *KLineEvent) {
for _, cb := range s.kLineEventCallbacks {
cb(event)
}
}
func (s *PrivateStream) RemoveOnKLineEvent(needle func(event *KLineEvent)) (found bool) {
var newcallbacks []func(event *KLineEvent)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.kLineEventCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.kLineEventCallbacks = newcallbacks
}
return found
}
func (s *PrivateStream) OnKLineClosedEvent(cb func(event *KLineEvent)) {
s.kLineClosedEventCallbacks = append(s.kLineClosedEventCallbacks, cb)
}
func (s *PrivateStream) EmitKLineClosedEvent(event *KLineEvent) {
for _, cb := range s.kLineClosedEventCallbacks {
cb(event)
}
}
func (s *PrivateStream) RemoveOnKLineClosedEvent(needle func(event *KLineEvent)) (found bool) {
var newcallbacks []func(event *KLineEvent)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.kLineClosedEventCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.kLineClosedEventCallbacks = newcallbacks
}
return found
}
func (s *PrivateStream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent)) {
s.balanceUpdateEventCallbacks = append(s.balanceUpdateEventCallbacks, cb)
}
func (s *PrivateStream) EmitBalanceUpdateEvent(event *BalanceUpdateEvent) {
for _, cb := range s.balanceUpdateEventCallbacks {
cb(event)
}
}
func (s *PrivateStream) RemoveOnBalanceUpdateEvent(needle func(event *BalanceUpdateEvent)) (found bool) {
var newcallbacks []func(event *BalanceUpdateEvent)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.balanceUpdateEventCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.balanceUpdateEventCallbacks = newcallbacks
}
return found
}
func (s *PrivateStream) OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent)) {
s.outboundAccountInfoEventCallbacks = append(s.outboundAccountInfoEventCallbacks, cb)
}
func (s *PrivateStream) EmitOutboundAccountInfoEvent(event *OutboundAccountInfoEvent) {
for _, cb := range s.outboundAccountInfoEventCallbacks {
cb(event)
}
}
func (s *PrivateStream) RemoveOnOutboundAccountInfoEvent(needle func(event *OutboundAccountInfoEvent)) (found bool) {
var newcallbacks []func(event *OutboundAccountInfoEvent)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.outboundAccountInfoEventCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.outboundAccountInfoEventCallbacks = newcallbacks
}
return found
}
func (s *PrivateStream) OnExecutionReportEvent(cb func(event *ExecutionReportEvent)) {
s.executionReportEventCallbacks = append(s.executionReportEventCallbacks, cb)
}
func (s *PrivateStream) EmitExecutionReportEvent(event *ExecutionReportEvent) {
for _, cb := range s.executionReportEventCallbacks {
cb(event)
}
}
func (s *PrivateStream) RemoveOnExecutionReportEvent(needle func(event *ExecutionReportEvent)) (found bool) {
var newcallbacks []func(event *ExecutionReportEvent)
var fp = reflect.ValueOf(needle).Pointer()
for _, cb := range s.executionReportEventCallbacks {
if fp == reflect.ValueOf(cb).Pointer() {
found = true
} else {
newcallbacks = append(newcallbacks, cb)
}
}
if found {
s.executionReportEventCallbacks = newcallbacks
}
return found
}
type PrivateStreamEventHub interface {
OnConnect(cb func(stream *PrivateStream))
OnKLineEvent(cb func(event *KLineEvent))
OnKLineClosedEvent(cb func(event *KLineEvent))
OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
OnExecutionReportEvent(cb func(event *ExecutionReportEvent))
}