From 9733eec28072ea7dfc5ac20e8829fbacc1f03fb3 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 29 Jun 2022 17:59:33 +0800 Subject: [PATCH] pivotshort: move pure funcs to the bottom --- pkg/strategy/pivotshort/strategy.go | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/pkg/strategy/pivotshort/strategy.go b/pkg/strategy/pivotshort/strategy.go index 7141c0483..ed0042f7c 100644 --- a/pkg/strategy/pivotshort/strategy.go +++ b/pkg/strategy/pivotshort/strategy.go @@ -453,31 +453,6 @@ func (s *Strategy) preloadPivot(pivot *indicator.Pivot, store *bbgo.MarketDataSt return &last } -func findPossibleResistancePrices(closePrice float64, minDistance float64, lows []float64) []float64 { - // sort float64 in increasing order - sort.Float64s(lows) - - var resistancePrices []float64 - for _, low := range lows { - if low < closePrice { - continue - } - - last := closePrice - if len(resistancePrices) > 0 { - last = resistancePrices[len(resistancePrices)-1] - } - - if (low / last) < (1.0 + minDistance) { - continue - } - resistancePrices = append(resistancePrices, low) - } - - return resistancePrices -} - - func (s *Strategy) useQuantityOrBaseBalance(quantity fixedpoint.Value) fixedpoint.Value { balance, hasBalance := s.session.Account.Balance(s.Market.BaseCurrency) @@ -520,3 +495,26 @@ func (s *Strategy) placeMarketSell(ctx context.Context, quantity fixedpoint.Valu }) } +func findPossibleResistancePrices(closePrice float64, minDistance float64, lows []float64) []float64 { + // sort float64 in increasing order + sort.Float64s(lows) + + var resistancePrices []float64 + for _, low := range lows { + if low < closePrice { + continue + } + + last := closePrice + if len(resistancePrices) > 0 { + last = resistancePrices[len(resistancePrices)-1] + } + + if (low / last) < (1.0 + minDistance) { + continue + } + resistancePrices = append(resistancePrices, low) + } + + return resistancePrices +}