I have the following data set structure:
date time_in_hours price
Sep 03 08 9.76 98
Sep 03 08 10.43 97
Sep 03 08 10.98 96
Sep 03 08 11.48 99
Sep 04 08 2.35 98
Sep 04 08 2.58 98.45
Sep 04 08 3.45 96.3
Sep 04 08 3.89 96.25
Sep 04 08 4.18 100
Sep 05 08 12.65 101
Sep 05 08 12.96 100.25
Sep 05 08 13.25 104.35
Sep 05 08 13.78 98
My data is for the years 2008 and 2009. It contains a total of 504 trading days.
My objective is to interpolate prices at every half hour (eg 9.5 10 10.5 11 11.5…etc.) only for time interval between 9.5 and 16.
I have been struggling with the command interpolate / aggregate given that I must interpolate for a specific time interval for each calendar date. My final output must also contain the date, time, and price. Something like this:
date time_in_hours price
Sep 03 08 10 98
Sep 03 08 10.5 97
Sep 03 08 11 96
Sep 03 08 11.5 99
Sep 04 08 2.5 98
Sep 04 08 3 98.45
The code below gives you the output you have stated, but based on all comments above I am not sure it is going to solve your problem completely. Note that round(x, 0.5) takes 0.25 as the boundary – so 2.74 becomes 2.5 while 2.75 becomes 3.