[R-SIG-Finance] OHLC and volume data analysis using quantmod

G See gsee000 at gmail.com
Mon Jan 16 20:06:56 CET 2012


If you apply to.minutes3 to an object that has volume, the volume will
be summed for you.

I think the following should work for you, although I didn't test your
specific example:

z <- xts(y[, 2:3], y[, 1])
to.minutes3(z, OHLC=TRUE)

HTH,
Garrett

On Mon, Jan 16, 2012 at 11:50 AM, financial engineer
<fin_engr at hotmail.com> wrote:
>
>
> hi,
>
> I have a time series of tick data and I am trying to get the aggregate volume for every 3-minutes for the tick data that I have converted into OHLC format (so I can use some of the nice functionalities of quantmod for my analysis).
>
> I have written the following code, but do
>  not know how to get the aggregate volume for the 3-minutes in that OHLC for some
> volume analysis (so I can use aggregate(Vo(x)) etc.).
>
> library(tseries)
> library(xts)
> library(quantmod)
>
>
> x = read.table("tick.dat", header = FALSE, sep="\t", skip=0)
> x
>             V1    V2               V3    V4    V5    V6       V7 V8  V9
> 11107  U10 2010-07-01  1      1453 9160 TRUE  N  N   2
> 11108  U10 2010-07-01  1      1453 9160 TRUE  N  N   1
> 11109  U10 2010-07-01  1      1454 9155 TRUE  N  N   4
> 11110  U10 2010-07-01  1      1455 9155 TRUE  N  N   3
> 11111  U10 2010-07-01  1      1455 9155 TRUE  N  N   1
>
> dt<-sprintf("%s %04d",x$V2,x$V4)
> dt<-as.POSIXlt(dt,format="%Y-%m-%d %H%M")
>
> y <- data.frame(dt,x$V5,x$V9)
> colnames(y) <- c("Date","Price","Volume")
> str(y)
>
> z <- xts(y[,2], y[,1])
>
> tickmin <- to.minutes3(z, OHLC=TRUE)
>
> Can anyone please suggest how I get the aggregate volume by 3-minutes into my OHLC series.
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list