grid2: calculate minBaseQuantity

This commit is contained in:
c9s 2022-11-30 12:55:23 +08:00
parent 45328a9f3d
commit 46bebb1022
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -358,11 +358,13 @@ func (s *Strategy) calculateQuoteBaseInvestmentQuantity(quoteInvestment, baseInv
// if the maxBaseQuantity is less than minQuantity, then we need to reduce the number of the sell orders
// so that the quantity can be increased.
numberOfSellOrders++
minBaseQuantity := fixedpoint.Max(s.Market.MinNotional.Div(lastPrice), s.Market.MinQuantity)
maxBaseQuantity := fixedpoint.Zero
for maxBaseQuantity.Compare(s.Market.MinQuantity) <= 0 {
numberOfSellOrders--
maxBaseQuantity = baseInvestment.Div(fixedpoint.NewFromInt(int64(numberOfSellOrders)))
}
log.Infof("grid %s base investment quantity range: %f <=> %f", s.Symbol, minBaseQuantity.Float64(), maxBaseQuantity.Float64())
buyPlacedPrice := fixedpoint.Zero
totalQuotePrice := fixedpoint.Zero