-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathtest_indicator_processor.py
97 lines (88 loc) · 3.01 KB
/
test_indicator_processor.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
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
89
90
91
92
93
94
95
96
97
"""
Test file for classes and functions:
- analysis_engine.indicators.base_indicator
- analysis_engine.indicators.indicator_processor
"""
import analysis_engine.consts as ae_consts
import analysis_engine.mocks.base_test as base_test
import analysis_engine.indicators.indicator_processor as ind_proc
class TestIndicatorProcessor(base_test.BaseTestCase):
"""TestIndicatorProcessor"""
ticker = None
last_close_str = None
def setUp(
self):
"""setUp"""
self.ticker = 'SPY'
self.example_module_path = (
'analysis_engine/mocks/example_indicator_williamsr.py')
self.test_data = {
"name": "test_5_days_ahead",
"algo_module_path": None,
"algo_version": 1,
"trade_horizon_units": "day",
"trade_horizon": 5,
"buy_rules": {
"confidence": 75,
"min_indicators": 1
},
"sell_rules": {
"confidence": 75,
"min_indicators": 1
},
"indicators": [
{
"name": "willr_1",
"module_path": self.example_module_path,
"category": "technical",
"type": "momentum",
"uses_data": "daily",
"num_points": 19,
"buy_above": 80,
"sell_below": 10
},
{
"name": "willr_2",
"module_path": self.example_module_path,
"category": "technical",
"type": "momentum",
"uses_data": "daily",
"num_points": 15,
"buy_above": 60,
"sell_below": 20
},
{
"name": "baseindicator",
"category": "fundamental",
"type": "balance_sheet",
"uses_data": "daily"
}
],
"slack": {
"webhook": None
}
}
# end of setUp
def test_build_indicator_processor(self):
"""test_build_algo_request_daily"""
print(self.test_data)
proc = ind_proc.IndicatorProcessor(
config_dict=self.test_data)
self.assertTrue(
len(proc.get_indicators()) == 3)
indicators = proc.get_indicators()
for idx, ind_id in enumerate(indicators):
ind_node = indicators[ind_id]
print(ind_node)
self.assertTrue(
ind_node['obj'] is not None)
if idx == 2:
self.assertEqual(
ind_node['report']['path_to_module'],
ae_consts.INDICATOR_BASE_MODULE_PATH)
else:
self.assertEqual(
ind_node['report']['path_to_module'],
self.example_module_path)
# end of test_build_indicator_processor
# end of TestIndicatorProcessor