I have a table with historical FX historical 1 minute level data, I would like to select out the 10 minutes data based on the 1 minute level data.
My table looks like below:
ccy Time open high low close
AUDUSD 2018.03.26 00:00 0.77282 0.77283 0.77265 0.77265
AUDUSD 2018.03.26 00:01 0.77264 0.77266 0.77261 0.77266
AUDUSD 2018.03.26 00:02 0.77264 0.77265 0.77259 0.77264
AUDUSD 2018.03.26 00:03 0.77262 0.77262 0.7726 0.77262
AUDUSD 2018.03.26 00:04 0.77262 0.77262 0.77262 0.77262
AUDUSD 2018.03.26 00:05 0.7726 0.7726 0.7726 0.7726
AUDUSD 2018.03.26 00:06 0.77259 0.77262 0.77259 0.77261
AUDUSD 2018.03.26 00:07 0.77262 0.77265 0.77262 0.77264
AUDUSD 2018.03.26 00:08 0.77263 0.77272 0.77262 0.77272
AUDUSD 2018.03.26 00:09 0.77273 0.77278 0.77271 0.77274
AUDUSD 2018.03.26 00:10 0.77273 0.77282 0.77271 0.77279
AUDUSD 2018.03.26 00:11 0.77282 0.77293 0.77281 0.77291
AUDUSD 2018.03.26 00:12 0.77291 0.77293 0.77287 0.77287
AUDUSD 2018.03.26 00:13 0.77288 0.77288 0.77288 0.77288
AUDUSD 2018.03.26 00:14 0.77288 0.77288 0.77277 0.77279
AUDUSD 2018.03.26 00:15 0.77278 0.77279 0.77255 0.77262
AUDUSD 2018.03.26 00:16 0.77261 0.77271 0.77261 0.77271
AUDUSD 2018.03.26 00:17 0.77271 0.77273 0.77264 0.77271
AUDUSD 2018.03.26 00:18 0.77273 0.77282 0.77273 0.77281
AUDUSD 2018.03.26 00:19 0.77281 0.77285 0.77281 0.77283
As you can see the timestamp is every 1 minute and above is 20 minutes data sample.
My expect result is:
ccy Time open high low close
AUDUSD 2018.03.26 00:00 0.77282 0.77283 0.77259 0.77274
AUDUSD 2018.03.26 00:10 0.77273 0.77293 0.77255 0.77283
The open needs to be the open price of every start point of the time span, for example from 2018.03.26 00:00 to 2018.03.26 00:09, the start point is 2018.03.26 00:00, so the expected result open is the open of 2018.03.26 00:00, which is 0.77282.
The close needs to be the close price of every end point of the time span, for example from 2018.03.26 00:00 to 2018.03.26 00:09, the end point is 2018.03.26 00:09, so the expected result close is the close of 2018.03.26 00:09, which is 0.77274.
The high needs to be the max value of the time span. In the high column, from 2018.03.26 00:00 to 2018.03.26 00:09, the max value is 0.77283, so my expected high is 0.77283.
The low needs to be the minimum value of the time span. In the low column, from 2018.03.26 00:00 to 2018.03.26 00:09, the minimum value is 0.77259, so my expected low is 0.77259.
And I hope this can keep looping while I have more data. So for example, if I have 1 hour data, I expected there are 60/10 = 6 rows records when I aggregate the data into 10 minutes data.
I have been working on this for while but cannot find a proper solution, can some one please kindly help? Thank you sooo much!