forked from wcharczuk/go-chart
-
Notifications
You must be signed in to change notification settings - Fork 2
/
macd_series_test.go
88 lines (80 loc) · 1.52 KB
/
macd_series_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package chart
import (
"fmt"
"testing"
"github.com/wcharczuk/go-chart/v2/testutil"
)
var (
macdExpected = []float64{
0,
0.06381766382,
0.1641441222,
0.2817201894,
0.4033023481,
0.3924673744,
0.2983093823,
0.1561821464,
-0.008916708129,
-0.05210332292,
-0.01649503993,
0.06667130899,
0.1751344574,
0.1657328378,
0.08257097469,
-0.04265109369,
-0.1875741257,
-0.2091853882,
-0.1518975486,
-0.04781419838,
0.08025242841,
0.08881960494,
0.02183529775,
-0.08904155476,
-0.2214141128,
-0.2321805992,
-0.1656331722,
-0.05373789678,
0.08083727586,
0.09475354363,
0.03209767112,
-0.07534076818,
-0.2050442354,
-0.2138010557,
-0.1458045181,
-0.03293263556,
0.1022243734,
0.1163957964,
0.05372761902,
-0.05393941791,
-0.1840438454,
-0.1933365048,
-0.1259788988,
-0.01382225715,
0.1205656194,
0.1339326478,
0.07044017167,
-0.03805851969,
-0.1689918111,
-0.1791024416,
}
)
func TestMACDSeries(t *testing.T) {
// replaced new assertions helper
mockSeries := mockValuesProvider{
emaXValues,
emaYValues,
}
testutil.AssertEqual(t, 50, mockSeries.Len())
mas := &MACDSeries{
InnerSeries: mockSeries,
}
var yvalues []float64
for x := 0; x < mas.Len(); x++ {
_, y := mas.GetValues(x)
yvalues = append(yvalues, y)
}
testutil.AssertNotEmpty(t, yvalues)
for index, vy := range yvalues {
testutil.AssertInDelta(t, vy, macdExpected[index], emaDelta, fmt.Sprintf("delta @ %d actual: %0.9f expected: %0.9f", index, vy, macdExpected[index]))
}
}