mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
fix used time field for withdraw
This commit is contained in:
parent
b25671c864
commit
8e85274876
|
@ -504,7 +504,7 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
|||
startTime = endTime
|
||||
} else {
|
||||
// its in descending order, so we get the first record
|
||||
startTime = time.Unix(withdraws[0].UpdatedAt, 0)
|
||||
startTime = time.Unix(withdraws[0].CreatedAt, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
if len(deposits) < limit {
|
||||
startTime = endTime
|
||||
} else {
|
||||
startTime = time.Unix(deposits[0].UpdatedAt, 0)
|
||||
startTime = time.Unix(deposits[0].CreatedAt, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,12 @@ type WithdrawService struct {
|
|||
DB *sqlx.DB
|
||||
}
|
||||
|
||||
// Sync syncs the withdraw records into db
|
||||
func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error {
|
||||
txnIDs := map[string]struct{}{}
|
||||
|
||||
records, err := s.QueryLast(ex.Name(), 10)
|
||||
// query descending
|
||||
records, err := s.QueryLast(ex.Name(), 100)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -30,15 +32,25 @@ func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error {
|
|||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
withdraws, err := transferApi.QueryWithdrawHistory(ctx, "", records[0].ApplyTime.Time(), time.Now())
|
||||
since := time.Time{}
|
||||
if len(records) > 0 {
|
||||
since = records[len(records)-1].ApplyTime.Time()
|
||||
}
|
||||
|
||||
// asset "" means all assets
|
||||
withdraws, err := transferApi.QueryWithdrawHistory(ctx, "", since, time.Now())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, withdraw := range withdraws {
|
||||
if _, exists := txnIDs[withdraw.TransactionID] ; exists {
|
||||
if _, exists := txnIDs[withdraw.TransactionID]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := s.Insert(withdraw); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user