indicator: rename BollStream to BOLLStream

This commit is contained in:
c9s 2023-06-09 18:38:12 +08:00
parent 295ae95da6
commit 0a5f31a80f
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1,6 +1,6 @@
package indicator package indicator
type BollStream struct { type BOLLStream struct {
// the band series // the band series
*Float64Series *Float64Series
@ -20,12 +20,12 @@ type BollStream struct {
// //
// -> calculate SMA // -> calculate SMA
// -> calculate stdDev -> calculate bandWidth -> get latest SMA -> upBand, downBand // -> calculate stdDev -> calculate bandWidth -> get latest SMA -> upBand, downBand
func BOLL2(source Float64Source, window int, k float64) *BollStream { func BOLL2(source Float64Source, window int, k float64) *BOLLStream {
// bind these indicators before our main calculator // bind these indicators before our main calculator
sma := SMA2(source, window) sma := SMA2(source, window)
stdDev := StdDev2(source, window) stdDev := StdDev2(source, window)
s := &BollStream{ s := &BOLLStream{
Float64Series: NewFloat64Series(), Float64Series: NewFloat64Series(),
UpBand: NewFloat64Series(), UpBand: NewFloat64Series(),
DownBand: NewFloat64Series(), DownBand: NewFloat64Series(),
@ -45,7 +45,7 @@ func BOLL2(source Float64Source, window int, k float64) *BollStream {
return s return s
} }
func (s *BollStream) Calculate(v float64) float64 { func (s *BOLLStream) Calculate(v float64) float64 {
stdDev := s.StdDev.Last(0) stdDev := s.StdDev.Last(0)
band := stdDev * s.k band := stdDev * s.k
return band return band