mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
pivotshort: move pure funcs to the bottom
This commit is contained in:
parent
38767cd2df
commit
9733eec280
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user