mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
indicator: add multiply operator
This commit is contained in:
parent
8ebf5723a7
commit
1535572b43
19
pkg/indicator/v2_multiply.go
Normal file
19
pkg/indicator/v2_multiply.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user