-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicStrategies.py
94 lines (90 loc) · 5.4 KB
/
basicStrategies.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
from constants import *
from strategy import *
turnoverExit = Strategy(name = "Turnover and exit",
long = Policy.down_cross_indicator,
exLong = Policy.propagate,
short = Policy.up_cross_indicator,
exShort = Policy.propagate,
enter_on_next = True,
modes = [MODE_ALL, MODE_LONGS, MODE_SHORTS],
long_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_LONG,
'window': 30},
exLong_params = {'ret_val': SIGNAL_EXIT,
'window': 4},
short_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_SHORT,
'window': 30},
exShort_params = {'ret_val': SIGNAL_EXIT,
'window': 4})
turnoverStrat = Strategy(name = "Simple turnover",
long = Policy.down_cross_indicator,
exLong = Policy.up_cross_indicator,
short = Policy.up_cross_indicator,
exShort = Policy.down_cross_indicator,
modes = [MODE_ALL, MODE_LONGS, MODE_SHORTS],
long_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_LONG,
'window': 100},
exLong_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_EXIT,
'window': 100},
short_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_SHORT,
'window': 100},
exShort_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_EXIT,
'window': 100})
turnoverExitRange = Strategy(name = "Turnover and exit",
long = Policy.down_cross_indicator,
exLong = Policy.propagate,
short = Policy.up_cross_indicator,
exShort = Policy.propagate,
enter_on_next = True,
modes = [MODE_ALL, MODE_LONGS, MODE_SHORTS],
long_params = {'prices': ['close', 'open'],
'indicator': Indicator.sma,
'ret_val': SIGNAL_LONG,
'window': range(15, 46, 3),
'defaults': {'window':30}},
exLong_params = {'ret_val': SIGNAL_EXIT,
'window': range(3, 7),
'defaults': {'window':4}},
short_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_SHORT,
'window': 30},
exShort_params = {'ret_val': SIGNAL_EXIT,
'window': 4})
turnoverStratRange = Strategy(name = "Simple turnover",
long = Policy.down_cross_indicator,
exLong = Policy.up_cross_indicator,
short = Policy.up_cross_indicator,
exShort = Policy.down_cross_indicator,
modes = [MODE_ALL, MODE_LONGS, MODE_SHORTS],
long_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_LONG,
'window': range(15, 46, 3),
'defaults': {'window':30}},
exLong_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_EXIT,
'window': range(15, 46, 3),
'defaults': {'window':30}},
short_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_SHORT,
'window': range(15, 46, 3),
'defaults': {'window':30}},
exShort_params = {'prices': 'close',
'indicator': Indicator.sma,
'ret_val': SIGNAL_EXIT,
'window': range(15, 46, 3),
'defaults': {'window':30}})