Skip to content

Commit

Permalink
xgap: share sourceKLineHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Nov 15, 2024
1 parent e67a6c5 commit 050d1ca
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/strategy/xgap/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,13 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
})

// from here, set data binding
s.sourceSession.MarketDataStream.OnKLine(func(kline types.KLine) {
sourceKLineHandler := func(kline types.KLine) {
s.mu.Lock()
s.lastSourceKLine = kline
s.mu.Unlock()
})
s.tradingSession.MarketDataStream.OnKLine(func(kline types.KLine) {
s.mu.Lock()
s.lastTradingKLine = kline
s.mu.Unlock()
})
}
s.sourceSession.MarketDataStream.OnKLine(sourceKLineHandler)
s.tradingSession.MarketDataStream.OnKLine(sourceKLineHandler)

if s.SourceExchange != "" && s.SourceSymbol != "" {
s.sourceBook = types.NewStreamBook(s.SourceSymbol, sourceSession.ExchangeName)
Expand Down

0 comments on commit 050d1ca

Please sign in to comment.