[R-SIG-Finance] [R-sig-finance] endpoints function in package xts [C1]

Jeff Ryan jeff.a.ryan at gmail.com
Mon Apr 7 15:16:28 CEST 2008


Hi Anass,

The question I have is -- what is the basis for the time stamps at 14
and 15, yet not at 13?  The problem from the endpoints function
perspective is just that - what would be the logic needed to get your
timestamps?  Would you like stamps that reflect the last obs. in the
time period (which is what endpoints does), or would you like
timestamps at the end/beginning of each hour from the start of the
series to the end?  Additionally the endpoints will pick the last
point within the hour - so 14:00 would be considered the _beginning_
of the 14th hour, 14:59:59 would be the end.

If you just want time stamps from each hour if not represented
already, that would certainly be doable - though not automatically at
present.  Possibly an addition to xts in the near future??

There are two soon to be exported functions from xts: lastof and
firstof, which essentially calculate the last_of an hour (or any
period), that may be of use:


> xts:::lastof(2008,3,10,14)
[1] "2008-03-10 14:59:59 GMT"

> xts:::firstof(2008,3,10,14)
[1] "2008-03-10 14:00:00 GMT"


You may be able to merge a series of all your required time stamps
with the series in question and get something approximately near what
you are seeking - but you'll most likely have to have stamps at each
hour, not just arbitrary ones.

Jeff

