more iterating on macd, need to get a better handle on how to test.
This commit is contained in:
parent
7858457772
commit
32dd907bf8
9 changed files with 464 additions and 246 deletions
35
ema_series_test.go
Normal file
35
ema_series_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package chart
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"github.com/blendlabs/go-assert"
|
||||
)
|
||||
|
||||
func TestEMASeries(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
mockSeries := mockValueProvider{
|
||||
Seq(1.0, 10.0),
|
||||
Seq(10, 1.0),
|
||||
}
|
||||
assert.Equal(10, mockSeries.Len())
|
||||
|
||||
mas := &EMASeries{
|
||||
InnerSeries: mockSeries,
|
||||
}
|
||||
|
||||
var yvalues []float64
|
||||
for x := 0; x < mas.Len(); x++ {
|
||||
_, y := mas.GetValue(x)
|
||||
yvalues = append(yvalues, y)
|
||||
}
|
||||
|
||||
assert.Equal(10.0, yvalues[0])
|
||||
assert.True(math.Abs(yvalues[9]-3.77) < 0.01)
|
||||
|
||||
lvx, lvy := mas.GetLastValue()
|
||||
assert.Equal(10.0, lvx)
|
||||
assert.True(math.Abs(lvy-3.77) < 0.01)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue