mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
rename trade callbacks to trade update callbacks
This commit is contained in:
parent
224acd0ca9
commit
74a9cae38e
|
@ -40,6 +40,13 @@ func (slice PriceVolumeSlice) Copy() PriceVolumeSlice {
|
||||||
return append(slice[:0:0], slice...)
|
return append(slice[:0:0], slice...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slice PriceVolumeSlice) First() (PriceVolume, bool) {
|
||||||
|
if len(slice) > 0 {
|
||||||
|
return slice[0], true
|
||||||
|
}
|
||||||
|
return PriceVolume{}, false
|
||||||
|
}
|
||||||
|
|
||||||
func (slice PriceVolumeSlice) IndexByVolumeDepth(requiredVolume fixedpoint.Value) int {
|
func (slice PriceVolumeSlice) IndexByVolumeDepth(requiredVolume fixedpoint.Value) int {
|
||||||
var tv int64 = 0
|
var tv int64 = 0
|
||||||
for x, el := range slice {
|
for x, el := range slice {
|
||||||
|
|
|
@ -2,18 +2,26 @@
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import ()
|
func (stream *StandardStream) OnTradeUpdate(cb func(trade Trade)) {
|
||||||
|
stream.tradeUpdateCallbacks = append(stream.tradeUpdateCallbacks, cb)
|
||||||
func (stream *StandardStream) OnTrade(cb func(trade Trade)) {
|
|
||||||
stream.tradeCallbacks = append(stream.tradeCallbacks, cb)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stream *StandardStream) EmitTrade(trade Trade) {
|
func (stream *StandardStream) EmitTradeUpdate(trade Trade) {
|
||||||
for _, cb := range stream.tradeCallbacks {
|
for _, cb := range stream.tradeUpdateCallbacks {
|
||||||
cb(trade)
|
cb(trade)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (stream *StandardStream) OnOrderUpdate(cb func(order Order)) {
|
||||||
|
stream.orderUpdateCallbacks = append(stream.orderUpdateCallbacks, cb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (stream *StandardStream) EmitOrderUpdate(order Order) {
|
||||||
|
for _, cb := range stream.orderUpdateCallbacks {
|
||||||
|
cb(order)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (stream *StandardStream) OnBalanceSnapshot(cb func(balances map[string]Balance)) {
|
func (stream *StandardStream) OnBalanceSnapshot(cb func(balances map[string]Balance)) {
|
||||||
stream.balanceSnapshotCallbacks = append(stream.balanceSnapshotCallbacks, cb)
|
stream.balanceSnapshotCallbacks = append(stream.balanceSnapshotCallbacks, cb)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +83,9 @@ func (stream *StandardStream) EmitBookSnapshot(book OrderBook) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type StandardStreamEventHub interface {
|
type StandardStreamEventHub interface {
|
||||||
OnTrade(cb func(trade Trade))
|
OnTradeUpdate(cb func(trade Trade))
|
||||||
|
|
||||||
|
OnOrderUpdate(cb func(order Order))
|
||||||
|
|
||||||
OnBalanceSnapshot(cb func(balances map[string]Balance))
|
OnBalanceSnapshot(cb func(balances map[string]Balance))
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,11 @@ var KLineChannel = Channel("kline")
|
||||||
type StandardStream struct {
|
type StandardStream struct {
|
||||||
Subscriptions []Subscription
|
Subscriptions []Subscription
|
||||||
|
|
||||||
// private trade callbacks
|
// private trade update callbacks
|
||||||
tradeCallbacks []func(trade Trade)
|
tradeUpdateCallbacks []func(trade Trade)
|
||||||
|
|
||||||
|
// private order update callbacks
|
||||||
|
orderUpdateCallbacks []func(order Order)
|
||||||
|
|
||||||
// balance snapshot callbacks
|
// balance snapshot callbacks
|
||||||
balanceSnapshotCallbacks []func(balances map[string]Balance)
|
balanceSnapshotCallbacks []func(balances map[string]Balance)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user