forked from sdcoffey/techan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indicator_aroon_test.go
45 lines (34 loc) · 1.28 KB
/
indicator_aroon_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
package techan
import "testing"
func TestAroonUpIndicator(t *testing.T) {
t.Run("with < window periods", func(t *testing.T) {
series := NewTimeSeries()
indicator := NewHighPriceIndicator(series)
aroonUp := NewAroonUpIndicator(indicator, 10)
decimalEquals(t, 0, aroonUp.Calculate(0))
})
t.Run("with > window periods", func(t *testing.T) {
ts := mockTimeSeriesFl(1, 2, 3, 4, 3, 2, 1)
indicator := NewHighPriceIndicator(ts)
aroonUpIndicator := NewAroonUpIndicator(indicator, 4)
decimalEquals(t, 100, aroonUpIndicator.Calculate(3))
decimalEquals(t, 75, aroonUpIndicator.Calculate(4))
decimalEquals(t, 50, aroonUpIndicator.Calculate(5))
})
}
func TestAroonDownIndicator(t *testing.T) {
t.Run("with < window periods", func(t *testing.T) {
series := NewTimeSeries()
indicator := NewHighPriceIndicator(series)
aroonUp := NewAroonDownIndicator(indicator, 10)
decimalEquals(t, 0, aroonUp.Calculate(0))
})
t.Run("with > window periods", func(t *testing.T) {
ts := mockTimeSeriesFl(5, 4, 3, 2, 3, 4, 5)
indicator := NewLowPriceIndicator(ts)
aroonUpIndicator := NewAroonDownIndicator(indicator, 4)
decimalEquals(t, 100, aroonUpIndicator.Calculate(3))
decimalEquals(t, 75, aroonUpIndicator.Calculate(4))
decimalEquals(t, 50, aroonUpIndicator.Calculate(5))
})
}