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
|
@ -456,7 +456,7 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := len(withdraws) - 1 ; i >= 0 ; i-- {
|
for i := len(withdraws) - 1; i >= 0; i-- {
|
||||||
d := withdraws[i]
|
d := withdraws[i]
|
||||||
if _, ok := txIDs[d.TxID]; ok {
|
if _, ok := txIDs[d.TxID]; ok {
|
||||||
continue
|
continue
|
||||||
|
@ -483,14 +483,14 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
||||||
|
|
||||||
txIDs[d.TxID] = struct{}{}
|
txIDs[d.TxID] = struct{}{}
|
||||||
withdraw := types.Withdraw{
|
withdraw := types.Withdraw{
|
||||||
Exchange: types.ExchangeMax,
|
Exchange: types.ExchangeMax,
|
||||||
ApplyTime: datatype.Time(time.Unix(d.CreatedAt, 0)),
|
ApplyTime: datatype.Time(time.Unix(d.CreatedAt, 0)),
|
||||||
Asset: toGlobalCurrency(d.Currency),
|
Asset: toGlobalCurrency(d.Currency),
|
||||||
Amount: util.MustParseFloat(d.Amount),
|
Amount: util.MustParseFloat(d.Amount),
|
||||||
Address: "",
|
Address: "",
|
||||||
AddressTag: "",
|
AddressTag: "",
|
||||||
TransactionID: d.TxID,
|
TransactionID: d.TxID,
|
||||||
TransactionFee: util.MustParseFloat(d.Fee),
|
TransactionFee: util.MustParseFloat(d.Fee),
|
||||||
TransactionFeeCurrency: d.FeeCurrency,
|
TransactionFeeCurrency: d.FeeCurrency,
|
||||||
// WithdrawOrderID: d.WithdrawOrderID,
|
// WithdrawOrderID: d.WithdrawOrderID,
|
||||||
// Network: d.Network,
|
// Network: d.Network,
|
||||||
|
@ -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) {
|
func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []types.Deposit, err error) {
|
||||||
startTime := since
|
startTime := since
|
||||||
|
limit := 1000
|
||||||
txIDs := map[string]struct{}{}
|
txIDs := map[string]struct{}{}
|
||||||
for startTime.Before(until) {
|
for startTime.Before(until) {
|
||||||
// startTime ~ endTime must be in 90 days
|
// 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)
|
log.Infof("querying deposit history %s: %s <=> %s", asset, startTime, endTime)
|
||||||
|
|
||||||
req := e.client.AccountService.NewGetDepositHistoryRequest()
|
req := e.client.AccountService.NewGetDepositHistoryRequest()
|
||||||
if len(asset) > 0 {
|
if len(asset) > 0 {
|
||||||
req.Currency(toLocalCurrency(asset))
|
req.Currency(toLocalCurrency(asset))
|
||||||
|
@ -529,13 +531,16 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
||||||
|
|
||||||
deposits, err := req.
|
deposits, err := req.
|
||||||
From(startTime.Unix()).
|
From(startTime.Unix()).
|
||||||
To(endTime.Unix()).Do(ctx)
|
To(endTime.Unix()).
|
||||||
|
Limit(limit).
|
||||||
|
Do(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range deposits {
|
for i := len(deposits) - 1; i >= 0; i-- {
|
||||||
|
d := deposits[i]
|
||||||
if _, ok := txIDs[d.TxID]; ok {
|
if _, ok := txIDs[d.TxID]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -552,7 +557,11 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = endTime
|
if len(deposits) < limit {
|
||||||
|
startTime = endTime
|
||||||
|
} else {
|
||||||
|
startTime = time.Unix(deposits[0].UpdatedAt, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allDeposits, err
|
return allDeposits, err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user