xgap: fix source market info loading

This commit is contained in:
c9s 2024-11-16 00:47:58 +08:00
parent 0ed1d385c1
commit 6078b2e144
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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():