bbgo: order executor should collect the created orders first before we retry

This commit is contained in:
c9s 2022-09-09 17:55:51 +08:00
parent 5f2254e2cb
commit 94780b39e6
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -110,14 +110,25 @@ func (e *GeneralOrderExecutor) SubmitOrders(ctx context.Context, submitOrders ..
return nil, err return nil, err
} }
createdOrders, err := e.session.Exchange.SubmitOrders(ctx, formattedOrders...) var createdOrders types.OrderSlice
retOrders, err := e.session.Exchange.SubmitOrders(ctx, formattedOrders...)
if len(retOrders) > 0 {
createdOrders = append(createdOrders, retOrders...)
}
if err != nil { if err != nil {
// Retry once // retry once
createdOrders, err = e.session.Exchange.SubmitOrders(ctx, formattedOrders...) retOrders, err = e.session.Exchange.SubmitOrders(ctx, formattedOrders...)
if len(retOrders) > 0 {
createdOrders = append(createdOrders, retOrders...)
}
if err != nil { if err != nil {
err = fmt.Errorf("can not place orders: %w", err) err = fmt.Errorf("can not place orders: %w", err)
} }
} }
// FIXME: map by price and volume // FIXME: map by price and volume
for i := 0; i < len(createdOrders); i++ { for i := 0; i < len(createdOrders); i++ {
createdOrders[i].Tag = formattedOrders[i].Tag createdOrders[i].Tag = formattedOrders[i].Tag