-1

I have 5 min intraday stock price data which I downsample by the following code:

ohlc = {                                                                                                             
'Open':'first',                                                                                              
'High':'max',                                                                                                     
'Low':'min',                                                                                                        
'Close': 'last',                                                                                                    
'Volume': 'sum'
}

d1_data = min5_data.resample('1d').apply(ohlc).dropna()

what I am trying to achieve is to merge the 5 min intraday and day data and match it by date (basically same values on 5 min interval for the whole duration of the trading day or 78 values in total). My idea is to have a reference for the opening price and day range expressed by High and Low.

It is not necessary to go thru resampling if there is another way.

Thank you

rumnen
  • 11
  • 3

2 Answers2

0
import pandas as pd
d1_data = pd.merge(pd.DataFrame([],
                             index = pd.date_range(start = '2020-01-01', 
                                                   end = '2020-01-31', 
                                                   freq = 'D')
                                                   ),
                  min5_data, 
                  how = 'left', 
                  right_index = 'True',
                  left_index = 'True')
0

I found it!

merged_data = pd.concat([min5_data, d1_data], axis=1).ffill()

Thanks for the answer anyway

rumnen
  • 11
  • 3