def __init__(self, db_h5_file,
future_time = 20, lookback = 100, read_first_k_table = -1, normalize=True, two_class=False):
super(DBGeneticReader, self).__init__()
self._db = pd.HDFStore(db_h5_file)
self._future_time = future_time
self._lookback = lookback
self._db_len = 0
self._two_class = two_class
self._tables = []
for k in self._db:
self._db_len += len(self._db[k]) - future_time - lookback
t = self._db[k].iloc[:, 4:].astype('float32')
t['AveragePrice'] = (t['AskPrice1'] + t['BidPrice1']) / 2
if normalize:
t = (t - t.mean()) / (t.std() + 1e-10)
self._tables.append(t)
if read_first_k_table != -1 and len(self._tables) == read_first_k_table:
break
评论列表
文章目录