service: handle error

This commit is contained in:
austin362667 2022-01-13 19:32:38 +08:00
parent 9a1d2cba31
commit f661db56bd

View File

@ -25,16 +25,20 @@ type SyncService struct {
func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exchange, startTime time.Time, symbols ...string) error {
for _, symbol := range symbols {
log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
// TODO: bbgo import cycle error
//markets, err := bbgo.LoadExchangeMarketsWithCache(ctx, exchange)
markets, err := exchange.QueryMarkets(ctx)
if err != nil {
if _, ok := markets[symbol]; ok {
if err := s.TradeService.Sync(ctx, exchange, symbol, startTime); err != nil {
return err
}
log.Infof("syncing %s %s orders...", exchange.Name(), symbol)
if err := s.OrderService.Sync(ctx, exchange, symbol, startTime); err != nil {
return err
}
return err
}
if _, ok := markets[symbol]; ok {
if err := s.TradeService.Sync(ctx, exchange, symbol, startTime); err != nil {
return err
}
log.Infof("syncing %s %s orders...", exchange.Name(), symbol)
if err := s.OrderService.Sync(ctx, exchange, symbol, startTime); err != nil {
return err
}
}
}