FIX: [grid2] fix quote accumulation

This commit is contained in:
gx578007 2023-02-17 22:52:58 +08:00
parent 03e25f12d6
commit 85d002eabc

View File

@ -1025,7 +1025,7 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
TimeInForce: types.TimeInForceGTC,
Tag: orderTag,
})
quoteQuantity := quantity.Mul(price)
quoteQuantity := quantity.Mul(nextPrice)
usedQuote = usedQuote.Add(quoteQuantity)
}
} else {
@ -1043,7 +1043,7 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
quoteQuantity := quantity.Mul(price)
if usedQuote.Add(quoteQuantity).Compare(totalQuote) > 0 {
s.logger.Warnf("used quote %f > total quote %f, this should not happen", usedQuote.Float64(), totalQuote.Float64())
s.logger.Warnf("used quote %f > total quote %f, this should not happen", usedQuote.Add(quoteQuantity).Float64(), totalQuote.Float64())
continue
}
@ -1592,4 +1592,4 @@ func (s *Strategy) openOrdersMismatches(ctx context.Context, session *bbgo.Excha
}
return false, nil
}
}