grid2: round up minBaseQuantity

This commit is contained in:
c9s 2023-05-19 16:46:17 +08:00
parent 4c13171cb0
commit c93a3d14b3
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 6 additions and 0 deletions

View File

@ -793,6 +793,7 @@ func (s *Strategy) calculateBaseQuoteInvestmentQuantity(quoteInvestment, baseInv
if baseQuantity.Compare(minBaseQuantity) <= 0 {
numberOfSellOrders = int(math.Floor(baseInvestment.Div(minBaseQuantity).Float64()))
baseQuantity = s.Market.RoundUpQuantityByPrecision(minBaseQuantity)
}
s.logger.Infof("grid base investment sell orders: %d", numberOfSellOrders)

View File

@ -76,6 +76,11 @@ func (m Market) RoundDownQuantityByPrecision(quantity fixedpoint.Value) fixedpoi
return quantity.Round(m.VolumePrecision, fixedpoint.Down)
}
// RoundUpQuantityByPrecision uses the volume precision to round up the quantity
func (m Market) RoundUpQuantityByPrecision(quantity fixedpoint.Value) fixedpoint.Value {
return quantity.Round(m.VolumePrecision, fixedpoint.Up)
}
func (m Market) TruncatePrice(price fixedpoint.Value) fixedpoint.Value {
return fixedpoint.MustNewFromString(m.FormatPrice(price))
}