mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: order executor should collect the created orders first before we retry
This commit is contained in:
parent
5f2254e2cb
commit
94780b39e6
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user