[R-SIG-Finance] Non unique timestamp in zoo object
Brian G. Peterson
brian at braverock.com
Tue Sep 1 19:13:37 CEST 2009
jatin patni wrote:
> I'm trying to create a zoo object from a tick data file(sample below) which
> contains timestamps only.
> Filename: "20080202.trd"
> 1|BHARTIARTL|EQ|18:15:05|600|1
> 2|BHARTIARTL|EQ|18:15:05|600|99
> 3|GLENMARK|EQ|18:15:05|238.1|5
> 4|HINDALCO|EQ|18:15:05|43.75|100
> 5|BHARTIARTL|EQ|18:15:05|600|1
> 6|BHEL|EQ|18:15:05|1100|11
> 7|HINDALCO|EQ|18:15:06|43.2|1
> 8|CHAMBLFERT|EQ|18:15:06|46|10
> 9|CHAMBLFERT|EQ|18:15:06|46|90
> 10|BAJAUTOFIN|EQ|18:15:06|80|100
>
> As you can see that timestamps are not unique even at microsecond levels.
> Inorder to create a zoo/xts object to be used with quantmod later, How do
> I:-
> 1)Do I have to merge two rows with the same timestamp, symbols, price but
> different volumes.(Do I need to do this or is there some other way possible)
> 2)Append date to the timestamp while creating the zoo/xts object
>
> I'm trying to explore the 'format' argument, and POSIX and chron but without
> much success.
>
Your target should be POSIXct, as that is what xts uses internally,
given that your stated goal is to use xts and quantmod.
?as.POSIXct
?format.POSIXct
These look like one second bars, not microsecond bars. To see
microseconds, if you have them:
options(digits.secs=6)
zoo doesn't require unique timestamps, just ordered ones. In this case,
your trades are ordered in the files. You might need to append an order
in the microseconds if you really only have second bars. It's also not
necessary to have unique timestamps, but you'll be happier if you do.
Regards,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list