mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
service: log sync start time
This commit is contained in:
parent
f223703247
commit
d5fe13272e
|
@ -25,30 +25,37 @@ 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 {
|
||||||
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, symbol := range symbols {
|
for _, symbol := range symbols {
|
||||||
if _, ok := markets[symbol]; ok {
|
// skip symbols do not exist in the market info
|
||||||
log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
|
if _, ok := markets[symbol]; !ok {
|
||||||
if err := s.TradeService.Sync(ctx, exchange, symbol, startTime); err != nil {
|
continue
|
||||||
return err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("syncing %s %s orders...", exchange.Name(), symbol)
|
log.Infof("syncing %s %s trades from %s...", exchange.Name(), symbol, startTime)
|
||||||
if err := s.OrderService.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 from %s...", exchange.Name(), symbol, startTime)
|
||||||
|
if err := s.OrderService.Sync(ctx, exchange, symbol, startTime); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncService) SyncMarginHistory(ctx context.Context, exchange types.Exchange, startTime time.Time, assets ...string) error {
|
func (s *SyncService) SyncMarginHistory(
|
||||||
|
ctx context.Context, exchange types.Exchange, startTime time.Time, assets ...string,
|
||||||
|
) error {
|
||||||
if _, implemented := exchange.(types.MarginHistoryService); !implemented {
|
if _, implemented := exchange.(types.MarginHistoryService); !implemented {
|
||||||
log.Debugf("exchange %T does not support types.MarginHistoryService", exchange)
|
log.Debugf("exchange %T does not support types.MarginHistoryService", exchange)
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user