Skip to content

Commit

Permalink
xdepthmaker: separate a stream for order book
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Nov 15, 2024
1 parent 9cced25 commit e0d3013
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/strategy/xdepthmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,6 @@ func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
panic(err)
}

hedgeSession.Subscribe(types.BookChannel, s.HedgeSymbol, types.SubscribeOptions{
Depth: types.DepthLevelFull,
Speed: types.SpeedLow,
})

hedgeSession.Subscribe(types.KLineChannel, s.HedgeSymbol, types.SubscribeOptions{Interval: "1m"})
hedgeSession.Subscribe(types.KLineChannel, hedgeSession.Exchange.PlatformFeeCurrency()+"USDT", types.SubscribeOptions{Interval: "1m"})

Expand Down Expand Up @@ -569,8 +564,19 @@ func (s *Strategy) CrossRun(
return err
}

sourceMarketStream := s.hedgeSession.Exchange.NewStream()
sourceMarketStream.SetPublicOnly()
sourceMarketStream.Subscribe(types.BookChannel, s.HedgeSymbol, types.SubscribeOptions{
Depth: types.DepthLevelFull,
Speed: types.SpeedLow,
})

s.sourceBook = types.NewStreamBook(s.HedgeSymbol, s.hedgeSession.ExchangeName)
s.sourceBook.BindStream(s.hedgeSession.MarketDataStream)
s.sourceBook.BindStream(sourceMarketStream)

if err := sourceMarketStream.Connect(ctx); err != nil {
return err
}

s.priceSolver = pricesolver.NewSimplePriceResolver(s.makerSession.Markets())
s.priceSolver.BindStream(s.hedgeSession.MarketDataStream)
Expand Down

0 comments on commit e0d3013

Please sign in to comment.