FEATURE: round down executed amount to avoid insufficient balance

This commit is contained in:
chiahung 2023-08-31 12:40:01 +08:00
parent 2c4b6e8cd1
commit 9dc7244d8a

View File

@ -460,6 +460,8 @@ func (s *Strategy) processFilledOrder(o types.Order) {
// will be used for calculating quantity // will be used for calculating quantity
orderExecutedQuoteAmount := executedQuantity.Mul(executedPrice) orderExecutedQuoteAmount := executedQuantity.Mul(executedPrice)
// round down order executed quote amount to avoid insufficient balance
orderExecutedQuoteAmount = orderExecutedQuoteAmount.Round(s.Market.PricePrecision, fixedpoint.Down)
// collect trades for fee // collect trades for fee
// fee calculation is used to reduce the order quantity // fee calculation is used to reduce the order quantity