forked from notadamking/RLTrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
optimize.py
32 lines (19 loc) · 809 Bytes
/
optimize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import multiprocessing
import numpy as np
from multiprocessing import Pool
from lib.env.reward import WeightedUnrealizedProfit
np.warnings.filterwarnings('ignore')
def optimize_code(params):
from lib.RLTrader import RLTrader
trader = RLTrader(**params)
trader.optimize()
return ""
if __name__ == '__main__':
n_processes = multiprocessing.cpu_count()
params = {'n_envs': n_processes, 'reward_strategy': WeightedUnrealizedProfit}
opt_pool = Pool(processes=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, save_report=True)