mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
grid2: fix quantity calculation
This commit is contained in:
parent
e80c8f2959
commit
22569fcb30
|
@ -360,7 +360,7 @@ func (s *Strategy) calculateQuoteBaseInvestmentQuantity(quoteInvestment, baseInv
|
|||
maxNumberOfSellOrders := numberOfSellOrders + 1
|
||||
minBaseQuantity := fixedpoint.Max(s.Market.MinNotional.Div(lastPrice), s.Market.MinQuantity)
|
||||
maxBaseQuantity := fixedpoint.Zero
|
||||
for maxBaseQuantity.Compare(s.Market.MinQuantity) <= 0 {
|
||||
for maxBaseQuantity.Compare(s.Market.MinQuantity) <= 0 || maxBaseQuantity.Compare(minBaseQuantity) <= 0 {
|
||||
maxNumberOfSellOrders--
|
||||
maxBaseQuantity = baseInvestment.Div(fixedpoint.NewFromInt(int64(maxNumberOfSellOrders)))
|
||||
}
|
||||
|
@ -398,7 +398,8 @@ func (s *Strategy) calculateQuoteBaseInvestmentQuantity(quoteInvestment, baseInv
|
|||
}
|
||||
}
|
||||
|
||||
return quoteInvestment.Div(totalQuotePrice), nil
|
||||
quoteSideQuantity := quoteInvestment.Div(totalQuotePrice)
|
||||
return fixedpoint.Max(quoteSideQuantity, maxBaseQuantity), nil
|
||||
}
|
||||
|
||||
// setupGridOrders
|
||||
|
|
Loading…
Reference in New Issue
Block a user