Rename AbsoluteValues to Abs

This commit is contained in:
なるみ 2022-04-09 22:46:17 +08:00
parent 859933d4ed
commit 0de03e37fc
2 changed files with 4 additions and 4 deletions

View File

@ -37,8 +37,8 @@ func (inc *RSI) Update(kline types.KLine, priceF KLinePriceMapper) {
if len(inc.Prices) == inc.Window+1 {
priceDifferences := inc.Prices.Diff()
avgGain = priceDifferences.PositiveValuesOrZero().AbsoluteValues().Sum() / float64(inc.Window)
avgLoss = priceDifferences.NegativeValuesOrZero().AbsoluteValues().Sum() / float64(inc.Window)
avgGain = priceDifferences.PositiveValuesOrZero().Abs().Sum() / float64(inc.Window)
avgLoss = priceDifferences.NegativeValuesOrZero().Abs().Sum() / float64(inc.Window)
} else {
difference := price - inc.Prices[len(inc.Prices)-2]
currentGain := math.Max(difference, 0)

View File

@ -76,7 +76,7 @@ func (s Float64Slice) NegativeValuesOrZero() (values Float64Slice) {
return values
}
func (s Float64Slice) AbsoluteValues() (values Float64Slice) {
func (s Float64Slice) Abs() (values Float64Slice) {
for _, v := range s {
values.Push(math.Abs(v))
}
@ -113,6 +113,6 @@ func (s Float64Slice) Dot(other Float64Slice) float64 {
return floats.Dot(s, other)
}
func (s Float64Slice) Normalize() (values Float64Slice) {
func (s Float64Slice) Normalize() Float64Slice {
return s.DivScalar(s.Sum())
}