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
|
startTime = endTime
|
||||||
} else {
|
} else {
|
||||||
// its in descending order, so we get the first record
|
// 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 {
|
if len(deposits) < limit {
|
||||||
startTime = endTime
|
startTime = endTime
|
||||||
} else {
|
} 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
|
DB *sqlx.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync syncs the withdraw records into db
|
||||||
func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error {
|
func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error {
|
||||||
txnIDs := map[string]struct{}{}
|
txnIDs := map[string]struct{}{}
|
||||||
|
|
||||||
records, err := s.QueryLast(ex.Name(), 10)
|
// query descending
|
||||||
|
records, err := s.QueryLast(ex.Name(), 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -30,15 +32,25 @@ func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error {
|
||||||
return ErrNotImplemented
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, withdraw := range withdraws {
|
for _, withdraw := range withdraws {
|
||||||
if _, exists := txnIDs[withdraw.TransactionID] ; exists {
|
if _, exists := txnIDs[withdraw.TransactionID]; exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := s.Insert(withdraw); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user