On Mon, Apr 7, 2008 at 6:26 AM,  <anass.mouhsine at sgcib.com> wrote:
>
>  Hi All,
>
>  I have an issue with endpoints in package xts.
>  Assume that I have a timeSeries of a tick by tick price and that I want to
>  get an hourly sum aggregation
>
>  > ep<-endpoints(temp,'hours',1)
>  >ans<-xts:::period.sum(temp[,1],ep)
>
>  this should do, but the problem is that in my set of data, I don't have any
>  data between 12h55 and 15h26.
>  so when it returns ans , ans equals:
>
>  2008-03-10 09:59:49 2004.37
>  2008-03-10 10:59:30 1441.56
>  2008-03-10 11:54:50 1445.40
>  2008-03-10 12:55:25  684.18
>  2008-03-10 15:50:41 1069.28
>  2008-03-10 16:56:49 3008.19
>  2008-03-10 17:30:00 1101.17
>
>  but I want something like
>
>  2008-03-10 09:59:49 2004.37
>  2008-03-10 10:59:30 1441.56
>  2008-03-10 11:54:50 1445.40
>  2008-03-10 12:55:25  684.18
>  2008-03-10 14:00:00 0
>  2008-03-10 15:00:00 0
>  2008-03-10 15:50:41 1069.28
>  2008-03-10 16:56:49 3008.19
>  2008-03-10 17:30:00 1101.17
>
>  Do you have any idea on how to perform this task?
>
>  Thanks in davance.
>
>  Anass
>
>  P.S: you will find below the timeSeries temp.
>
>  > temp
>                                    V6
>  2008-03-10 09:00:00  0.00
>  2008-03-10 09:00:01 25.65
>  2008-03-10 09:00:01 25.65
>  2008-03-10 09:00:05 25.65
>  2008-03-10 09:03:03 25.65
>  2008-03-10 09:16:06 25.65
>  2008-03-10 09:16:18 25.65
>  2008-03-10 09:16:29 25.65
>  2008-03-10 09:16:29 25.65
>  2008-03-10 09:27:43 25.65
>  2008-03-10 09:27:43 25.65
>  2008-03-10 09:28:44 25.65
>  2008-03-10 09:28:44 25.65
>  2008-03-10 09:29:39 25.65
>  2008-03-10 09:29:39 25.65
>  2008-03-10 09:30:44 25.65
>  2008-03-10 09:36:36 25.65
>  2008-03-10 09:38:37 25.65
>  2008-03-10 09:38:37 25.65
>  2008-03-10 09:40:36 25.65
>  2008-03-10 09:44:47 25.50
>  2008-03-10 09:44:47 25.28
>  2008-03-10 09:44:47 25.28
>  2008-03-10 09:44:47 25.28
>  2008-03-10 09:44:47 25.28
>  2008-03-10 09:44:47 25.28
>  2008-03-10 09:44:48 25.28
>  2008-03-10 09:44:48 25.28
>  2008-03-10 09:44:48 25.28
>  2008-03-10 09:44:48 25.28
>  2008-03-10 09:44:48 25.28
>  2008-03-10 09:44:53 25.28
>  2008-03-10 09:45:44 25.28
>  2008-03-10 09:47:05 25.28
>  2008-03-10 09:47:05 25.28
>  2008-03-10 09:47:05 25.28
>  2008-03-10 09:47:52 25.28
>  2008-03-10 09:47:52 25.28
>  2008-03-10 09:50:44 25.28
>  2008-03-10 09:50:45 25.28
>  2008-03-10 09:50:45 25.28
>  2008-03-10 09:50:45 25.28
>  2008-03-10 09:51:42 25.28
>  2008-03-10 09:51:43 25.28
>  2008-03-10 09:51:43 25.28
>  2008-03-10 09:51:43 25.28
>  2008-03-10 09:51:43 25.28
>  2008-03-10 09:51:43 25.28
>  2008-03-10 09:51:44 25.28
>  2008-03-10 09:51:44 25.28
>  2008-03-10 09:51:44 25.28
>  2008-03-10 09:52:42 25.28
>  2008-03-10 09:52:42 25.28
>  2008-03-10 09:52:43 25.28
>  2008-03-10 09:52:43 25.28
>  2008-03-10 09:52:43 25.28
>  2008-03-10 09:52:43 25.28
>  2008-03-10 09:53:40 25.28
>  2008-03-10 09:53:40 25.28
>  2008-03-10 09:53:41 25.28
>  2008-03-10 09:53:41 25.28
>  2008-03-10 09:54:24 25.28
>  2008-03-10 09:54:24 25.28
>  2008-03-10 09:54:43 25.28
>  2008-03-10 09:54:43 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:54:44 25.28
>  2008-03-10 09:55:47 25.28
>  2008-03-10 09:55:47 25.28
>  2008-03-10 09:55:48 25.28
>  2008-03-10 09:55:48 25.28
>  2008-03-10 09:55:48 25.28
>  2008-03-10 09:59:04 25.28
>  2008-03-10 09:59:05 25.28
>  2008-03-10 09:59:49 25.28
>  2008-03-10 09:59:49 25.28
>  2008-03-10 10:00:45 25.28
>  2008-03-10 10:01:39 25.28
>  2008-03-10 10:01:39 25.28
>  2008-03-10 10:03:32 25.28
>  2008-03-10 10:05:31 25.28
>  2008-03-10 10:05:31 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:07:32 25.28
>  2008-03-10 10:08:34 25.28
>  2008-03-10 10:08:34 25.28
>  2008-03-10 10:08:34 25.28
>  2008-03-10 10:08:34 25.28
>  2008-03-10 10:09:30 25.28
>  2008-03-10 10:09:30 25.28
>  2008-03-10 10:10:25 25.28
>  2008-03-10 10:10:25 25.28
>  2008-03-10 10:11:25 25.28
>  2008-03-10 10:11:25 25.28
>  2008-03-10 10:12:24 25.28
>  2008-03-10 10:13:26 25.28
>  2008-03-10 10:14:31 25.28
>  2008-03-10 10:14:31 25.28
>  2008-03-10 10:15:35 25.28
>  2008-03-10 10:15:35 25.28
>  2008-03-10 10:16:38 25.28
>  2008-03-10 10:16:38 25.28
>  2008-03-10 10:16:53 25.28
>  2008-03-10 10:19:53 25.28
>  2008-03-10 10:19:54 25.28
>  2008-03-10 10:20:12 25.28
>  2008-03-10 10:20:48 25.28
>  2008-03-10 10:20:48 25.28
>  2008-03-10 10:24:52 25.28
>  2008-03-10 10:24:53 25.28
>  2008-03-10 10:24:53 25.28
>  2008-03-10 10:30:39 25.28
>  2008-03-10 10:30:39 25.28
>  2008-03-10 10:30:40 25.28
>  2008-03-10 10:47:27 25.32
>  2008-03-10 10:47:27 25.32
>  2008-03-10 10:47:28 25.32
>  2008-03-10 10:47:28 25.32
>  2008-03-10 10:47:29 25.32
>  2008-03-10 10:52:55 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:55:51 25.32
>  2008-03-10 10:59:29 25.32
>  2008-03-10 10:59:30 25.32
>  2008-03-10 10:59:30 25.32
>  2008-03-10 11:01:45 25.51
>  2008-03-10 11:01:45 25.51
>  2008-03-10 11:01:46 25.51
>  2008-03-10 11:01:46 25.51
>  2008-03-10 11:01:46 25.51
>  2008-03-10 11:13:50 25.51
>  2008-03-10 11:15:18 25.34
>  2008-03-10 11:15:18 25.34
>  2008-03-10 11:15:19 25.34
>  2008-03-10 11:15:19 25.34
>  2008-03-10 11:15:19 25.34
>  2008-03-10 11:22:53 25.34
>  2008-03-10 11:24:09 25.34
>  2008-03-10 11:32:15 25.34
>  2008-03-10 11:39:42 25.34
>  2008-03-10 11:39:55 25.34
>  2008-03-10 11:39:56 25.34
>  2008-03-10 11:39:56 25.34
>  2008-03-10 11:39:56 25.34
>  2008-03-10 11:39:56 25.34
>  2008-03-10 11:39:56 25.34
>  2008-03-10 11:40:56 25.34
>  2008-03-10 11:40:56 25.34
>  2008-03-10 11:40:57 25.34
>  2008-03-10 11:40:57 25.34
>  2008-03-10 11:40:57 25.34
>  2008-03-10 11:40:57 25.34
>  2008-03-10 11:43:22 25.34
>  2008-03-10 11:43:23 25.34
>  2008-03-10 11:43:59 25.34
>  2008-03-10 11:43:59 25.34
>  2008-03-10 11:47:54 25.34
>  2008-03-10 11:47:54 25.34
>  2008-03-10 11:48:51 25.34
>  2008-03-10 11:48:51 25.34
>  2008-03-10 11:49:46 25.34
>  2008-03-10 11:49:46 25.34
>  2008-03-10 11:50:17 25.34
>  2008-03-10 11:50:18 25.34
>  2008-03-10 11:50:18 25.34
>  2008-03-10 11:50:18 25.34
>  2008-03-10 11:50:19 25.34
>  2008-03-10 11:50:19 25.34
>  2008-03-10 11:50:48 25.34
>  2008-03-10 11:50:48 25.34
>  2008-03-10 11:51:49 25.34
>  2008-03-10 11:51:49 25.34
>  2008-03-10 11:52:20 25.34
>  2008-03-10 11:52:20 25.34
>  2008-03-10 11:52:49 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:28 25.34
>  2008-03-10 11:54:50 25.34
>  2008-03-10 12:31:29 25.34
>  2008-03-10 12:31:34 25.34
>  2008-03-10 12:31:35 25.34
>  2008-03-10 12:31:35 25.34
>  2008-03-10 12:31:35 25.34
>  2008-03-10 12:31:42 25.34
>  2008-03-10 12:31:42 25.34
>  2008-03-10 12:31:46 25.34
>  2008-03-10 12:31:47 25.34
>  2008-03-10 12:31:47 25.34
>  2008-03-10 12:31:47 25.34
>  2008-03-10 12:31:47 25.34
>  2008-03-10 12:31:52 25.34
>  2008-03-10 12:31:56 25.34
>  2008-03-10 12:31:57 25.34
>  2008-03-10 12:31:57 25.34
>  2008-03-10 12:31:57 25.34
>  2008-03-10 12:31:57 25.34
>  2008-03-10 12:31:58 25.34
>  2008-03-10 12:42:21 25.34
>  2008-03-10 12:55:24 25.34
>  2008-03-10 12:55:24 25.34
>  2008-03-10 12:55:25 25.34
>  2008-03-10 12:55:25 25.34
>  2008-03-10 12:55:25 25.34
>  2008-03-10 12:55:25 25.34
>  2008-03-10 12:55:25 25.34
>  2008-03-10 15:26:24 25.68
>  2008-03-10 15:26:24 25.68
>  2008-03-10 15:26:24 25.68
>  2008-03-10 15:26:24 25.68
>  2008-03-10 15:26:24 25.68
>  2008-03-10 15:26:25 25.68
>  2008-03-10 15:26:25 25.68
>  2008-03-10 15:31:24 25.68
>  2008-03-10 15:31:24 25.68
>  2008-03-10 15:46:56 25.68
>  2008-03-10 15:46:56 25.68
>  2008-03-10 15:46:56 25.68
>  2008-03-10 15:47:02 25.68
>  2008-03-10 15:48:12 25.42
>  2008-03-10 15:48:12 25.42
>  2008-03-10 15:48:13 25.42
>  2008-03-10 15:48:13 25.42
>  2008-03-10 15:48:13 25.42
>  2008-03-10 15:49:06 25.42
>  2008-03-10 15:49:06 25.42
>  2008-03-10 15:49:06 25.35
>  2008-03-10 15:49:06 25.35
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:06 25.34
>  2008-03-10 15:49:17 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:49:45 25.34
>  2008-03-10 15:50:40 25.34
>  2008-03-10 15:50:40 25.34
>  2008-03-10 15:50:40 25.34
>  2008-03-10 15:50:40 25.34
>  2008-03-10 15:50:40 25.34
>  2008-03-10 15:50:41 25.34
>  2008-03-10 16:02:12 25.35
>  2008-03-10 16:02:12 25.35
>  2008-03-10 16:02:12 25.35
>  2008-03-10 16:02:13 25.35
>  2008-03-10 16:14:02 25.35
>  2008-03-10 16:14:02 25.35
>  2008-03-10 16:14:13 25.35
>  2008-03-10 16:14:16 25.34
>  2008-03-10 16:14:16 25.30
>  2008-03-10 16:14:16 25.30
>  2008-03-10 16:14:17 25.30
>  2008-03-10 16:14:17 25.30
>  2008-03-10 16:14:17 25.30
>  2008-03-10 16:14:17 25.30
>  2008-03-10 16:14:18 25.30
>  2008-03-10 16:14:18 25.30
>  2008-03-10 16:14:18 25.30
>  2008-03-10 16:14:20 25.30
>  2008-03-10 16:14:33 25.30
>  2008-03-10 16:14:33 25.30
>  2008-03-10 16:14:34 25.30
>  2008-03-10 16:14:34 25.30
>  2008-03-10 16:14:34 25.30
>  2008-03-10 16:14:34 25.30
>  2008-03-10 16:14:45 25.30
>  2008-03-10 16:15:15 25.30
>  2008-03-10 16:15:37 25.30
>  2008-03-10 16:15:37 25.30
>  2008-03-10 16:15:38 25.30
>  2008-03-10 16:15:38 25.30
>  2008-03-10 16:15:38 25.30
>  2008-03-10 16:15:38 25.30
>  2008-03-10 16:16:37 25.30
>  2008-03-10 16:16:37 25.30
>  2008-03-10 16:16:38 25.30
>  2008-03-10 16:16:38 25.30
>  2008-03-10 16:16:38 25.30
>  2008-03-10 16:16:38 25.30
>  2008-03-10 16:22:46 25.35
>  2008-03-10 16:22:46 25.35
>  2008-03-10 16:22:46 25.35
>  2008-03-10 16:22:47 25.35
>  2008-03-10 16:22:47 25.35
>  2008-03-10 16:22:47 25.35
>  2008-03-10 16:22:47 25.35
>  2008-03-10 16:22:47 25.35
>  2008-03-10 16:22:48 25.35
>  2008-03-10 16:23:46 25.35
>  2008-03-10 16:23:46 25.35
>  2008-03-10 16:23:47 25.35
>  2008-03-10 16:23:47 25.35
>  2008-03-10 16:23:47 25.35
>  2008-03-10 16:23:47 25.35
>  2008-03-10 16:24:43 25.35
>  2008-03-10 16:24:43 25.35
>  2008-03-10 16:24:44 25.35
>  2008-03-10 16:24:44 25.35
>  2008-03-10 16:24:44 25.35
>  2008-03-10 16:24:44 25.35
>  2008-03-10 16:25:07 25.35
>  2008-03-10 16:25:07 25.35
>  2008-03-10 16:25:41 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:42 25.35
>  2008-03-10 16:25:43 25.35
>  2008-03-10 16:26:38 25.35
>  2008-03-10 16:26:38 25.35
>  2008-03-10 16:26:39 25.35
>  2008-03-10 16:32:49 25.35
>  2008-03-10 16:34:38 25.35
>  2008-03-10 16:35:09 25.35
>  2008-03-10 16:35:10 25.35
>  2008-03-10 16:35:10 25.35
>  2008-03-10 16:35:29 25.20
>  2008-03-10 16:35:29 25.20
>  2008-03-10 16:35:30 25.20
>  2008-03-10 16:35:30 25.20
>  2008-03-10 16:35:33 25.20
>  2008-03-10 16:35:33 25.20
>  2008-03-10 16:35:33 25.20
>  2008-03-10 16:35:34 25.20
>  2008-03-10 16:36:12 25.20
>  2008-03-10 16:36:12 25.20
>  2008-03-10 16:40:28 25.20
>  2008-03-10 16:43:42 25.20
>  2008-03-10 16:43:43 25.20
>  2008-03-10 16:44:24 25.20
>  2008-03-10 16:44:25 25.20
>  2008-03-10 16:44:25 25.20
>  2008-03-10 16:44:25 25.20
>  2008-03-10 16:50:31 25.20
>  2008-03-10 16:50:31 25.20
>  2008-03-10 16:51:31 25.20
>  2008-03-10 16:51:31 25.20
>  2008-03-10 16:52:29 25.20
>  2008-03-10 16:52:29 25.20
>  2008-03-10 16:53:00 25.20
>  2008-03-10 16:53:00 25.20
>  2008-03-10 16:53:23 25.20
>  2008-03-10 16:53:23 25.20
>  2008-03-10 16:54:27 25.20
>  2008-03-10 16:54:56 25.20
>  2008-03-10 16:55:30 25.20
>  2008-03-10 16:55:31 25.20
>  2008-03-10 16:55:31 25.20
>  2008-03-10 16:56:27 25.20
>  2008-03-10 16:56:27 25.10
>  2008-03-10 16:56:27 25.10
>  2008-03-10 16:56:28 25.10
>  2008-03-10 16:56:28 25.10
>  2008-03-10 16:56:28 25.10
>  2008-03-10 16:56:33 25.10
>  2008-03-10 16:56:43 25.10
>  2008-03-10 16:56:49 25.10
>  2008-03-10 17:02:16 25.10
>  2008-03-10 17:02:19 25.10
>  2008-03-10 17:03:56 25.10
>  2008-03-10 17:03:57 25.10
>  2008-03-10 17:05:59 25.06
>  2008-03-10 17:05:59 25.06
>  2008-03-10 17:06:00 25.06
>  2008-03-10 17:06:00 25.06
>  2008-03-10 17:06:00 25.06
>  2008-03-10 17:06:01 25.06
>  2008-03-10 17:06:12 25.05
>  2008-03-10 17:06:12 25.05
>  2008-03-10 17:06:12 25.05
>  2008-03-10 17:06:13 25.05
>  2008-03-10 17:06:13 25.05
>  2008-03-10 17:07:03 25.05
>  2008-03-10 17:07:16 25.05
>  2008-03-10 17:08:02 25.05
>  2008-03-10 17:08:02 25.01
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:02 25.00
>  2008-03-10 17:08:03 25.00
>  2008-03-10 17:08:03 25.00
>  2008-03-10 17:08:03 25.00
>  2008-03-10 17:08:10 25.00
>  2008-03-10 17:08:35 25.00
>  2008-03-10 17:08:43 25.00
>  2008-03-10 17:08:47 25.00
>  2008-03-10 17:24:18 25.00
>  2008-03-10 17:24:19 25.00
>  2008-03-10 17:24:19 25.00
>  2008-03-10 17:24:19 25.00
>  2008-03-10 17:24:19 25.00
>  2008-03-10 17:24:19 25.00
>  2008-03-10 17:24:20 25.00
>  2008-03-10 17:24:20 25.00
>  2008-03-10 17:29:05 25.00
>  2008-03-10 17:29:31 25.00
>  2008-03-10 17:29:31 25.00
>  2008-03-10 17:30:00 25.00
>
>
>
>  *************************************************************************
>  This message and any attachments (the "message") are con...{{dropped:10}}
>
>  _______________________________________________
>  R-SIG-Finance at stat.math.ethz.ch mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>  -- Subscriber-posting only.
>  -- If you want to post, subscribe first.
>



-- 
There's a way to do it better - find it.
Thomas A. Edison



More information about the R-SIG-Finance mailing list