pandas - Resampling Minute data -
pandas - Resampling Minute data -
i have min based ohlcv info opening range/first hr (9:30-10:30 est). i'm looking resample info can 1 60-minute value , calculate range.
when phone call dataframe.resample() function on info 2 rows , initial row starts @ 9:00 am. i'm looking 1 row starts @ 9:30 am.
note: initial info begins @ 9:30.
edit: adding code:
# extract info regular trading hours (rth) 24 hr info set rth = data.between_time(start_time = '09:30:00', end_time = '16:15:00', include_end = false) # extract info extended trading hours (eth) 24 hr info set eth = data.between_time(start_time = '16:30:00', end_time = '09:30:00', include_end = false) # extract info initial balance (rth) 24 hr info set initial_balance = data.between_time(start_time = '09:30:00', end_time = '10:30:00', include_end = false)
got stuck tried separate opening range individual date , initial balance
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)
by default resample starts @ beggining of hour. start info starts.
you can utilize base
argument of resample
:
sample.resample('60min', how=conversion, base=30)
from the above docs-link:
base
: int
, default 0 frequencies evenly subdivide 1 day, “origin” of aggregated intervals. for example, ‘5min’ frequency, base of operations range 0 through 4. defaults 0
pandas
Comments
Post a Comment