always check restQuantity

This commit is contained in:
c9s 2021-05-15 10:00:32 +08:00
parent 638cc40516
commit aa340f0db3

View File

@ -152,6 +152,13 @@ func (e *TwapExecution) newBestPriceOrder() (orderForm types.SubmitOrder, err er
minQuantity := fixedpoint.NewFromFloat(e.market.MinQuantity)
restQuantity := e.TargetQuantity - fixedpoint.Abs(e.position.Base)
if restQuantity == 0 {
if e.cancelContextIfTargetQuantityFilled() {
return
}
}
if restQuantity < minQuantity {
return orderForm, fmt.Errorf("can not continue placing orders, rest quantity %f is less than the min quantity %f", restQuantity.Float64(), minQuantity.Float64())
}