[R] Divide tick-data into intervalls

Joshua Ulrich josh.m.ulrich at gmail.com
Tue May 8 14:37:16 CEST 2012


You can use the to.period family of functions in the xts package for
this.  For example,

Lines <-
"2011-11-01 08:00:00 0.000000000
2011-11-01 08:00:00 0.000000000
2011-11-01 08:02:00 0.000000000
2011-11-01 08:03:00 -0.017033339
2011-11-01 08:24:00 0.000000000
2011-11-01 08:24:00 0.000000000
2011-11-01 08:29:00 0.000000000
2011-11-01 08:29:00 0.000000000
2011-11-01 08:29:00 0.000000000
2011-11-01 08:29:00 0.000000000
2011-11-01 08:29:00 0.002166062
2011-11-01 08:44:00 0.000000000
2011-11-01 08:44:00 -0.002166062
2011-11-01 08:44:00 0.004321374
2011-11-01 10:36:00 0.010618976
2011-11-01 15:59:00 0.002092990
2011-11-01 16:21:00 0.000000000
2011-11-01 16:30:00 0.004155960
2011-11-02 08:00:00 0.000000000
2011-11-02 11:50:00 0.000000000
2011-11-02 13:38:00 -0.002073009"
d <- read.table(con <- textConnection(Lines))
close(con)
library(xts)
x <- xts(d$V3, as.POSIXct(paste(d$V1, d$V2)))
to.minutes3(x)

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com


On Tue, May 8, 2012 at 3:14 AM, oswi3605 <jeppf at mailinator.com> wrote:
>
> Hello,
>
> Im currently writing my bachelor thesis in statistical finance and i have
> run into a small problem. I want to evaluate forcasts from my GARCH with
> realized intraday volatility. The intraday data is Tick-data over a certain
> period. The date column is presented as for example 2011-11-01 09:24:41 for
> different points in time. The other column is with the stock prices at that
> same time. What I want to do is to recieve the end courses of certain time
> intervals. For example i want to know what the closing course if for every
> five minute or ten minute interval in the sample. In other words, i want to
> transform the tick-data into k-minute-interval data.
>
> I have been trying to this in the following way:
>
> The data has been converted to a time serie and look likes:
>
> price
>  2011-11-01 08:00:00 0.000000000
>  2011-11-01 08:00:00 0.000000000
>  2011-11-01 08:02:00 0.000000000
>  2011-11-01 08:03:00 -0.017033339
>  2011-11-01 08:24:00 0.000000000
>  2011-11-01 08:24:00 0.000000000
>  2011-11-01 08:29:00 0.000000000
>  2011-11-01 08:29:00 0.000000000
>  2011-11-01 08:29:00 0.000000000
>  2011-11-01 08:29:00 0.000000000
>  2011-11-01 08:29:00 0.002166062
>  2011-11-01 08:44:00 0.000000000
>  2011-11-01 08:44:00 -0.002166062
>  2011-11-01 08:44:00 0.004321374
>  2011-11-01 10:36:00 0.010618976
>  2011-11-01 15:59:00 0.002092990
>  2011-11-01 16:21:00 0.000000000
>  2011-11-01 16:30:00 0.004155960
>  2011-11-02 08:00:00 0.000000000
>  2011-11-02 11:50:00 0.000000000
>  2011-11-02 13:38:00 -0.002073009
>
> and so on for 108 days (this stock is a small cap company, and therefore the
> infrequent trading)
> I tried one coding option but it did not work even after much modification
> of the coding, so i need a new approach. An answer in coding would be much
> appreciated.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Divide-tick-data-into-intervalls-tp4616873.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list