我有开放范围/第一个小时(美国东部标准时间上午 9:30-10:30)的基于分钟的 OHLCV 数据。我希望重新采样这些数据,以便获得一个 60 分钟的值,然后计算范围。
当我对数据调用 dataframe.resample() 函数时,我得到两行,第一行从上午 9:00 开始。我希望只有一排从上午 9:30 开始。
注意:初始数据从 9:30 开始。
编辑:添加代码:
# Extract data for regular trading hours (rth) from the 24 hour data set
rth = data.between_time(start_time = '09:30:00', end_time = '16:15:00', include_end = False)
# Extract data for extended trading hours (eth) from the 24 hour data set
eth = data.between_time(start_time = '16:30:00', end_time = '09:30:00', include_end = False)
# Extract data for initial balance (rth) from the 24 hour data set
initial_balance = data.between_time(start_time = '09:30:00', end_time = '10:30:00', include_end = False)
卡住试图按个别日期分隔开盘范围并获得初始余额
conversion = {'Open' : 'first', 'High' : 'max', 'Low' : 'min', 'Close' : 'last', 'Volume' : 'sum'}
sample = data.between_time(start_time = '09:30:00', end_time = '10:30:00', include_end = False)
sample = sample.ix['2007-05-07']
sample.tail()
sample.resample('60Min', how = conversion)
默认情况下,重新采样从整点开始。我希望它从数据开始的地方开始。