mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
service: fix sync process
This commit is contained in:
parent
407a533659
commit
106239e808
|
@ -3,9 +3,10 @@ package service
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
"time"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
|
@ -24,17 +25,18 @@ type SyncService struct {
|
|||
|
||||
// SyncSessionSymbols syncs the trades from the given exchange session
|
||||
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)
|
||||
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, symbol := range symbols {
|
||||
if _, ok := markets[symbol]; ok {
|
||||
log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user