|
@@ -5,14 +5,25 @@ import pymysql
|
|
|
import backtrader as bt
|
|
|
import backtrader.indicators as btind
|
|
|
import datetime
|
|
|
+import math
|
|
|
import threading
|
|
|
from datetime import datetime as dt
|
|
|
import multiprocessing as mp
|
|
|
from backtrader.feeds import PandasData
|
|
|
-
|
|
|
+import os
|
|
|
# import multiprocessing
|
|
|
import matplotlib
|
|
|
|
|
|
+cpu_count = os.cpu_count()
|
|
|
+os_name = os.name
|
|
|
+if os_name == 'posix':
|
|
|
+ path = '/Users/daniel/Documents/策略穷举2.csv'
|
|
|
+else:
|
|
|
+ path = 'D:\\BackTrader\\策略穷举0105。csv'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
class MyPandasData(PandasData):
|
|
|
lines = ('change_pct', 'net_amount_main', 'net_pct_main', 'net_amount_xl', 'net_pct_xl', 'net_amount_l', 'net_pct_l'
|
|
|
, 'net_amount_m', 'net_pct_m', 'net_amount_s', 'net_pct_s',)
|
|
@@ -216,7 +227,8 @@ if __name__ == '__main__':
|
|
|
for num in range(20, 180, 10):
|
|
|
for Volatility in range(10, 20, 1):
|
|
|
for rate in range(5, 20, 1):
|
|
|
- step = 400
|
|
|
+ #获得cpu数量,计算进程数
|
|
|
+ step = math.ceil(len(table_list)/cpu_count/100)*100
|
|
|
thread_list = []
|
|
|
result = mp.Manager().list()
|
|
|
result_change = mp.Manager().list()
|
|
@@ -255,4 +267,4 @@ if __name__ == '__main__':
|
|
|
print('每轮耗时:', endtime-stattime)
|
|
|
edtime = dt.now()
|
|
|
print('总耗时:', edtime - sttime)
|
|
|
- df.to_csv('/Users/daniel/Documents/策略穷举2.csv', index=True)
|
|
|
+ df.to_csv(path, index=True)
|