|
@@ -82,6 +82,7 @@ class TestStrategy(bt.Strategy):
|
|
|
self.sma5 = btind.MovingAverageSimple(self.datas[0].close, period=5)
|
|
|
self.sma10 = btind.MovingAverageSimple(self.datas[0].close, period=10)
|
|
|
self.sma20 = btind.MovingAverageSimple(self.datas[0].close, period=20)
|
|
|
+ self.sma60 = btind.MovingAverageSimple(self.datas[0].close, period=60)
|
|
|
|
|
|
def notify_order(self, order):
|
|
|
"""
|
|
@@ -142,10 +143,10 @@ class TestStrategy(bt.Strategy):
|
|
|
and (((lowest * (1 - vola)) < self.low[-2] < (lowest * (1 + vola))) or (
|
|
|
(lowest * (1 - vola)) < self.low[-1] < (lowest * (1 + vola)))) \
|
|
|
and self.volume[0] >= self.volume[-1] and self.dataclose[0] > self.dataopen[0] \
|
|
|
- and self.sma5[0] < self.sma10[0] < self.sma20[0]:
|
|
|
+ and self.sma5[0] < self.sma10[0] and self.sma10[0] > self.sma20[0]:
|
|
|
self.order = self.buy()
|
|
|
self.pos_price = self.low[-1]
|
|
|
- elif (self.hl[0] == 5 and ((highest * (1 - vola)) < self.high[-2] < (highest * (1 + vola)))) \
|
|
|
+ elif ((self.hl[0] == 5 or self.dataclose[0] < self.sma5[0]) and ((highest * (1 - vola)) < self.high[-2] < (highest * (1 + vola)))) \
|
|
|
or self.dataclose[0] < self.pos_price:
|
|
|
self.order = self.close()
|
|
|
self.pos_price = 0
|
|
@@ -288,9 +289,9 @@ if __name__ == '__main__':
|
|
|
list_date = mp.Manager().list()
|
|
|
thread_list = []
|
|
|
pool = mp.Pool(processes=mp.cpu_count())
|
|
|
- for num in range(60, 180, 20):
|
|
|
- for Volatility in range(5, 8, 1):
|
|
|
- for rate in range(1, 3, 1):
|
|
|
+ for num in range(20, 180, 20):
|
|
|
+ for Volatility in range(5, 11, 1):
|
|
|
+ for rate in range(1, 5, 1):
|
|
|
step = math.ceil(len(table_list) / mp.cpu_count())
|
|
|
result = []
|
|
|
result_change = []
|