mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 23:35:14 +00:00
16 lines
250 B
Go
16 lines
250 B
Go
|
package fixedpoint
|
||
|
|
||
|
func Sum(values []Value) (s Value) {
|
||
|
s = Zero
|
||
|
for _, value := range values {
|
||
|
s = s.Add(value)
|
||
|
}
|
||
|
return s
|
||
|
}
|
||
|
|
||
|
func Avg(values []Value) (avg Value) {
|
||
|
s := Sum(values)
|
||
|
avg = s.Div(NewFromInt(int64(len(values))))
|
||
|
return avg
|
||
|
}
|