Creating Higher Time Frame Data in Moonshot

Hi there,

I am attempting to create 15 minute data from 1 minute data in Moonshot. I am acquiring the one minute data using the get_prices function. For example, the output of a request for a days worth of 1 minute data for AAPL is the following. The dataframe is called ‘closes’. It has been abbreviated such that it doesn’t crowd the screen.

                                                     |Sid                               |FIBBG000B9XRY4|

|Field |Date |Time||
|Close| 2020-07-15 |09:30:00 |395.760|
|09:31:00 |393.835|
|09:32:00 |395.080|
|09:33:00 |395.320|
|09:34:00 |394.067|
|…|…|
|15:55:00 |390.950|
|15:56:00 |390.990|
|15:57:00 |391.010|
|15:58:00 |390.780|
|15:59:00 |390.910|

When I try to create the 15 minute data, I do the following.
fifteen_min_closes_creator = closes[::15]

The output of this is the following:

                                                     |Sid                               |FIBBG000B9XRY4|

|Field |Date |Time||
|Close| 2020-07-15 |09:30:00 |395.760|
|09:45:00 |395.570|
|10:00:00 |394.740|
|10:15:00 |394.540|
|10:30:00 |395.090|
|10:45:00 |394.437|
|11:00:00 |390.260|
|11:15:00 |389.335|
|11:30:00 |390.640|
|11:45:00 |388.110|
|12:00:00 |386.720|
|12:15:00 |387.300|
|12:30:00 |389.065|
|12:45:00 |388.760|
|13:00:00 |389.750|
|13:15:00 |390.900|
|13:30:00 |390.230|
|13:45:00 |390.769|
|14:00:00 |389.530|
|14:15:00 |391.060|
|14:30:00 |391.070|
|14:45:00 |390.690|
|15:00:00 |389.235|
|15:15:00 |388.235|
|15:30:00 |390.330|
|15:45:00 |391.045|

The issue with this data, however, is that I am missing the last line, because it technically is the 14th bar, not the fifteenth. What is the best way to create the fifteen minute data from the 1 minute data?

Thank you!

That’s a pandas question and it’s called resampling. A web search for “pandas resample” should turn up plenty of information.