Skip to content

Commit

Permalink
Merge pull request #8 from kylejusticemagnuson/better-aroon-tests
Browse files Browse the repository at this point in the history
Update aroon tests
  • Loading branch information
Kyle Magnuson authored Dec 12, 2017
2 parents c393ae8 + e7f1865 commit d0caa6b
Showing 1 changed file with 32 additions and 61 deletions.
93 changes: 32 additions & 61 deletions tests/test_aroon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,70 +11,41 @@ def setUp(self):
"""Create data to use for testing."""
self.data = SampleData().get_sample_close_data()

self.aroon_up_period_6_expected = np.array([np.nan, np.nan, np.nan, np.nan,
np.nan, 50.0, 16.666666666666664, 16.666666666666664, 33.333333333333329,
50.0, 16.666666666666664, 16.666666666666664, 33.333333333333329, 50.0,
66.666666666666657, 83.333333333333343, 100.0, 100.0, 83.333333333333343,
100.0, 100.0, 100.0, 16.666666666666664, 33.333333333333329, 50.0,
66.666666666666657, 83.333333333333343, 100.0, 100.0, 16.666666666666664,
33.333333333333329, 50.0, 66.666666666666657, 83.333333333333343, 100.0,
16.666666666666664, 16.666666666666664, 33.333333333333329, 50.0,
66.666666666666657, 83.333333333333343, 100.0, 16.666666666666664,
16.666666666666664, 33.333333333333329, 16.666666666666664, 16.666666666666664,
16.666666666666664, 33.333333333333329, 50.0, 66.666666666666657,
83.333333333333343, 100.0, 66.666666666666657, 83.333333333333343, 100.0, 100.0,
16.666666666666664, 33.333333333333329, 50.0, 66.666666666666657,
83.333333333333343, 100.0, 16.666666666666664, 33.333333333333329,
16.666666666666664, 16.666666666666664, 33.333333333333329, 16.666666666666664,
16.666666666666664, 33.333333333333329, 50.0, 66.666666666666657,
83.333333333333343, 100.0, 100.0, 50.0, 66.666666666666657, 83.333333333333343,
16.666666666666664, 16.666666666666664, 16.666666666666664, 33.333333333333329,
50.0, 66.666666666666657, 83.333333333333343, 100.0, 100.0, 50.0,
66.666666666666657, 16.666666666666664, 16.666666666666664, 16.666666666666664,
16.666666666666664, 16.666666666666664, 33.333333333333329, 16.666666666666664,
16.666666666666664, 16.666666666666664, 16.666666666666664, 33.333333333333329,
50.0, 66.666666666666657, 83.333333333333343, 100.0, 100.0, 83.333333333333343,
100.0, 50.0, 66.666666666666657, 83.333333333333343, 100.0, 100.0, 100.0, 100.0,
66.666666666666657, 83.333333333333343, 100.0, 83.333333333333343, 100.0, 100.0,
100.0, 83.333333333333343, 100.0, 83.333333333333343, 100.0, 100.0])

self.aroon_down_period_14_expected = [np.nan, np.nan, np.nan, np.nan, np.nan,
np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 100.0, 100.0,
7.1428571428571423, 7.1428571428571423, 7.1428571428571423, 14.285714285714285,
7.1428571428571423, 7.1428571428571423, 14.285714285714285, 21.428571428571427,
28.571428571428569, 35.714285714285715, 42.857142857142854, 50.0, 57.142857142857139,
64.285714285714292, 71.428571428571431, 78.571428571428569, 85.714285714285708,
7.1428571428571423, 14.285714285714285, 21.428571428571427, 28.571428571428569,
35.714285714285715, 42.857142857142854, 50.0, 57.142857142857139, 64.285714285714292,
71.428571428571431, 78.571428571428569, 85.714285714285708, 92.857142857142861,
100.0, 100.0, 100.0, 78.571428571428569, 85.714285714285708, 92.857142857142861,
100.0, 100.0, 100.0, 7.1428571428571423, 14.285714285714285, 21.428571428571427,
28.571428571428569, 7.1428571428571423, 14.285714285714285, 21.428571428571427,
28.571428571428569, 7.1428571428571423, 14.285714285714285, 21.428571428571427,
28.571428571428569, 35.714285714285715, 42.857142857142854, 50.0, 57.142857142857139,
64.285714285714292, 7.1428571428571423, 7.1428571428571423, 14.285714285714285,
21.428571428571427, 7.1428571428571423, 7.1428571428571423, 14.285714285714285,
7.1428571428571423, 14.285714285714285, 21.428571428571427, 28.571428571428569,
35.714285714285715, 42.857142857142854, 50.0, 57.142857142857139, 64.285714285714292,
71.428571428571431, 78.571428571428569, 85.714285714285708, 92.857142857142861,
100.0, 64.285714285714292, 71.428571428571431, 78.571428571428569, 85.714285714285708,
92.857142857142861, 100.0, 78.571428571428569, 85.714285714285708, 92.857142857142861,
100.0, 100.0, 100.0, 100.0, 21.428571428571427, 28.571428571428569, 7.1428571428571423,
7.1428571428571423, 7.1428571428571423, 7.1428571428571423, 7.1428571428571423,
14.285714285714285, 7.1428571428571423, 14.285714285714285, 7.1428571428571423,
7.1428571428571423, 7.1428571428571423, 14.285714285714285, 7.1428571428571423,
14.285714285714285, 7.1428571428571423, 7.1428571428571423, 7.1428571428571423,
14.285714285714285, 7.1428571428571423, 14.285714285714285]

