diff --git a/pkg/strategy/bollmaker/strategy.go b/pkg/strategy/bollmaker/strategy.go index a48eba33d..25a7859c3 100644 --- a/pkg/strategy/bollmaker/strategy.go +++ b/pkg/strategy/bollmaker/strategy.go @@ -215,34 +215,7 @@ func (s *Strategy) CurrentPosition() *types.Position { } func (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error { - base := s.Position.GetBase() - if base.IsZero() { - return fmt.Errorf("no opened %s position", s.Position.Symbol) - } - - // make it negative - quantity := base.Mul(percentage).Abs() - side := types.SideTypeBuy - if base.Sign() > 0 { - side = types.SideTypeSell - } - - if quantity.Compare(s.Market.MinQuantity) < 0 { - return fmt.Errorf("order quantity %v is too small, less than %v", quantity, s.Market.MinQuantity) - } - - submitOrder := types.SubmitOrder{ - Symbol: s.Symbol, - Side: side, - Type: types.OrderTypeMarket, - Quantity: quantity, - Market: s.Market, - } - - bbgo.Notify("Submitting %s %s order to close position by %v", s.Symbol, side.String(), percentage, submitOrder) - - _, err := s.orderExecutor.SubmitOrders(ctx, submitOrder) - return err + return s.orderExecutor.ClosePosition(ctx, percentage) } // Deprecated: LoadState method is migrated to the persistence struct tag.