grid2: fix quote investment algorithm

This commit is contained in:
c9s 2023-02-13 14:05:52 +08:00
parent 7ed0a0225e
commit 3df846d878
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -567,6 +567,11 @@ func (s *Strategy) calculateQuoteInvestmentQuantity(quoteInvestment, lastPrice f
continue continue
} }
// should never place a buy order at the upper price
if i == len(pins)-1 {
continue
}
totalQuotePrice = totalQuotePrice.Add(price) totalQuotePrice = totalQuotePrice.Add(price)
} }
} }
@ -645,6 +650,11 @@ func (s *Strategy) calculateQuoteBaseInvestmentQuantity(quoteInvestment, baseInv
continue continue
} }
// should never place a buy order at the upper price
if i == len(pins)-1 {
continue
}
totalQuotePrice = totalQuotePrice.Add(price) totalQuotePrice = totalQuotePrice.Add(price)
} }
} }