indicator: add multiply operator

This commit is contained in:
c9s 2023-06-01 14:30:16 +08:00
parent 8ebf5723a7
commit 1535572b43
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -0,0 +1,19 @@
package indicator
type MultiplyStream struct {
Float64Series
multiplier float64
}
func Multiply(source Float64Source, multiplier float64) *MultiplyStream {
s := &MultiplyStream{
Float64Series: NewFloat64Series(),
multiplier: multiplier,
}
s.Bind(source, s)
return s
}
func (s *MultiplyStream) Calculate(v float64) float64 {
return v * s.multiplier
}