grid2: apply baseGridNumber

This commit is contained in:
c9s 2023-05-22 18:07:40 +08:00
parent f11d869d02
commit 0c6ef38ea3
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -91,6 +91,9 @@ type Strategy struct {
// GridNum is the grid number, how many orders you want to post on the orderbook.
GridNum int64 `json:"gridNumber"`
// BaseGridNum is an optional field used for base investment sell orders
BaseGridNum int `json:"baseGridNumber,omitempty"`
AutoRange *types.SimpleDuration `json:"autoRange"`
UpperPrice fixedpoint.Value `json:"upperPrice"`
@ -761,7 +764,10 @@ func (s *Strategy) calculateBaseQuoteInvestmentQuantity(quoteInvestment, baseInv
// maxBaseQuantity = baseInvestment / numberOfSellOrders
// if maxBaseQuantity < minQuantity or maxBaseQuantity * priceLowest < minNotional
// then reduce the numberOfSellOrders
numberOfSellOrders := 0
numberOfSellOrders := s.BaseGridNum
// if it's not configured
if numberOfSellOrders == 0 {
for i := len(pins) - 1; i >= 0; i-- {
pin := pins[i]
price := fixedpoint.Value(pin)
@ -781,6 +787,7 @@ func (s *Strategy) calculateBaseQuoteInvestmentQuantity(quoteInvestment, baseInv
if numberOfSellOrders > 0 {
numberOfSellOrders--
}
}
// if the maxBaseQuantity is less than minQuantity, then we need to reduce the number of the sell orders
// so that the quantity can be increased.