risk: return quantity directly if it's not zero

This commit is contained in:
c9s 2022-07-27 01:28:18 +08:00
parent 578e4b2801
commit 076f196621
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -164,6 +164,7 @@ func CalculateBaseQuantity(session *bbgo.ExchangeSession, market types.Market, p
leverage = fixedpoint.NewFromInt(3)
}
baseBalance, _ := session.Account.Balance(market.BaseCurrency)
quoteBalance, _ := session.Account.Balance(market.QuoteCurrency)
@ -185,11 +186,11 @@ func CalculateBaseQuantity(session *bbgo.ExchangeSession, market types.Market, p
return quantity, fmt.Errorf("quantity is zero, can not submit sell order, please check your quantity settings")
}
// using leverage -- starts from here
if !quantity.IsZero() {
return quantity, nil
}
// using leverage -- starts from here
logrus.Infof("calculating available leveraged base quantity: base balance = %+v, quote balance = %+v", baseBalance, quoteBalance)
// calculate the quantity automatically