[Blotter-commits] r1564 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 4 17:53:04 CET 2013


Author: bodanker
Date: 2013-11-04 17:53:04 +0100 (Mon, 04 Nov 2013)
New Revision: 1564

Modified:
   pkg/quantstrat/R/rules.R
Log:
- get curIndex from '...' if rule$timespan isn't NULL; thanks to Jan Humme


Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-11-04 14:56:55 UTC (rev 1563)
+++ pkg/quantstrat/R/rules.R	2013-11-04 16:53:04 UTC (rev 1564)
@@ -683,7 +683,15 @@
         if(!isTRUE(rule$enabled)) next()
         
         # check to see if we should run in this timespan
-        if(!is.null(rule$timespan) && nrow(mktdata[curIndex][rule$timespan])==0) next()
+        if(!is.null(rule$timespan)) {
+            # Get row index of timestamp for faster subsetting
+            if(hasArg(curIndex))
+                curIndex <- eval(match.call(expand.dots=TRUE)$curIndex, parent.frame())
+            else
+                curIndex <- timestamp
+            if(nrow(mktdata[curIndex][rule$timespan])==0)
+                next()
+        }
         
         # modify a few things
         rule$arguments$timestamp = timestamp



More information about the Blotter-commits mailing list