-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
210 lines (178 loc) · 4.69 KB
/
config.py
File metadata and controls
210 lines (178 loc) · 4.69 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
"""Config file."""
from universal import algos
from stable_baselines3 import DQN, DDPG
from stable_baselines3.common.noise import OrnsteinUhlenbeckActionNoise, NormalActionNoise
MODELS = {
'dqn': DQN,
'ddpg': DDPG
}
MODEL_PATH = {
'ddpg': 'models/DDPG_best.zip',
'dqn': 'models/DQN_best.zip'
}
ACTION_SPACE = {
'dqn': 'discrete',
'ddpg': 'continuous',
}
ACTION_NOISE = {
"normal": NormalActionNoise,
"ornstein_uhlenbeck": OrnsteinUhlenbeckActionNoise,
}
# DJIA as of April 14, 2021
DOW_TICKERS = [
'UNH', # United Health
'GS', # Goldman Sachs
'HD', # Home Depot
'MSFT', # Microsoft
'BA', # Boeing
'AMGN', # Amgen
'CAT', # Caterpillar
'MCD', # McDonald's
'HON', # Honeywell
'CRM', # Salesforce
'V', # Visa (2013-09-20/2008-03-19)
'MMM', # 3M
'DIS', # Disney
'JNJ', # Johnson & Johnson
'TRV', # Travelers Companies
'JPM', # JPMorgan Chase
'AXP', # American Express
'WMT', # Walmart
'PG', # Proctor & Gamble
'IBM', # IBM
'NKE', # Nike
'AAPL', # Apple (2015-03-19)
'CVX', # Chevron Corporation
'MRK', # Merck & Co
'DOW', # Dow Inc
'INTC', # Intel
'VZ', # Verizon
'WBA', # Walgreens Boots Alliance
'KO', # Coca-Cola
'CSCO', # Cisco
]
##################################################
# Environment Configurations
##################################################
# TICKERS = ['AAPL', 'GE', 'JPM', 'MSFT', 'VOD', 'GS', 'MMM']
# TICKERS = ['AAPL', 'GE', 'JPM', 'MSFT']
TICKERS = ['AAPL', 'MSFT', 'V', 'JPM']
# TICKERS = ['AAPL', 'MSFT', 'V', 'JPM', 'JNJ', 'WMT']
# start date from which to begin downloading ticker data
START = '2008-03-19'
# START = '2013-09-20'
# end date for data used in experiments
END = '2021-07-31'
# number of units to divide discreted weights into
SLICES = 8
# number of days' prices used for a single observation
WINDOW_LENGTH = 50
# fee charged as commission by the broker
COMMISSION_RATE = 0.0025
##################################################
# Training Hyperparameters
##################################################
DDPG_KWARGS = dict(
policy='MultiInputPolicy',
learning_rate=0.000002,
learning_starts=10000,
buffer_size=10000,
batch_size=64,
tau=0.005,
gamma=1,
train_freq=100,
action_noise='normal' # 'normal' | 'ornstein_uhlenbeck' | None
)
DQN_KWARGS = dict(
policy='MultiInputPolicy',
learning_rate=0.00005,
learning_starts=10000,
buffer_size=10000,
batch_size=64,
tau=0.005,
gamma=0.5,
train_freq=1,
target_update_interval=1000
)
TRAIN_VERBOSE_LEVEL = 2
RANDOM_SEED = 42
##################################################
# Exploration configurations
##################################################
DDPG_EX_PARAMS = dict(
noise_sigma=0.2,
)
DQN_EX_PARAMS = dict(
exploration_fraction=0.4,
exploration_initial_eps=0.8,
exploration_final_eps=0.01,
)
##################################################
# Combined Model and NN Configurations
##################################################
MODEL_PARAMS = {
'ddpg': dict(
net_arch=[512, 256, 128],
multiplier=2,
hyperparams=DDPG_KWARGS,
exploration=DDPG_EX_PARAMS,
),
'dqn': dict(
net_arch=[256, 128, 64],
multiplier=1,
hyperparams=DQN_KWARGS,
exploration=DQN_EX_PARAMS,
)
}
##################################################
# Callback configurations
##################################################
CALLBACK_ENABLED = True
CALLBACK_START = 20000
SAVE_PATH = 'models/'
LOG_PATH = 'logs/'
CALLBACK_VERBOSE_LEVEL = 2
##################################################
# metrics to be calculated when evaluating strategies
ATTRIBUTES = [
'total_wealth',
'cumulative_return',
'annualised_return',
'sharpe',
'max_drawdown',
'max_drawdown_period',
'ulcer_index',
'profit_factor',
'winning_pct',
'beta',
'alpha',
'appraisal_ratio',
'information_ratio',
'annualised_volatility',
'annual_turnover',
]
# online portfolio selection strategies for
# benchmarking/comparing agent performance
OLPS_STRATEGIES = [
# benchmarks
algos.BAH(),
algos.CRP(),
algos.BCRP(),
# algos.DCRP(),
algos.MPT(window=50, min_history=1, mu_estimator='historical', cov_estimator='empirical', q=0), # min-variance
# follow the winner
algos.UP(),
algos.EG(),
# follow the loser
algos.Anticor(window=WINDOW_LENGTH),
algos.PAMR(eps=1),
algos.OLMAR(window=WINDOW_LENGTH),
algos.RMR(window=WINDOW_LENGTH),
algos.CWMR(),
algos.WMAMR(window=WINDOW_LENGTH),
# pattern matching
algos.BNN(k=WINDOW_LENGTH),
algos.CORN(),
# meta-learning
algos.ONS(),
]