start time is required for syncing trades

This commit is contained in:
c9s 2022-01-01 02:50:07 +08:00
parent 83053ab807
commit ab0519c4be

View File

@ -2,6 +2,7 @@ package batch
import ( import (
"context" "context"
"errors"
"sort" "sort"
"time" "time"
@ -21,17 +22,26 @@ func (e TradeBatchQuery) Query(ctx context.Context, symbol string, options *type
tradeHistoryService, ok := e.Exchange.(types.ExchangeTradeHistoryService) tradeHistoryService, ok := e.Exchange.(types.ExchangeTradeHistoryService)
if !ok { if !ok {
defer close(c) close(errC)
defer close(errC) close(c)
// skip exchanges that does not support trading history services // skip exchanges that does not support trading history services
logrus.Warnf("exchange %s does not implement ExchangeTradeHistoryService, skip syncing closed orders (TradeBatchQuery.Query)", e.Exchange.Name()) logrus.Warnf("exchange %s does not implement ExchangeTradeHistoryService, skip syncing closed orders (TradeBatchQuery.Query)", e.Exchange.Name())
return c, errC return c, errC
} }
if options.StartTime == nil {
errC <- errors.New("start time is required for syncing trades")
close(errC)
close(c)
return c, errC
}
var lastTradeID = options.LastTradeID var lastTradeID = options.LastTradeID
var startTime = *options.StartTime var startTime = *options.StartTime
var endTime = *options.EndTime var endTime = *options.EndTime
go func() { go func() {
limiter := rate.NewLimiter(rate.Every(5*time.Second), 2) // from binance (original 1200, use 1000 for safety) limiter := rate.NewLimiter(rate.Every(5*time.Second), 2) // from binance (original 1200, use 1000 for safety)