mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
receive trade in value instead of pointer
This commit is contained in:
parent
292dd2492a
commit
822e4c2703
|
@ -149,12 +149,12 @@ func (environ *Environment) Connect(ctx context.Context) error {
|
|||
session.marketDataStores[kline.Symbol].AddKLine(kline)
|
||||
})
|
||||
|
||||
session.Stream.OnTrade(func(trade *types.Trade) {
|
||||
session.Stream.OnTrade(func(trade types.Trade) {
|
||||
// append trades
|
||||
session.Trades[trade.Symbol] = append(session.Trades[trade.Symbol], *trade)
|
||||
session.Trades[trade.Symbol] = append(session.Trades[trade.Symbol], trade)
|
||||
|
||||
if err := environ.TradeService.Insert(*trade); err != nil {
|
||||
log.WithError(err).Errorf("trade insert error: %+v", *trade)
|
||||
if err := environ.TradeService.Insert(trade); err != nil {
|
||||
log.WithError(err).Errorf("trade insert error: %+v", trade)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ func NewStream(client *binance.Client) *Stream {
|
|||
break
|
||||
}
|
||||
|
||||
stream.EmitTrade(trade)
|
||||
stream.EmitTrade(*trade)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
package types
|
||||
|
||||
func (stream *StandardStream) OnTrade(cb func(trade *Trade)) {
|
||||
import ()
|
||||
|
||||
func (stream *StandardStream) OnTrade(cb func(trade Trade)) {
|
||||
stream.tradeCallbacks = append(stream.tradeCallbacks, cb)
|
||||
}
|
||||
|
||||
func (stream *StandardStream) EmitTrade(trade *Trade) {
|
||||
func (stream *StandardStream) EmitTrade(trade Trade) {
|
||||
for _, cb := range stream.tradeCallbacks {
|
||||
cb(trade)
|
||||
}
|
||||
|
@ -63,7 +65,7 @@ func (stream *StandardStream) EmitBookSnapshot(book OrderBook) {
|
|||
}
|
||||
|
||||
type StandardStreamEventHub interface {
|
||||
OnTrade(cb func(trade *Trade))
|
||||
OnTrade(cb func(trade Trade))
|
||||
|
||||
OnBalanceSnapshot(cb func(balances map[string]Balance))
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ type StandardStream struct {
|
|||
Subscriptions []Subscription
|
||||
|
||||
// private trade callbacks
|
||||
tradeCallbacks []func(trade *Trade)
|
||||
tradeCallbacks []func(trade Trade)
|
||||
|
||||
// balance snapshot callbacks
|
||||
balanceSnapshotCallbacks []func(balances map[string]Balance)
|
||||
|
|
Loading…
Reference in New Issue
Block a user