mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
autoborrow: improve available balance checking
This commit is contained in:
parent
b7c9ef7983
commit
4cb9ff569a
|
@ -216,12 +216,14 @@ func (s *Strategy) reBalanceDebt(ctx context.Context) {
|
||||||
log.Infof("checking repayable balance: %+v", b)
|
log.Infof("checking repayable balance: %+v", b)
|
||||||
|
|
||||||
toRepay := debt
|
toRepay := debt
|
||||||
if !b.Available.IsZero() {
|
|
||||||
toRepay = fixedpoint.Min(toRepay, b.Available)
|
if b.Available.IsZero() {
|
||||||
} else {
|
log.Errorf("%s available balance is 0, can not repay, balance = %+v", marginAsset.Asset, b)
|
||||||
log.Errorf("available balance is 0: %#v", b)
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toRepay = fixedpoint.Min(toRepay, b.Available)
|
||||||
|
|
||||||
if !marginAsset.Low.IsZero() {
|
if !marginAsset.Low.IsZero() {
|
||||||
toRepay = toRepay.Sub(marginAsset.Low)
|
toRepay = toRepay.Sub(marginAsset.Low)
|
||||||
}
|
}
|
||||||
|
@ -235,6 +237,8 @@ func (s *Strategy) reBalanceDebt(ctx context.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("%s repay %f", marginAsset.Asset, toRepay.Float64())
|
||||||
|
|
||||||
bbgo.Notify(&MarginAction{
|
bbgo.Notify(&MarginAction{
|
||||||
Exchange: s.ExchangeSession.ExchangeName,
|
Exchange: s.ExchangeSession.ExchangeName,
|
||||||
Action: fmt.Sprintf("Repay for Debt Ratio %f < Minimal Debt Ratio %f", debtRatio.Float64(), marginAsset.DebtRatio.Float64()),
|
Action: fmt.Sprintf("Repay for Debt Ratio %f < Minimal Debt Ratio %f", debtRatio.Float64(), marginAsset.DebtRatio.Float64()),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user