From 74ee92832b8d6f163789e8d60e87906cb8e7635e Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 5 Jun 2022 12:56:40 +0800 Subject: [PATCH] pivotshort: rename pivotBuffer to pivotLowPrices --- pkg/strategy/pivotshort/strategy.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/strategy/pivotshort/strategy.go b/pkg/strategy/pivotshort/strategy.go index ba31328c3..682acf50a 100644 --- a/pkg/strategy/pivotshort/strategy.go +++ b/pkg/strategy/pivotshort/strategy.go @@ -66,8 +66,8 @@ type Strategy struct { session *bbgo.ExchangeSession - pivot *indicator.Pivot - pivotBuffer []fixedpoint.Value + pivot *indicator.Pivot + pivotLowPrices []fixedpoint.Value // StrategyController bbgo.StrategyController @@ -187,9 +187,9 @@ func canClosePosition(position *types.Position, signal fixedpoint.Value, price f // get last available pivot low, the most recent pivot point higher than current price func (s *Strategy) getValidPivotLow(price fixedpoint.Value) fixedpoint.Value { - for l := len(s.pivotBuffer) - 1; l > 0; l-- { - if s.pivotBuffer[l].Compare(price) > 0 { - return s.pivotBuffer[l] + for l := len(s.pivotLowPrices) - 1; l > 0; l-- { + if s.pivotLowPrices[l].Compare(price) > 0 { + return s.pivotLowPrices[l] } } return price @@ -341,7 +341,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se if !s.LastLow.IsZero() { - s.pivotBuffer = append(s.pivotBuffer, s.LastLow) + s.pivotLowPrices = append(s.pivotLowPrices, s.LastLow) if err := s.activeMakerOrders.GracefulCancel(ctx, s.session.Exchange); err != nil { log.WithError(err).Errorf("graceful cancel order error")