mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
tradingutil: return anyErr if anyErr is not nil
This commit is contained in:
parent
3b8a3bed5f
commit
0b0bc7e179
|
@ -41,9 +41,9 @@ func UniversalCancelAllOrders(ctx context.Context, exchange types.Exchange, open
|
||||||
return errors.New("to cancel all orders, openOrders can not be empty")
|
return errors.New("to cancel all orders, openOrders can not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var anyErr error
|
||||||
if service, ok := exchange.(CancelAllOrdersBySymbolService); ok {
|
if service, ok := exchange.(CancelAllOrdersBySymbolService); ok {
|
||||||
var symbols = CollectOrderSymbols(openOrders)
|
var symbols = CollectOrderSymbols(openOrders)
|
||||||
var anyErr error
|
|
||||||
for _, symbol := range symbols {
|
for _, symbol := range symbols {
|
||||||
_, err := service.CancelOrdersBySymbol(ctx, symbol)
|
_, err := service.CancelOrdersBySymbol(ctx, symbol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -58,7 +58,6 @@ func UniversalCancelAllOrders(ctx context.Context, exchange types.Exchange, open
|
||||||
|
|
||||||
if service, ok := exchange.(CancelAllOrdersByGroupIDService); ok {
|
if service, ok := exchange.(CancelAllOrdersByGroupIDService); ok {
|
||||||
var groupIds = CollectOrderGroupIds(openOrders)
|
var groupIds = CollectOrderGroupIds(openOrders)
|
||||||
var anyErr error
|
|
||||||
for _, groupId := range groupIds {
|
for _, groupId := range groupIds {
|
||||||
if _, err := service.CancelOrdersByGroupID(ctx, groupId); err != nil {
|
if _, err := service.CancelOrdersByGroupID(ctx, groupId); err != nil {
|
||||||
anyErr = err
|
anyErr = err
|
||||||
|
@ -70,7 +69,11 @@ func UniversalCancelAllOrders(ctx context.Context, exchange types.Exchange, open
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("unable to cancel all orders: %+v", openOrders)
|
if anyErr != nil {
|
||||||
|
return anyErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("unable to cancel all orders, openOrders:%+v", openOrders)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CollectOrderGroupIds(orders []types.Order) (groupIds []uint32) {
|
func CollectOrderGroupIds(orders []types.Order) (groupIds []uint32) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user