mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
binance: fix margin order cancel
This commit is contained in:
parent
1a820936c4
commit
2ef4d713f8
|
@ -535,22 +535,38 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
|
|||
return err
|
||||
}
|
||||
|
||||
|
||||
for _, o := range orders {
|
||||
var req = e.Client.NewCancelOrderService()
|
||||
if e.IsMargin {
|
||||
var req = e.Client.NewCancelMarginOrderService()
|
||||
req.Symbol(o.Symbol)
|
||||
|
||||
// Mandatory
|
||||
req.Symbol(o.Symbol)
|
||||
if o.OrderID > 0 {
|
||||
req.OrderID(int64(o.OrderID))
|
||||
} else if len(o.ClientOrderID) > 0 {
|
||||
req.NewClientOrderID(o.ClientOrderID)
|
||||
}
|
||||
|
||||
if o.OrderID > 0 {
|
||||
req.OrderID(int64(o.OrderID))
|
||||
} else if len(o.ClientOrderID) > 0 {
|
||||
req.NewClientOrderID(o.ClientOrderID)
|
||||
}
|
||||
_, _err := req.Do(ctx)
|
||||
if _err != nil {
|
||||
log.WithError(_err).Errorf("order cancel error")
|
||||
err = multierr.Append(err, _err)
|
||||
}
|
||||
} else {
|
||||
var req = e.Client.NewCancelOrderService()
|
||||
req.Symbol(o.Symbol)
|
||||
|
||||
_, _err := req.Do(ctx)
|
||||
if _err != nil {
|
||||
log.WithError(_err).Errorf("order cancel error")
|
||||
err = multierr.Append(err, _err)
|
||||
if o.OrderID > 0 {
|
||||
req.OrderID(int64(o.OrderID))
|
||||
} else if len(o.ClientOrderID) > 0 {
|
||||
req.NewClientOrderID(o.ClientOrderID)
|
||||
}
|
||||
|
||||
_, _err := req.Do(ctx)
|
||||
if _err != nil {
|
||||
log.WithError(_err).Errorf("order cancel error")
|
||||
err = multierr.Append(err, _err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user