Skip to content

Commit

Permalink
xgap: fix source market info loading
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Nov 15, 2024
1 parent 0ed1d38 commit 6078b2e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/strategy/xgap/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
}
s.tradingSession = tradingSession

s.sourceMarket, ok = s.sourceSession.Market(s.Symbol)
s.sourceMarket, ok = s.sourceSession.Market(s.SourceSymbol)
if !ok {
return fmt.Errorf("source session market %s is not defined", s.Symbol)
}
Expand All @@ -156,11 +156,12 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()

close(s.stopC)

if err := tradingutil.UniversalCancelAllOrders(ctx, s.tradingSession.Exchange, s.Symbol, nil); err != nil {
s.logger.WithError(err).Errorf("cancel all orders error")
}

close(s.stopC)
bbgo.Sync(ctx, s)
})

Expand Down Expand Up @@ -194,6 +195,9 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
)
defer ticker.Stop()

s.placeOrders(ctx)
s.cancelOrders(ctx)

for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 6078b2e

Please sign in to comment.