-
Notifications
You must be signed in to change notification settings - Fork 38
/
test_hma.py
47 lines (33 loc) · 1.4 KB
/
test_hma.py
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
import pytest
from stock_indicators import indicators
class TestHMA:
def test_standard(self, quotes):
results = indicators.get_hma(quotes, 20)
assert 502 == len(results)
assert 480 == len(list(filter(lambda x: x.hma is not None, results)))
r = results[149]
assert 236.0835 == round(float(r.hma), 4)
r = results[501]
assert 235.6972 == round(float(r.hma), 4)
def test_bad_data(self, bad_quotes):
r = indicators.get_hma(bad_quotes, 15)
assert 502 == len(r)
def test_no_quotes(self, quotes):
r = indicators.get_hma([], 5)
assert 0 == len(r)
r = indicators.get_hma(quotes[:1], 5)
assert 1 == len(r)
def test_removed(self, quotes):
results = indicators.get_hma(quotes, 20).remove_warmup_periods()
assert 480 == len(results)
last = results.pop()
assert 235.6972 == round(float(last.hma), 4)
def test_condense(self, quotes):
results = indicators.get_hma(quotes, 20).condense()
assert 480 == len(results)
last = results.pop()
assert 235.6972 == round(float(last.hma), 4)
def test_exceptions(self, quotes):
from System import ArgumentOutOfRangeException
with pytest.raises(ArgumentOutOfRangeException):
indicators.get_hma(quotes, 1)