grid2: check buy placed order price

This commit is contained in:
c9s 2022-11-25 15:05:11 +08:00
parent 020e7c8604
commit 622fe75ed3
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -209,7 +209,7 @@ func (s *Strategy) checkRequiredInvestmentByQuantity(baseBalance, quoteBalance,
}
} else {
// for orders that buy
if price.Compare(buyPlacedPrice) == 0 {
if !buyPlacedPrice.IsZero() && price.Compare(buyPlacedPrice) == 0 {
continue
}
requiredQuote = requiredQuote.Add(quantity.Mul(price))
@ -269,7 +269,7 @@ func (s *Strategy) checkRequiredInvestmentByAmount(baseBalance, quoteBalance, am
}
} else {
// for orders that buy
if price.Compare(buyPlacedPrice) == 0 {
if !buyPlacedPrice.IsZero() && price.Compare(buyPlacedPrice) == 0 {
continue
}
requiredQuote = requiredQuote.Add(amount)
@ -398,7 +398,7 @@ func (s *Strategy) setupGridOrders(ctx context.Context, session *bbgo.ExchangeSe
buyPlacedPrice = nextPrice
}
} else {
if price.Compare(buyPlacedPrice) >= 0 {
if !buyPlacedPrice.IsZero() && price.Compare(buyPlacedPrice) >= 0 {
continue
}