[R-SIG-Finance] Filtering dates/times from zoo/xts series

Brian G. Peterson brian at braverock.com
Mon Sep 26 12:48:47 CEST 2011


On Mon, 2011-09-26 at 00:48 -0700, chrisbird wrote:
> I actually managed to get the first part working (filtering by time),
> relatively simple:
> 
> spreadv[.indexhour(spreadv) > 9 & .indexhour(spreadv) < 21]

It is actually much simpler than that:

spreadv['T09:00/T21:00']

xts makes extensive use of ISO 8601 subsetting.

> However, still stuck on second question.

I typically remove days that don't fall on trading days when I am
initially processing the data.  If the markets were open, you probably
want the data.  If not, you probably don't want it.  But this requires
you to know the market calendar.

I'll also point out that if you're writing a backtest using blotter, it
would probably be far faster for you to base your backtest on
quantstrat, which adds a strategy logic abstraction layer on top of
blotter.

Cheers,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list