mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
Rename functions
This commit is contained in:
parent
2a6f1f410d
commit
42d6bf03b5
|
@ -37,8 +37,8 @@ func (inc *RSI) Update(kline types.KLine, priceF KLinePriceMapper) {
|
||||||
if len(inc.Prices) == inc.Window+1 {
|
if len(inc.Prices) == inc.Window+1 {
|
||||||
diffValues := inc.Prices.Diff()
|
diffValues := inc.Prices.Diff()
|
||||||
|
|
||||||
avgGain = diffValues.PositiveValues().AbsoluteValues().Sum() / float64(inc.Window)
|
avgGain = diffValues.PositiveValuesOrZero().AbsoluteValues().Sum() / float64(inc.Window)
|
||||||
avgLoss = diffValues.NegativeValues().AbsoluteValues().Sum() / float64(inc.Window)
|
avgLoss = diffValues.NegativeValuesOrZero().AbsoluteValues().Sum() / float64(inc.Window)
|
||||||
} else {
|
} else {
|
||||||
diff := price - inc.Prices[len(inc.Prices)-2]
|
diff := price - inc.Prices[len(inc.Prices)-2]
|
||||||
currentGain := math.Max(diff, 0)
|
currentGain := math.Max(diff, 0)
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (s Float64Slice) Diff() Float64Slice {
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Float64Slice) PositiveValues() Float64Slice {
|
func (s Float64Slice) PositiveValuesOrZero() Float64Slice {
|
||||||
var values Float64Slice
|
var values Float64Slice
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
values.Push(math.Max(v, 0))
|
values.Push(math.Max(v, 0))
|
||||||
|
@ -74,7 +74,7 @@ func (s Float64Slice) PositiveValues() Float64Slice {
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Float64Slice) NegativeValues() Float64Slice {
|
func (s Float64Slice) NegativeValuesOrZero() Float64Slice {
|
||||||
var values Float64Slice
|
var values Float64Slice
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
values.Push(math.Min(v, 0))
|
values.Push(math.Min(v, 0))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user