mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Rename AbsoluteValues to Abs
This commit is contained in:
parent
859933d4ed
commit
0de03e37fc
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user