mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
grid2: improve base quote investment check
This commit is contained in:
parent
cf5d71b4bc
commit
8c09c9668a
|
@ -850,12 +850,16 @@ func (s *Strategy) calculateBaseQuoteInvestmentQuantity(quoteInvestment, baseInv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quoteSideQuantity := quoteInvestment.Div(totalQuotePrice)
|
if totalQuotePrice.Sign() > 0 && quoteInvestment.Sign() > 0 {
|
||||||
if numberOfSellOrders > 0 {
|
quoteSideQuantity := quoteInvestment.Div(totalQuotePrice)
|
||||||
return fixedpoint.Min(quoteSideQuantity, baseQuantity), nil
|
if numberOfSellOrders > 0 {
|
||||||
|
return fixedpoint.Min(quoteSideQuantity, baseQuantity), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return quoteSideQuantity, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return quoteSideQuantity, nil
|
return baseQuantity, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) newTriggerPriceHandler(ctx context.Context, session *bbgo.ExchangeSession) types.KLineCallback {
|
func (s *Strategy) newTriggerPriceHandler(ctx context.Context, session *bbgo.ExchangeSession) types.KLineCallback {
|
||||||
|
@ -1079,7 +1083,7 @@ func (s *Strategy) openGrid(ctx context.Context, session *bbgo.ExchangeSession)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// calculate the quantity from the investment configuration
|
// calculate the quantity from the investment configuration
|
||||||
if !s.QuoteInvestment.IsZero() && !s.BaseInvestment.IsZero() {
|
if !s.BaseInvestment.IsZero() {
|
||||||
quantity, err2 := s.calculateBaseQuoteInvestmentQuantity(s.QuoteInvestment, s.BaseInvestment, lastPrice, s.grid.Pins)
|
quantity, err2 := s.calculateBaseQuoteInvestmentQuantity(s.QuoteInvestment, s.BaseInvestment, lastPrice, s.grid.Pins)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
s.EmitGridError(err2)
|
s.EmitGridError(err2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user