|
@@ -138,6 +138,7 @@ class TestStrategy(bt.Strategy):
|
|
|
rate = self.params.rate / 100
|
|
|
lowest = np.min(self.low.get(size=self.params.num))
|
|
|
highest = np.max(self.high.get(size=self.params.num))
|
|
|
+ '''
|
|
|
if (self.hl[-1] == 2 or self.hl[-1] == 1) and self.dataclose[0] > self.sma5[0] > self.sma5[-1] \
|
|
|
and self.sma5[-4]/self.sma5[-3] > self.sma5[-3]/self.sma5[-2] \
|
|
|
and self.sma10[-4]/self.sma10[-3] > self.sma10[-3]/self.sma10[-2] \
|
|
@@ -145,6 +146,8 @@ class TestStrategy(bt.Strategy):
|
|
|
and (self.low[-2] < self.sma5[-2]*(1-rate) or self.low[-1] < self.sma5[-1]*(1-rate))\
|
|
|
and self.dataclose[0] > self.dataopen[0] \
|
|
|
and self.sma5[-1] < self.sma10[-1] < self.sma20[-1]:
|
|
|
+ '''
|
|
|
+ if self.dataclose[0] > self.sma5[0] > self.sma10[0] and self.sma5[-1] < self.sma10[-1]:
|
|
|
self.order = self.buy()
|
|
|
self.pos_price = self.low[-1]
|
|
|
|
|
@@ -285,7 +288,8 @@ if __name__ == '__main__':
|
|
|
cursor.execute("show tables like '%%%s%%' " % fre)
|
|
|
table_list = [tuple[0] for tuple in cursor.fetchall()]
|
|
|
# print(table_list)
|
|
|
- # table_list = table_list[0:10]
|
|
|
+ table_list = table_list[0:500]
|
|
|
+ print(f'计算个股数为:{len(table_list)}')
|
|
|
|
|
|
list_date = mp.Manager().list()
|
|
|
thread_list = []
|
|
@@ -293,7 +297,7 @@ if __name__ == '__main__':
|
|
|
for num in range(60, 70, 20):
|
|
|
for Volatility in range(5, 6, 1):
|
|
|
for rate in range(3, 11, 1):
|
|
|
- step = math.ceil(len(table_list) / mp.cpu_count())
|
|
|
+ # step = math.ceil(len(table_list) / mp.cpu_count())
|
|
|
result = []
|
|
|
result_change = []
|
|
|
result_change_fall = []
|
|
@@ -309,13 +313,6 @@ if __name__ == '__main__':
|
|
|
pool.apply_async(func=backtrader,
|
|
|
args=(list_date, table_list, result, result_change, result_change_fall,
|
|
|
num, Volatility, rate, err_list,), error_callback=err_call_back)
|
|
|
- # p.start()
|
|
|
- # p.join()
|
|
|
- # print(thread_list)
|
|
|
- # for thread in thread_list:
|
|
|
- # thread.start()
|
|
|
- # for thread in thread_list:
|
|
|
- # thread.join()
|
|
|
pool.close()
|
|
|
pool.join()
|
|
|
|