grid2: simplify and fix calculateMinimalQuoteInvestment

This commit is contained in:
c9s 2023-02-21 17:58:11 +08:00
parent 9c1110fb44
commit 03dfb4386e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1122,11 +1122,8 @@ func (s *Strategy) getLastTradePrice(ctx context.Context, session *bbgo.Exchange
func calculateMinimalQuoteInvestment(market types.Market, grid *Grid) fixedpoint.Value {
// upperPrice for buy order
upperPrice := grid.UpperPrice.Sub(grid.Spread)
minQuantity := fixedpoint.Max(
fixedpoint.Max(upperPrice.Mul(market.MinQuantity), market.MinNotional).Div(upperPrice),
market.MinQuantity,
)
lowerPrice := grid.LowerPrice
minQuantity := fixedpoint.Max(market.MinNotional.Div(lowerPrice), market.MinQuantity)
var pins = grid.Pins
var totalQuote = fixedpoint.Zero