[R] Millisecond TimeStamps

David Reiner David.Reiner at xrtrading.com
Thu Mar 24 21:34:36 CET 2011


?strptime or ?options

> d1 <- as.POSIXct("2009-09-30 10:00:00.543")
> d1
[1] "2009-09-30 10:00:00 CDT"
> # Oh, yeah, I forgot ....
> op <- options(digits.secs=6) # or 3
> d1
[1] "2009-09-30 10:00:00.543 CDT"
> # The accuracy was there already

HTH,
David L. Reiner, PhD
Head Quant
XR Trading LLC

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Madaliso Mulaisho
Sent: Thursday, March 24, 2011 12:14 PM
To: r-help at r-project.org
Subject: [R] Millisecond TimeStamps

I am wondering if there is a good way to work with data that is indexed in
time, via timestamps with a resolution in milliseconds.  As I understand it,
the POSIX classes have a resolution i n terms of seconds, and will not
process fractional seconds from a string.  Is this correct.  I realize that
this may be a little unclear.  Here is what I am trying to do:



A data frame with a time series and a price series, there the time series is
of the form:

"2009-09-30 10:00:00.543"



I ultimately like to create an xts object out of this data frame, or some
other object where I can easily work with times (find out how much time has
elapsed, between entries, etc).



Using, for example, the code:

as.POSIXct("2009-09-30 10:00:00.543", "%Y-%m-%d %H:%M:%S", tz="UTC")

I find this returned:

                "2009-09-30 10:00:00 UTC"



>From various experiments similar to the above, and from the forums, it first
seemed like POSIX could not process millisecond time stamps.  However, when
I call:

                Sys.time()

I get a POSIX object that has millisecond timestamps:

                "2011-03-24 13:11:52.79 EDT"





This has made me confused.  Does anyone know a way to go from a string
containing time data to a POSIX object with millisecond timestamps?



Thanks

Madaliso


        [[alternative HTML version deleted]]

______________________________________________
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.


This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws.  Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.



More information about the R-help mailing list