mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 11:33:50 +00:00
deposit2transfer: fix deposit time checking
This commit is contained in:
parent
37c97fd966
commit
e9e3dbacec
|
@ -271,6 +271,12 @@ func (s *Strategy) checkDeposits(ctx context.Context) {
|
||||||
func (s *Strategy) addWatchingDeposit(deposit types.Deposit) {
|
func (s *Strategy) addWatchingDeposit(deposit types.Deposit) {
|
||||||
s.watchingDeposits[deposit.TransactionID] = deposit
|
s.watchingDeposits[deposit.TransactionID] = deposit
|
||||||
|
|
||||||
|
if lastTime, ok := s.lastAssetDepositTimes[deposit.Asset]; ok {
|
||||||
|
s.lastAssetDepositTimes[deposit.Asset] = later(deposit.Time.Time(), lastTime)
|
||||||
|
} else {
|
||||||
|
s.lastAssetDepositTimes[deposit.Asset] = deposit.Time.Time()
|
||||||
|
}
|
||||||
|
|
||||||
if s.SlackAlert != nil {
|
if s.SlackAlert != nil {
|
||||||
bbgo.PostLiveNote(&deposit,
|
bbgo.PostLiveNote(&deposit,
|
||||||
livenote.Channel(s.SlackAlert.Channel),
|
livenote.Channel(s.SlackAlert.Channel),
|
||||||
|
@ -339,7 +345,13 @@ func (s *Strategy) scanDepositHistory(ctx context.Context, asset string, duratio
|
||||||
logger.Infof("ignored expired succeedded deposit: %s %+v", deposit.TransactionID, deposit)
|
logger.Infof("ignored expired succeedded deposit: %s %+v", deposit.TransactionID, deposit)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.addWatchingDeposit(deposit)
|
// if the latest deposit time is not found, check if the deposit is older than 5 minutes
|
||||||
|
expiryTime := 5 * time.Minute
|
||||||
|
if deposit.Time.Before(time.Now().Add(-expiryTime)) {
|
||||||
|
logger.Infof("ignored expired (%s) succeedded deposit: %s %+v", expiryTime, deposit.TransactionID, deposit)
|
||||||
|
} else {
|
||||||
|
s.addWatchingDeposit(deposit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.DepositCredited, types.DepositPending:
|
case types.DepositCredited, types.DepositPending:
|
||||||
|
@ -349,15 +361,6 @@ func (s *Strategy) scanDepositHistory(ctx context.Context, asset string, duratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deposits) > 0 {
|
|
||||||
lastDeposit := deposits[len(deposits)-1]
|
|
||||||
if lastTime, ok := s.lastAssetDepositTimes[asset]; ok {
|
|
||||||
s.lastAssetDepositTimes[asset] = later(lastDeposit.Time.Time(), lastTime)
|
|
||||||
} else {
|
|
||||||
s.lastAssetDepositTimes[asset] = lastDeposit.Time.Time()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var succeededDeposits []types.Deposit
|
var succeededDeposits []types.Deposit
|
||||||
|
|
||||||
// find and move out succeeded deposits
|
// find and move out succeeded deposits
|
||||||
|
|
Loading…
Reference in New Issue
Block a user