adding validation.
This commit is contained in:
parent
3ea3c9ac10
commit
e735797037
20 changed files with 285 additions and 7 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package chart
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
// BollingerBandsSeries draws bollinger bands for an inner series.
|
||||
// Bollinger bands are defined by two lines, one at SMA+k*stddev, one at SMA-k*stdev.
|
||||
|
|
@ -147,3 +150,11 @@ func (bbs BollingerBandsSeries) getVariance(valueBuffer *RingBuffer) float64 {
|
|||
func (bbs BollingerBandsSeries) getStdDev(valueBuffer *RingBuffer) float64 {
|
||||
return math.Pow(bbs.getVariance(valueBuffer), 0.5)
|
||||
}
|
||||
|
||||
// Validate validates the series.
|
||||
func (bbs BollingerBandsSeries) Validate() error {
|
||||
if bbs.InnerSeries == nil {
|
||||
return fmt.Errorf("bollinger bands series requires InnerSeries to be set")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue