mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
autoborrow: check available
This commit is contained in:
parent
f014213c85
commit
a5a9512ef1
|
@ -213,8 +213,16 @@ func (s *Strategy) reBalanceDebt(ctx context.Context) {
|
|||
|
||||
log.Infof("checking repayable balance: %+v", b)
|
||||
|
||||
toRepay := fixedpoint.Min(b.Borrowed, b.Available)
|
||||
toRepay = toRepay.Sub(marginAsset.Low)
|
||||
toRepay := b.Borrowed
|
||||
if !b.Available.IsZero() {
|
||||
toRepay = fixedpoint.Min(b.Borrowed, b.Available)
|
||||
} else {
|
||||
log.Errorf("available balance is 0: %#v", b)
|
||||
}
|
||||
|
||||
if !marginAsset.Low.IsZero() {
|
||||
toRepay = toRepay.Sub(marginAsset.Low)
|
||||
}
|
||||
|
||||
if toRepay.Sign() <= 0 {
|
||||
log.Warnf("%s repay = %f, available = %f, borrowed = %f, can not repay",
|
||||
|
|
Loading…
Reference in New Issue
Block a user