genetic.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:future-price-predictor 作者: htfy96 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号