From 980f1ae3e7598ececcdc4df6c018012e4b1dbfa3 Mon Sep 17 00:00:00 2001 From: Larry850806 Date: Thu, 15 Apr 2021 12:13:15 +0800 Subject: [PATCH] bollgrid: submit buy/sell orders separately --- pkg/strategy/bollgrid/strategy.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/strategy/bollgrid/strategy.go b/pkg/strategy/bollgrid/strategy.go index 8fc6066a4..06a25324e 100644 --- a/pkg/strategy/bollgrid/strategy.go +++ b/pkg/strategy/bollgrid/strategy.go @@ -240,20 +240,23 @@ func (s *Strategy) placeGridOrders(orderExecutor bbgo.OrderExecutor, session *bb if err != nil { log.Warn(err.Error()) } + createdSellOrders, err := orderExecutor.SubmitOrders(context.Background(), sellOrders...) + if err != nil { + log.WithError(err).Errorf("can not place sell orders") + } + buyOrders, err := s.generateGridBuyOrders(session) if err != nil { log.Warn(err.Error()) } + createdBuyOrders, err := orderExecutor.SubmitOrders(context.Background(), buyOrders...) + if err != nil { + log.WithError(err).Errorf("can not place buy orders") + } - orders := append(sellOrders, buyOrders...) - - createdOrders, err := orderExecutor.SubmitOrders(context.Background(), orders...) + createdOrders := append(createdSellOrders, createdBuyOrders...) s.activeOrders.Add(createdOrders...) s.orders.Add(createdOrders...) - - if err != nil { - log.WithError(err).Errorf("can not place orders") - } } func (s *Strategy) updateOrders(orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) {