mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
grid2: fix upper price buy order issue
This commit is contained in:
parent
34ab53303a
commit
4eca007d3d
|
@ -956,7 +956,8 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
|
|||
})
|
||||
usedBase = usedBase.Add(quantity)
|
||||
} else if i > 0 {
|
||||
// next price
|
||||
// if we don't have enough base asset
|
||||
// then we need to place a buy order at the next price.
|
||||
nextPin := pins[i-1]
|
||||
nextPrice := fixedpoint.Value(nextPin)
|
||||
submitOrders = append(submitOrders, types.SubmitOrder{
|
||||
|
@ -975,10 +976,17 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
|
|||
// skip i == 0
|
||||
}
|
||||
} else {
|
||||
// if price spread is not enabled, and we have already placed a sell order index on the top of this price,
|
||||
// then we should skip
|
||||
if s.ProfitSpread.IsZero() && i+1 == si {
|
||||
continue
|
||||
}
|
||||
|
||||
// should never place a buy order at the upper price
|
||||
if i == len(pins)-1 {
|
||||
continue
|
||||
}
|
||||
|
||||
submitOrders = append(submitOrders, types.SubmitOrder{
|
||||
Symbol: s.Symbol,
|
||||
Type: types.OrderTypeLimit,
|
||||
|
|
Loading…
Reference in New Issue
Block a user