-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.py
49 lines (43 loc) · 1.75 KB
/
utils.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
Author: Javier Montero
License: MIT
'''
import http.client, urllib
import os
def send_pushover_qtrader (msg):
conn = http.client.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.parse.urlencode({
"token": "",
"user": "",
"message": msg,
}), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()
def current_folder_name():
fullpath = os.getcwd()
return fullpath.split(os.sep)[-1]
def is_legal_action (action, position):
if action == 0 and position == 0:
return False
if action == 2 and position == 2:
return False
return True
def describe(env, agent, args):
print (" ")
print ("##################### Training description #####################")
print ("Samples: ", env.getNumSamples())
print ("From {} to {}".format (env.startDateTime, env.endDateTime))
print ("Backsamples: {} State size: {} Funds: {} Drawdown: {}".format (
args.lag,
env.state_size,
env.INITIAL_FUNDS,
env.MAXDRAWDOWN))
print ("Gamma: {} Alpha: {} Memory: {} Batch size: {} Episodes: {}".format (
agent.gamma,
agent.learning_rate,
args.memory_size,
args.batch_size,
args.episodes))
print ('Reward: {}'.format (env.reward.__doc__))
print (agent.model.summary())
print ("################################################################")