[R-SIG-Finance] How to know when an XTS row is at a particular interval

Noah Silverman noahsilverman at ucla.edu
Thu Jul 7 22:27:53 CEST 2011


Hi,


I have a big dataset of tick data.  (Actual transactions at sub-second frequency)

I've used R to convert this to an xts object.

Iterating through the series to simulate a trading day.

I'd like to know when a particular transaction is "on the minute" or "on the 5 minute" mark.  Of course, I can use all the great functions of xts to convert the series to bars of any frequency, but that's not what I want.  I'd like to iterate over all the transaction and then somehow know when I've hit a bar boundary.

One possible issue is if I don't have a transaction exactly at the bar.  (More of a theoretical question.)  For example, If I have a transaction at 11:59:59, and then the next transaction is at 12:00:01.  Then no transaction occurred exactly on the 1 minute boundary.  I'm not sure the best way to handle this.

The general "big picture' concept is that a trading strategy might only want to trigger on 5 minute bars, but I'd like to keep updating some of my indicators as individual trades flow in.  

Thoughts?


--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095



More information about the R-SIG-Finance mailing list