mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #1062 from c9s/fix/grid2/recover-sorting
fix: grid2: fix recover sorting
This commit is contained in:
commit
09db017101
|
@ -223,6 +223,8 @@ func (e *GeneralOrderExecutor) SubmitOrders(ctx context.Context, submitOrders ..
|
|||
}
|
||||
|
||||
if len(errIdx) > 0 {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
createdOrders2, err2 := BatchRetryPlaceOrder(ctx, e.session.Exchange, errIdx, formattedOrders...)
|
||||
if err2 != nil {
|
||||
err = multierr.Append(err, err2)
|
||||
|
|
|
@ -1238,9 +1238,9 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
|
|||
// for reverse order recovering, we need the orders to be sort by update time ascending-ly
|
||||
types.SortOrdersUpdateTimeAscending(tmpOrders)
|
||||
|
||||
if len(tmpOrders) > 1 && len(tmpOrders) == int(s.GridNum)+1 {
|
||||
if len(tmpOrders) > 1 && len(tmpOrders) == int(s.GridNum) {
|
||||
// remove the latest updated order because it's near the empty slot
|
||||
tmpOrders = tmpOrders[:len(tmpOrders)-1]
|
||||
tmpOrders = tmpOrders[1:]
|
||||
}
|
||||
|
||||
// we will only submit reverse orders for filled orders
|
||||
|
@ -1248,7 +1248,7 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
|
|||
|
||||
s.logger.Infof("GRID RECOVER: found %d filled grid orders, will re-replay the order event in the following order:", len(filledOrders))
|
||||
for i, o := range filledOrders {
|
||||
s.logger.Infof("%d) %s", i, o.String())
|
||||
s.logger.Infof("%d) %s", i+1, o.String())
|
||||
}
|
||||
|
||||
// before we re-play the orders,
|
||||
|
@ -1264,8 +1264,12 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
|
|||
|
||||
for _, o := range filledOrders {
|
||||
s.processFilledOrder(o)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
// wait for the reverse order to be placed
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
s.logger.Infof("GRID RECOVER COMPLETE")
|
||||
|
||||
debugGrid(grid, s.orderExecutor.ActiveMakerOrders())
|
||||
|
|
Loading…
Reference in New Issue
Block a user