mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
20 lines
421 B
Go
20 lines
421 B
Go
package indicator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_VIDYA(t *testing.T) {
|
|
vidya := &VIDYA{IntervalWindow: types.IntervalWindow{Window: 16}}
|
|
vidya.Update(1)
|
|
assert.Equal(t, vidya.Last(), 1.)
|
|
vidya.Update(2)
|
|
newV := 2./17.*2. + 1.*(1.-2./17.)
|
|
assert.Equal(t, vidya.Last(), newV)
|
|
vidya.Update(1)
|
|
assert.Equal(t, vidya.Last(), vidya.Index(1))
|
|
}
|