binance: fix futures symbol not found from syncSession

binance: fix query trades, closed orders futures symbol not found

binance: fix futures symbol not found
This commit is contained in:
austin362667 2022-01-04 03:31:26 +08:00
parent 0f0539fe70
commit 5404bfe7f8
2 changed files with 14 additions and 19 deletions

View File

@ -178,7 +178,6 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
markets := types.MarketMap{} markets := types.MarketMap{}
for _, symbol := range exchangeInfo.Symbols { for _, symbol := range exchangeInfo.Symbols {
log.Info(symbol)
markets[symbol.Symbol] = toGlobalFuturesMarket(symbol) markets[symbol.Symbol] = toGlobalFuturesMarket(symbol)
} }
@ -494,12 +493,7 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
return futuresAccount, nil return futuresAccount, nil
} }
account, err := e.QuerySpotAccount(ctx) return e.QuerySpotAccount(ctx)
if err != nil {
return nil, err
}
return account, nil
} }
func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error) { func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error) {
@ -578,7 +572,6 @@ func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since,
if err != nil { if err != nil {
return orders, err return orders, err
} }
return toGlobalFuturesOrders(binanceOrders) return toGlobalFuturesOrders(binanceOrders)
} }
@ -1094,9 +1087,8 @@ func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *type
return trades, nil return trades, nil
} else if e.IsFutures { } else if e.IsFutures {
var remoteTrades []*futures.AccountTrade var remoteTrades []*futures.AccountTrade
req := e.futuresClient.NewListAccountTradeService(). // IsIsolated(e.IsIsolatedFutures). req := e.futuresClient.NewListAccountTradeService(). //IsIsolated(e.IsIsolatedFutures).
Symbol(symbol) Symbol(symbol)
if options.Limit > 0 { if options.Limit > 0 {
req.Limit(int(options.Limit)) req.Limit(int(options.Limit))
} else { } else {
@ -1115,7 +1107,7 @@ func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *type
for _, t := range remoteTrades { for _, t := range remoteTrades {
localTrade, err := toGlobalFuturesTrade(*t) localTrade, err := toGlobalFuturesTrade(*t)
if err != nil { if err != nil {
log.WithError(err).Errorf("can not convert binance trade: %+v", t) log.WithError(err).Errorf("can not convert binance futures trade: %+v", t)
continue continue
} }

View File

@ -25,16 +25,19 @@ type SyncService struct {
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 { for _, symbol := range symbols {
log.Infof("syncing %s %s trades...", exchange.Name(), symbol) log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
markets, err := exchange.QueryMarkets(ctx)
if err != nil {
if _, ok := markets[symbol]; ok {
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
} }
} }
}
}
log.Infof("syncing %s deposit records...", exchange.Name()) log.Infof("syncing %s deposit records...", exchange.Name())
if err := s.DepositService.Sync(ctx, exchange); err != nil { if err := s.DepositService.Sync(ctx, exchange); err != nil {