mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
factorzoo: fix correlation
This commit is contained in:
parent
71a032a29b
commit
1163b89807
|
@ -2,15 +2,15 @@ package factorzoo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/c9s/bbgo/pkg/indicator"
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/c9s/bbgo/pkg/indicator"
|
||||||
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var zeroTime time.Time
|
var zeroTime time.Time
|
||||||
|
|
||||||
//var zeroTime time.Time
|
|
||||||
type KLineValueMapper func(k types.KLine) float64
|
type KLineValueMapper func(k types.KLine) float64
|
||||||
|
|
||||||
//go:generate callbackgen -type Correlation
|
//go:generate callbackgen -type Correlation
|
||||||
|
@ -82,7 +82,7 @@ func calculateCORRELATION(klines []types.KLine, window int, valA KLineValueMappe
|
||||||
// sum of elements of array A
|
// sum of elements of array A
|
||||||
sumA += valA(k)
|
sumA += valA(k)
|
||||||
// sum of elements of array B
|
// sum of elements of array B
|
||||||
sumB += valA(k)
|
sumB += valB(k)
|
||||||
|
|
||||||
// sum of A[i] * B[i].
|
// sum of A[i] * B[i].
|
||||||
sumAB = sumAB + valA(k)*valB(k)
|
sumAB = sumAB + valA(k)*valB(k)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user