pd.resample('1Min').agg({..})
从报价数据中准确地得到开盘价,最高价,最低价,收盘价和成交量但是,DatetimeIndex关闭了1Min。我想这是大熊猫认为开始重新采样的时间段造成的
ohlcv_df = data.resample('1Min')['last'].agg(
{'open_p': 'first', 'high_p': 'max', 'low_p': 'min', 'close_p': 'last'})
ohlcv_df['tot_vlm'] = data.resample('1Min')['tot_vlm'].agg({'tol_vlm': 'last'})
ohlcv_df['prd_vlm'] = data.resample('1Min')['last_sz'].sum()
ohlcv_df['num_trds'] = 0
ohlcv_df['symbol'] = self.symbol
ohlcv_df['date'] = ohlcv_df.index
ohlcv_df['date'] = ohlcv_df.date.apply(lambda x: x.date())