Skip to content

Commit

Permalink
Wait for pool.imap to finish before calling trader.train
Browse files Browse the repository at this point in the history
  • Loading branch information
notadamking committed Jul 10, 2019
1 parent 924df37 commit a7e8ff7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Binary file modified data/params.db
Binary file not shown.
12 changes: 9 additions & 3 deletions optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from multiprocessing import Pool

from lib.env.reward import WeightedUnrealizedProfit

np.warnings.filterwarnings('ignore')


Expand All @@ -12,15 +14,19 @@ def optimize_code(params):
trader = RLTrader(**params)
trader.optimize()

return ""


if __name__ == '__main__':
n_processes = multiprocessing.cpu_count()
params = {'n_envs': n_processes}
params = {'n_envs': n_processes, 'reward_strategy': WeightedUnrealizedProfit}

opt_pool = Pool(processes=n_processes)
opt_pool.imap(optimize_code, [params for _ in range(n_processes)])
results = opt_pool.imap(optimize_code, [params for _ in range(n_processes)])

print([result.get() for result in results])

from lib.RLTrader import RLTrader

trader = RLTrader(**params)
trader.train(test_trained_model=True, render_test_env=True, render_report=True)
trader.train(test_trained_model=True, render_test_env=True, render_report=True, save_report=True)

0 comments on commit a7e8ff7

Please sign in to comment.