bbgo_origin/pkg/strategy/bollmaker/trend.go

31 lines
573 B
Go
Raw Normal View History

2022-06-02 18:15:23 +00:00
package bollmaker
2023-07-10 08:54:22 +00:00
import (
indicatorv2 "github.com/c9s/bbgo/pkg/indicator/v2"
)
2022-06-02 18:15:23 +00:00
type PriceTrend string
const (
NeutralTrend PriceTrend = "neutral"
UpTrend PriceTrend = "upTrend"
DownTrend PriceTrend = "downTrend"
UnknownTrend PriceTrend = "unknown"
)
2023-07-10 08:54:22 +00:00
func detectPriceTrend(inc *indicatorv2.BOLLStream, price float64) PriceTrend {
if inBetween(price, inc.DownBand.Last(0), inc.UpBand.Last(0)) {
2022-06-02 18:15:23 +00:00
return NeutralTrend
}
if price < inc.DownBand.Last(0) {
2022-06-02 18:15:23 +00:00
return DownTrend
}
if price > inc.UpBand.Last(0) {
2022-06-02 18:15:23 +00:00
return UpTrend
}
return UnknownTrend
}