It's alive!

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

View File

@ -5,16 +5,17 @@ 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 run
#number of jobs to append each round
parts = 1280000 parts = 1280000
#number of times to loop jobs
rounds = 1280000
jobs = [] jobs = []
current = 0 current = 0
def backtesting(ind): def backtesting(ind):
er1 = str(ind) er1 = str(ind)
ou1 = str(ind * 1024) ou1 = str(ind * 1024)
@ -37,58 +38,54 @@ 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, restart=True) job_server = pp.Server(150, 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, restart=True) job_server = pp.Server(150, ppservers=ppservers, restart=True)
print("Starting pp with", job_server.get_ncpus(), "workers") print("Starting pp with", job_server.get_ncpus(), "workers")
start_time = time.time() start_time = time.time()
# Since jobs are not equal in the execution time, division of the problem for index in range(parts):
# into a 100 of small subproblems leads to a better load balancing jobs.append(job_server.submit(backtesting, (index,)))
# print(index)
for index in range(rounds): while True:
print('Please wait... it takes a few minutes to hit the while loop after all jobs are appended for the round.') for job in jobs:
for index in range(parts): try:
jobs.append(job_server.submit(backtesting, (index,))) res = job()
while True: string = str(res)
for job in jobs: params = re.search(r'~~~~(.*)~~~~', string).group(1)
try: mfi = re.search(r'MFI Value(.*)XXX', string)
res = job() fastd = re.search(r'FASTD Value(.*)XXX', string)
string = str(res) adx = re.search(r'ADX Value(.*)XXX', string)
params = re.search(r'~~~~(.*)~~~~', string).group(1) rsi = re.search(r'RSI Value(.*)XXX', string)
mfi = re.search(r'MFI Value(.*)XXX', string) tot = re.search(r'TOTAL(.*)', string).group(1)
fastd = re.search(r'FASTD Value(.*)XXX', string) total = re.search(r'[-+]?([0-9]*\.[0-9]+|[0-9]+)', tot).group(1)
adx = re.search(r'ADX Value(.*)XXX', string) if total and (float(total) > float(current)):
rsi = re.search(r'RSI Value(.*)XXX', string) current = total
tot = re.search(r'TOTAL(.*)', string).group(1) print('total better profit paremeters: ')
total = re.search(r'[-+]?([0-9]*\.[0-9]+|[0-9]+)', tot).group(1) print(total)
if total and (float(total) > float(current)): if params:
current = total print(params)
print('total better profit paremeters: ') print('~~~~~~')
print(total) print('Only enable the above settings, not all settings below are used!')
if params: print('~~~~~~')
print(params) if mfi:
print('~~~~~~') print('~~~MFI~~~')
print('Only enable the above settings, not all settings below are used!') print(mfi.group(1))
print('~~~~~~') if fastd:
if mfi: print('~~~FASTD~~~')
print('~~~MFI~~~') print(fastd.group(1))
print(mfi.group(1)) if adx:
if fastd: print('~~~ADX~~~')
print('~~~FASTD~~~') print(adx.group(1))
print(fastd.group(1)) if rsi:
if adx: print('~~~RSI~~~')
print('~~~ADX~~~') print(rsi.group(1))
print(adx.group(1)) except exception as e:
if rsi: print(e)
print('~~~RSI~~~')
print(rsi.group(1))
except exception as e:
print(e)
print("Time elapsed: ", time.time() - start_time, "s") print("Time elapsed: ", time.time() - start_time, "s")
job_server.print_stats() job_server.print_stats()