pivotshort: move pure funcs to the bottom

This commit is contained in:
c9s 2022-06-29 17:59:33 +08:00
parent 38767cd2df
commit 9733eec280
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -453,31 +453,6 @@ func (s *Strategy) preloadPivot(pivot *indicator.Pivot, store *bbgo.MarketDataSt
return &last 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 { func (s *Strategy) useQuantityOrBaseBalance(quantity fixedpoint.Value) fixedpoint.Value {
balance, hasBalance := s.session.Account.Balance(s.Market.BaseCurrency) 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
}