mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
fix max deposits history ordering
This commit is contained in:
parent
75778675e3
commit
b25671c864
|
@ -513,6 +513,7 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
|||
|
||||
func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []types.Deposit, err error) {
|
||||
startTime := since
|
||||
limit := 1000
|
||||
txIDs := map[string]struct{}{}
|
||||
for startTime.Before(until) {
|
||||
// startTime ~ endTime must be in 90 days
|
||||
|
@ -522,6 +523,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
}
|
||||
|
||||
log.Infof("querying deposit history %s: %s <=> %s", asset, startTime, endTime)
|
||||
|
||||
req := e.client.AccountService.NewGetDepositHistoryRequest()
|
||||
if len(asset) > 0 {
|
||||
req.Currency(toLocalCurrency(asset))
|
||||
|
@ -529,13 +531,16 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
|
||||
deposits, err := req.
|
||||
From(startTime.Unix()).
|
||||
To(endTime.Unix()).Do(ctx)
|
||||
To(endTime.Unix()).
|
||||
Limit(limit).
|
||||
Do(ctx)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range deposits {
|
||||
for i := len(deposits) - 1; i >= 0; i-- {
|
||||
d := deposits[i]
|
||||
if _, ok := txIDs[d.TxID]; ok {
|
||||
continue
|
||||
}
|
||||
|
@ -552,7 +557,11 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
})
|
||||
}
|
||||
|
||||
if len(deposits) < limit {
|
||||
startTime = endTime
|
||||
} else {
|
||||
startTime = time.Unix(deposits[0].UpdatedAt, 0)
|
||||
}
|
||||
}
|
||||
|
||||
return allDeposits, err
|
||||
|
|
Loading…
Reference in New Issue
Block a user