bbgo_origin/pkg/indicator/v2_multiply.go
2023-06-01 14:30:16 +08:00

20 lines
367 B
Go

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
}