mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
fix rollupOpen(), rollupHigh(), rollupLow() functions (#328)
This commit is contained in:
parent
04762344c6
commit
a6d0645539
1 changed files with 9 additions and 18 deletions
|
@ -1435,12 +1435,9 @@ func getCandlestickValues(rfa *rollupFuncArg) []float64 {
|
|||
}
|
||||
|
||||
func rollupOpen(rfa *rollupFuncArg) float64 {
|
||||
if !math.IsNaN(rfa.prevValue) {
|
||||
return rfa.prevValue
|
||||
}
|
||||
values := getCandlestickValues(rfa)
|
||||
if len(values) == 0 {
|
||||
return nan
|
||||
return rfa.prevValue
|
||||
}
|
||||
return values[0]
|
||||
}
|
||||
|
@ -1455,14 +1452,11 @@ func rollupClose(rfa *rollupFuncArg) float64 {
|
|||
|
||||
func rollupHigh(rfa *rollupFuncArg) float64 {
|
||||
values := getCandlestickValues(rfa)
|
||||
max := rfa.prevValue
|
||||
if math.IsNaN(max) {
|
||||
if len(values) == 0 {
|
||||
return nan
|
||||
return rfa.prevValue
|
||||
}
|
||||
max = values[0]
|
||||
}
|
||||
for _, v := range values {
|
||||
max := values[0]
|
||||
for _, v := range values[1:] {
|
||||
if v > max {
|
||||
max = v
|
||||
}
|
||||
|
@ -1472,14 +1466,11 @@ func rollupHigh(rfa *rollupFuncArg) float64 {
|
|||
|
||||
func rollupLow(rfa *rollupFuncArg) float64 {
|
||||
values := getCandlestickValues(rfa)
|
||||
min := rfa.prevValue
|
||||
if math.IsNaN(min) {
|
||||
if len(values) == 0 {
|
||||
return nan
|
||||
return rfa.prevValue
|
||||
}
|
||||
min = values[0]
|
||||
}
|
||||
for _, v := range values {
|
||||
min := values[0]
|
||||
for _, v := range values[1:] {
|
||||
if v < min {
|
||||
min = v
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue