mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
schedule: graceful cancel orders before the next submission
This commit is contained in:
parent
f6a300a7c4
commit
e0e27e75bb
|
@ -183,7 +183,6 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
}
|
||||
|
||||
if quoteBalance.Available.Compare(quoteQuantity) < 0 {
|
||||
bbgo.Notify("Can not place scheduled %s order: quote balance %s is not enough: %v < %v", s.Symbol, s.Market.QuoteCurrency, quoteBalance.Available, quoteQuantity)
|
||||
log.Errorf("can not place scheduled %s order: quote balance %s is not enough: %v < %v", s.Symbol, s.Market.QuoteCurrency, quoteBalance.Available, quoteQuantity)
|
||||
return
|
||||
}
|
||||
|
@ -220,6 +219,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
submitOrder.Price = closePrice
|
||||
}
|
||||
|
||||
if err := s.orderExecutor.GracefulCancel(ctx); err != nil {
|
||||
log.WithError(err).Errorf("cancel order error")
|
||||
}
|
||||
|
||||
bbgo.Notify("Submitting scheduled %s order with quantity %s at price %s", s.Symbol, quantity.String(), closePrice.String())
|
||||
_, err := s.orderExecutor.SubmitOrders(ctx, submitOrder)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user