forked from milenavuletic/Fin-GAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinGAN-example.py
More file actions
95 lines (72 loc) · 2.31 KB
/
FinGAN-example.py
File metadata and controls
95 lines (72 loc) · 2.31 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
# -*- coding: utf-8 -*-
"""
Created on Tue 7th Nov 2023
@author: vuletic@maths.ox.ac.uk
"""
import FinGAN
import pandas as pd
import matplotlib.pyplot as plt
h = 1
l = 10
pred = 1
###location of the dataset and etfs-stocks list
dataloc = "/data/"
etflistloc = "/stocks-etfs-list.csv"
###number of epochs of training
n_epochs = 100
#number of available GPUs
ngpu = 1
###Location for saiving results
loc = "/Fin-GAN/"
#Models, plots, results folders in the location aboce
modelsloc = loc+"TrainedModels/"
plotsloc = loc+"Plots/"
resultsloc = loc+"Results/"
tanh_coeff = 100
z_dim = 8
hid_d = 8
hid_g = 8
checkpoint_epoch = 20
batch_size = 100
diter = 1
n_epochs = 100
ngrad = 25
vl_later = False
datastart = {'lrd':[],'lrg':[],'epochs':[],'SR_val':[]}
tr = 0.8
vl = 0.1
plot = False
z_dim = 8
hid_d_s = [8]
hid_g_s = [8]
#optional to explore different learning rates
lrg_s = [0.0001]
lrd_s = [0.0001]
vl_later = True
nres = len(lrg_s)
resultsname = "results.csv"
plt.rcParams['figure.figsize'] = [15.75, 9.385]
##tickers to be used
tickers = ['AMZN','HD']
datastart = {'lrd':[],'lrg':[],'epochs':[],'SR_val':[]}
#results_df has performance on both validation and test set
results_df = pd.DataFrame(data=datastart)
corrs = [False] * len(tickers)
for j in range(len(hid_d_s)):
for i in range(nres):
lrg = lrg_s[i]
lrd = lrd_s[i]
# For LSTM_combos set hid_d and hid_g to 0 and 1
# hid_d = 0
# hid_g = 1
for tickern in range(len(tickers)):
ticker = tickers[tickern]
print("******************")
print(ticker)
print("******************")
df_temp, corrs[tickern] = FinGAN.FinGAN_combos(ticker,loc,modelsloc,plotsloc,dataloc, etflistloc, vl_later, lrg, lrd, n_epochs, ngrad, h, l, pred, ngpu, tanh_coeff, tr, vl, z_dim, hid_d, hid_g, checkpoint_epoch, batch_size = 100, diter = 1, plot = plot)
# df_temp, corrs[tickern] = FinGAN.LSTM_combos(ticker,loc,modelsloc,plotsloc,dataloc, etflistloc, vl_later, lrg, lrd, n_epochs, ngrad, h, l, pred, ngpu, tanh_coeff, tr, vl, z_dim, hid_d, hid_g, checkpoint_epoch, batch_size = 100, diter = 1, plot = plot)
results_df = pd.concat([results_df,df_temp], ignore_index=True)
results_df.to_csv(resultsloc+resultsname)
print("*************")
print("DONE")