Merge pull request #748 from andycheng123/improve/bollmaker

bollmaker: remove redundant code for adapting new order executor api
This commit is contained in:
Yo-An Lin 2022-06-21 00:26:41 +08:00 committed by GitHub
commit 0e877b789e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,7 +269,7 @@ func (s *Strategy) getCurrentAllowedExposurePosition(bandPercentage float64) (fi
return s.MaxExposurePosition, nil return s.MaxExposurePosition, nil
} }
func (s *Strategy) placeOrders(ctx context.Context, orderExecutor bbgo.OrderExecutor, midPrice fixedpoint.Value, kline *types.KLine) { func (s *Strategy) placeOrders(ctx context.Context, midPrice fixedpoint.Value, kline *types.KLine) {
bidSpread := s.Spread bidSpread := s.Spread
if s.BidSpread.Sign() > 0 { if s.BidSpread.Sign() > 0 {
bidSpread = s.BidSpread bidSpread = s.BidSpread
@ -598,10 +598,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
} }
midPrice := ticker.Buy.Add(ticker.Sell).Div(two) midPrice := ticker.Buy.Add(ticker.Sell).Div(two)
s.placeOrders(ctx, orderExecutor, midPrice, nil) s.placeOrders(ctx, midPrice, nil)
} else { } else {
if price, ok := session.LastPrice(s.Symbol); ok { if price, ok := session.LastPrice(s.Symbol); ok {
s.placeOrders(ctx, orderExecutor, price, nil) s.placeOrders(ctx, price, nil)
} }
} }
}) })
@ -641,9 +641,9 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
midPrice := ticker.Buy.Add(ticker.Sell).Div(two) midPrice := ticker.Buy.Add(ticker.Sell).Div(two)
log.Infof("using ticker price: bid %v / ask %v, mid price %v", ticker.Buy, ticker.Sell, midPrice) log.Infof("using ticker price: bid %v / ask %v, mid price %v", ticker.Buy, ticker.Sell, midPrice)
s.placeOrders(ctx, orderExecutor, midPrice, &kline) s.placeOrders(ctx, midPrice, &kline)
} else { } else {
s.placeOrders(ctx, orderExecutor, kline.Close, &kline) s.placeOrders(ctx, kline.Close, &kline)
} }
}) })