Skip to content
Prev 8188 / 15274 Next

How to know when an XTS row is at a particular interval

On Sat, 2011-07-09 at 12:37 -0700, Noah Silverman wrote:
I'll note that you didn't say that you wanted to apply to streaming
data.  Your original post said:

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

though you did say:

"Iterating through the series to simulate a trading day."

You didn't say that you ultimately wanted to apply the same algorithm to
streaming data.  All backtesting (trading simulation) involves some
amount of iteration through the data, assuming that there is some path
dependent logic (and real trading is always path dependent, though
path-independent assumptions may serve for simple things).

Even when 'iterating' through historical data, endpoints is still the
most efficient mechanism in R that I'm aware of.  Streaming data is
necessarily a different problem.

R doesn't have any native support for streaming data types that I am
aware of.  You need to use some sort of sampling or event loop
algorithm.
Well, messages from an exchange are timestamped.  Use those.  Keep your
'last' transaction in a buffer, and then pop it onto a stack as soon as
you have an observation (transaction or not) that is at or past the
mark.

Jeff has previously reported being able to handle several thougsand
messages per second from IB in an event loop in R, which is probably
sufficient for most single-instrument modeling.

Regards,

   - Brian