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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/c9s/bbgo/pkg/cache"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/c9s/bbgo/pkg/cache"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
@ -24,17 +25,18 @@ type SyncService struct {
|
||||||
|
|
||||||
// SyncSessionSymbols syncs the trades from the given exchange session
|
// 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 {
|
func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exchange, startTime time.Time, symbols ...string) error {
|
||||||
for _, symbol := range symbols {
|
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||||
log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
|
if err != nil {
|
||||||
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for _, symbol := range symbols {
|
||||||
if _, ok := markets[symbol]; ok {
|
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 {
|
if err := s.TradeService.Sync(ctx, exchange, symbol, startTime); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("syncing %s %s orders...", exchange.Name(), symbol)
|
log.Infof("syncing %s %s orders...", exchange.Name(), symbol)
|
||||||
if err := s.OrderService.Sync(ctx, exchange, symbol, startTime); err != nil {
|
if err := s.OrderService.Sync(ctx, exchange, symbol, startTime); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user