mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
fix(bollgrid): skip canceling profit order on graceful exit
profit orders shouldn't be canceled on graceful exit unless properly persisted. a new strategy parameter `shutdownCancelProfitOrders` is added. Issue: #220
This commit is contained in:
parent
3f39131d76
commit
da0ea3d390
|
@ -83,6 +83,8 @@ type Strategy struct {
|
||||||
|
|
||||||
// boll is the BOLLINGER indicator we used for predicting the price.
|
// boll is the BOLLINGER indicator we used for predicting the price.
|
||||||
boll *indicator.BOLL
|
boll *indicator.BOLL
|
||||||
|
|
||||||
|
CancelProfitOrdersOnShutdown bool `json: "shutdownCancelProfitOrders"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) ID() string {
|
func (s *Strategy) ID() string {
|
||||||
|
@ -352,8 +354,13 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
log.WithError(err).Errorf("cancel order error")
|
log.WithError(err).Errorf("cancel order error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.Exchange.CancelOrders(ctx, s.profitOrders.Orders()...); err != nil {
|
if s.CancelProfitOrdersOnShutdown {
|
||||||
log.WithError(err).Errorf("cancel order error")
|
log.Infof("canceling profit orders...")
|
||||||
|
err := session.Exchange.CancelOrders(ctx, s.profitOrders.Orders()...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Errorf("cancel profit order error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user