[R-SIG-Finance] OHLC and volume data analysis using quantmod
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
z <- xts(y[, 2:3], y[, 1])
On Mon, Jan 16, 2012 at 11:50 AM, financial engineer
<fin_engr at hotmail.com> wrote:
> 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.).
> x = read.table("tick.dat", header = FALSE, sep="\t", skip=0)
> 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")
> 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
> -- 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