OHLC Full Form -> Open , High , Low , Close.
I want to calculating this volume in OHLC because It doesn't have volume column.
I have problem to calculated this Volume in OHLC.
Using Jupyter Notebook :-
ohlc_data = {
'DateTime': ['2023-10-05 08:31:00', '2023-10-05 08:32:00', '2023-10-05 08:33:00', '2023-10-05 08:34:00', '2023-10-05 08:35:00'],
'Open': [0.5945, 0.59445, 0.59427, 0.59427, 0.59439],
'High': [0.5945, 0.59448, 0.59433, 0.59445, 0.59452],
'Low': [0.5945, 0.5943, 0.59423, 0.59425, 0.59435],
'Close': [0.5944, 0.5943, 0.5943, 0.5944, 0.59448],
}
ohlc_data = pd.DataFrame(ohlc_data)
ohlc_data
Vol = pd.DataFrame(ohlc_data,columns = ['Volume'])
Volume = pd.concat([ohlc_data,Vol],axis = 1)
Volume = Volume.set_index('DateTime')
Volume.index = pd.to_datetime(Volume.index, format='%Y-%m-%d %H:%M:%S', utc=True)
Volume.Volume = Volume.Volume.resample('1T').sum()
Volume
Is this correct to Resample code ?
Output :-
It says "0" number is given in Volumn column but it has problem to calculated itself.
How to calculate this Volume in OHLC ?
How to do code?
Maybe you misunderstood what OHLC means? (Open High Low Close). If you want to compute the daily OHLC of a time series:
You can do:
Which is a very similar to:
You can't compute the volume with this function. You don't need
ohlcbecause your input data are already in this format.