From 3df846d878c3379b5875e7660c7b086af5db5a59 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 13 Feb 2023 14:05:52 +0800 Subject: [PATCH] grid2: fix quote investment algorithm --- pkg/strategy/grid2/strategy.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index cf38e4e7c..05d95ae53 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -567,6 +567,11 @@ func (s *Strategy) calculateQuoteInvestmentQuantity(quoteInvestment, lastPrice f continue } + // should never place a buy order at the upper price + if i == len(pins)-1 { + continue + } + totalQuotePrice = totalQuotePrice.Add(price) } } @@ -645,6 +650,11 @@ func (s *Strategy) calculateQuoteBaseInvestmentQuantity(quoteInvestment, baseInv continue } + // should never place a buy order at the upper price + if i == len(pins)-1 { + continue + } + totalQuotePrice = totalQuotePrice.Add(price) } }