mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
fix: do not load all trades into memory
This commit is contained in:
parent
d7c8b0b127
commit
d27fee57ad
|
@ -448,6 +448,8 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
|
|||
trades, err = environ.TradeService.Query(service.QueryTradesOptions{
|
||||
Exchange: session.Exchange.Name(),
|
||||
Symbol: symbol,
|
||||
Ordering: "DESC",
|
||||
Limit: 100,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -455,6 +457,7 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
|
|||
return err
|
||||
}
|
||||
|
||||
trades = types.SortTradesAscending(trades)
|
||||
log.Infof("symbol %s: %d trades loaded", symbol, len(trades))
|
||||
}
|
||||
|
||||
|
|
|
@ -295,13 +295,11 @@ func (s *TradeService) QueryForTradingFeeCurrency(ex types.ExchangeName, symbol
|
|||
|
||||
func (s *TradeService) Query(options QueryTradesOptions) ([]types.Trade, error) {
|
||||
sql := queryTradesSQL(options)
|
||||
|
||||
log.Debug(sql)
|
||||
|
||||
args := map[string]interface{}{
|
||||
"exchange": options.Exchange,
|
||||
"symbol": options.Symbol,
|
||||
}
|
||||
|
||||
rows, err := s.DB.NamedQuery(sql, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue
Block a user