mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
xgap: share sourceKLineHandler
This commit is contained in:
parent
e67a6c56c9
commit
050d1ca794
|
@ -159,16 +159,13 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
||||||
})
|
})
|
||||||
|
|
||||||
// from here, set data binding
|
// from here, set data binding
|
||||||
s.sourceSession.MarketDataStream.OnKLine(func(kline types.KLine) {
|
sourceKLineHandler := func(kline types.KLine) {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.lastSourceKLine = kline
|
s.lastSourceKLine = kline
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
})
|
}
|
||||||
s.tradingSession.MarketDataStream.OnKLine(func(kline types.KLine) {
|
s.sourceSession.MarketDataStream.OnKLine(sourceKLineHandler)
|
||||||
s.mu.Lock()
|
s.tradingSession.MarketDataStream.OnKLine(sourceKLineHandler)
|
||||||
s.lastTradingKLine = kline
|
|
||||||
s.mu.Unlock()
|
|
||||||
})
|
|
||||||
|
|
||||||
if s.SourceExchange != "" && s.SourceSymbol != "" {
|
if s.SourceExchange != "" && s.SourceSymbol != "" {
|
||||||
s.sourceBook = types.NewStreamBook(s.SourceSymbol, sourceSession.ExchangeName)
|
s.sourceBook = types.NewStreamBook(s.SourceSymbol, sourceSession.ExchangeName)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user