def test_aroon_up_period_6(self):
period = 6
self.aroon_up_expected = [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 48.0, 44.0, 40.0,
36.0, 32.0, 28.000000000000004, 24.0, 20.0, 16.0, 12.0, 8.0, 4.0, 4.0, 96.0, 92.0,
88.0, 84.0, 80.0, 76.0, 100.0, 96.0, 100.0, 100.0, 100.0, 96.0, 92.0, 88.0, 84.0,
80.0, 76.0, 72.0, 68.0, 64.0, 60.0, 56.000000000000007, 52.0, 48.0, 44.0, 40.0,
36.0, 32.0, 28.000000000000004, 24.0, 20.0, 16.0, 12.0, 8.0, 4.0, 12.0, 8.0, 4.0,
4.0, 72.0, 68.0, 64.0, 60.0, 56.000000000000007, 52.0, 48.0, 44.0, 40.0, 36.0,
32.0, 28.000000000000004, 24.0, 20.0, 16.0, 12.0, 8.0, 4.0, 48.0, 44.0, 40.0,
36.0, 100.0, 100.0, 96.0, 92.0, 88.0, 84.0, 80.0, 76.0, 72.0, 68.0, 64.0, 60.0,
56.000000000000007, 52.0, 48.0, 44.0, 40.0, 36.0, 32.0, 28.000000000000004, 24.0,
20.0, 16.0, 12.0, 8.0, 4.0, 4.0, 8.0, 4.0]

self.aroon_down_expected = [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan,
np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 84.0, 80.0, 76.0, 72.0,
68.0, 64.0, 60.0, 56.000000000000007, 100.0, 96.0, 92.0, 88.0, 84.0, 80.0, 76.0,
72.0, 68.0, 64.0, 60.0, 56.000000000000007, 52.0, 48.0, 44.0, 40.0, 36.0, 32.0,
28.000000000000004, 24.0, 20.0, 16.0, 12.0, 8.0, 4.0, 4.0, 4.0, 16.0, 12.0, 8.0,
4.0, 4.0, 4.0, 88.0, 84.0, 80.0, 76.0, 72.0, 68.0, 100.0, 100.0, 96.0, 92.0, 100.0,
100.0, 96.0, 100.0, 96.0, 92.0, 88.0, 84.0, 80.0, 76.0, 72.0, 68.0, 64.0, 60.0,
56.000000000000007, 52.0, 48.0, 44.0, 40.0, 36.0, 32.0, 28.000000000000004, 24.0,
20.0, 16.0, 12.0, 8.0, 4.0, 24.0, 20.0, 16.0, 12.0, 8.0, 100.0, 100.0, 100.0, 100.0,
96.0, 100.0, 96.0, 100.0, 100.0, 100.0, 96.0, 100.0, 96.0, 100.0, 100.0, 100.0, 96.0,
100.0, 96.0]

def test_aroon_up(self):
period = 25
aroon_up = aroon.aroon_up(self.data, period)
np.testing.assert_array_equal(aroon_up, self.aroon_up_period_6_expected)
np.testing.assert_array_equal(aroon_up, self.aroon_up_expected)

def test_aroon_down_period_14(self):
period = 14
def test_aroon_down(self):
period = 25
aroon_down = aroon.aroon_down(self.data, period)
np.testing.assert_array_equal(aroon_down, self.aroon_down_period_14_expected)
np.testing.assert_array_equal(aroon_down, self.aroon_down_expected)

def test_aroon_up_invalid_period(self):
period = 128
Expand Down

0 comments on commit d0caa6b

Please sign in to comment.