This commit is contained in:
MoonGem 2018-03-26 20:23:59 -05:00 committed by GitHub
parent 0f964762e9
commit 9fc7bc9c17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,10 +5,14 @@ from io import StringIO
ppservers = () ppservers = ()
#ppservers = ("10.0.0.1",) #ppservers = ("10.0.0.1",)
#note threads are automatically detected for performance
#number of jobs to append each round
parts = 1280000
#number of times to loop jobs
rounds = 1280000
jobs = []
current = 0
def backtesting(ind): def backtesting(ind):
@ -33,10 +37,10 @@ def backtesting(ind):
if len(sys.argv) > 1: if len(sys.argv) > 1:
ncpus = int(sys.argv[1]) ncpus = int(sys.argv[1])
# Creates jobserver with ncpus workers # Creates jobserver with ncpus workers
job_server = pp.Server(ncpus, ppservers=ppservers) job_server = pp.Server(ncpus, ppservers=ppservers, restart=True)
else: else:
# Creates jobserver with automatically detected number of workers # Creates jobserver with automatically detected number of workers
job_server = pp.Server(ppservers=ppservers) job_server = pp.Server(ppservers=ppservers, restart=True)
print("Starting pp with", job_server.get_ncpus(), "workers") print("Starting pp with", job_server.get_ncpus(), "workers")
@ -45,51 +49,46 @@ start_time = time.time()
# Since jobs are not equal in the execution time, division of the problem # Since jobs are not equal in the execution time, division of the problem
# into a 100 of small subproblems leads to a better load balancing # into a 100 of small subproblems leads to a better load balancing
parts = 128
rounds = 128
jobs = []
current = 0
for index in range(rounds): for index in range(rounds):
print('Please wait... it takes a few minutes to hit the while loop after all jobs are appended for the round.')
for index in range(parts): for index in range(parts):
jobs.append(job_server.submit(backtesting, (index,))) jobs.append(job_server.submit(backtesting, (index,)))
job_server.wait() while True:
for job in jobs: for job in jobs:
res = job() try:
string = str(res) res = job()
params = re.search(r'~~~~(.*)~~~~', string).group(1) string = str(res)
mfi = re.search(r'MFI Value(.*)XXX', string) params = re.search(r'~~~~(.*)~~~~', string).group(1)
fastd = re.search(r'FASTD Value(.*)XXX', string) mfi = re.search(r'MFI Value(.*)XXX', string)
adx = re.search(r'ADX Value(.*)XXX', string) fastd = re.search(r'FASTD Value(.*)XXX', string)
rsi = re.search(r'RSI Value(.*)XXX', string) adx = re.search(r'ADX Value(.*)XXX', string)
tot = re.search(r'TOTAL(.*)', string).group(1) rsi = re.search(r'RSI Value(.*)XXX', string)
total = re.search(r'[-+]?([0-9]*\.[0-9]+|[0-9]+)', tot).group(1) tot = re.search(r'TOTAL(.*)', string).group(1)
if total and (float(total) > float(current)): total = re.search(r'[-+]?([0-9]*\.[0-9]+|[0-9]+)', tot).group(1)
current = total if total and (float(total) > float(current)):
print('total better profit paremeters: ') current = total
print(total) print('total better profit paremeters: ')
if params: print(total)
print(params) if params:
print('~~~~~~') print(params)
print('Only enable the above settings, not all settings below are used!') print('~~~~~~')
print('~~~~~~') print('Only enable the above settings, not all settings below are used!')
if mfi: print('~~~~~~')
print('~~~MFI~~~') if mfi:
print(mfi.group(1)) print('~~~MFI~~~')
if fastd: print(mfi.group(1))
print('~~~FASTD~~~') if fastd:
print(fastd.group(1)) print('~~~FASTD~~~')
if adx: print(fastd.group(1))
print('~~~ADX~~~') if adx:
print(adx.group(1)) print('~~~ADX~~~')
if rsi: print(adx.group(1))
print('~~~RSI~~~') if rsi:
print(rsi.group(1)) print('~~~RSI~~~')
print(rsi.group(1))
except exception as e:
print(e)
jobs = []
print("Time elapsed: ", time.time() - start_time, "s") print("Time elapsed: ", time.time() - start_time, "s")
job_server.print_stats() job_server.print_stats()