From 6078b2e1441670ec6e9659680407297f93276f3c Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 16 Nov 2024 00:47:58 +0800 Subject: [PATCH] xgap: fix source market info loading --- pkg/strategy/xgap/strategy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/strategy/xgap/strategy.go b/pkg/strategy/xgap/strategy.go index 434b4e015..209fb3126 100644 --- a/pkg/strategy/xgap/strategy.go +++ b/pkg/strategy/xgap/strategy.go @@ -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) } @@ -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) }) @@ -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():