mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
batch: add DepositBatchQuery
This commit is contained in:
parent
c4c8bca72f
commit
5f075af24f
36
pkg/exchange/batch/deposit.go
Normal file
36
pkg/exchange/batch/deposit.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package batch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
type DepositBatchQuery struct {
|
||||
types.ExchangeTransferService
|
||||
}
|
||||
|
||||
func (e *DepositBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.Deposit, errC chan error) {
|
||||
query := &AsyncTimeRangedBatchQuery{
|
||||
Type: types.Deposit{},
|
||||
Limiter: rate.NewLimiter(rate.Every(5*time.Second), 2),
|
||||
JumpIfEmpty: time.Hour * 24 * 80,
|
||||
Q: func(startTime, endTime time.Time) (interface{}, error) {
|
||||
return e.ExchangeTransferService.QueryDepositHistory(ctx, asset, startTime, endTime)
|
||||
},
|
||||
T: func(obj interface{}) time.Time {
|
||||
return time.Time(obj.(types.Deposit).Time)
|
||||
},
|
||||
ID: func(obj interface{}) string {
|
||||
deposit := obj.(types.Deposit)
|
||||
return deposit.TransactionID
|
||||
},
|
||||
}
|
||||
|
||||
c = make(chan types.Deposit, 100)
|
||||
errC = query.Query(ctx, c, startTime, endTime)
|
||||
return c, errC
|
||||
}
|
Loading…
Reference in New Issue
Block a user