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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 17 15:04:14 CEST 2013


Author: bodanker
Date: 2013-10-17 15:04:13 +0200 (Thu, 17 Oct 2013)
New Revision: 1533

Modified:
   pkg/quantstrat/R/indicators.R
   pkg/quantstrat/R/initialize.R
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/R/signals.R
   pkg/quantstrat/R/utils.R
   pkg/quantstrat/R/wrapup.R
Log:
- Update modify.args to avoid evaluating '...', which causes a deparsed
  mktdata object to be part of the call created by do.call
- Update calls to modify.args to use '...' directly instead of list(...)


Modified: pkg/quantstrat/R/indicators.R
===================================================================
--- pkg/quantstrat/R/indicators.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/indicators.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -174,7 +174,7 @@
         # now add arguments from parameters
         .formals <- modify.args(.formals, parameters)
         # now add dots
-        .formals <- modify.args(.formals, list(...))
+        .formals <- modify.args(.formals, ...)
         
         tmp_val <- do.call(indicator$name, .formals)
 		

Modified: pkg/quantstrat/R/initialize.R
===================================================================
--- pkg/quantstrat/R/initialize.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/initialize.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -100,7 +100,7 @@
         # now add arguments from parameters
         .formals <- modify.args(.formals, parameters)
         # now add dots
-        .formals <- modify.args(.formals, list(...))
+        .formals <- modify.args(.formals, ...)
         
         do.call(init_o$name, .formals)
     }

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/rules.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -696,12 +696,13 @@
         # now add arguments from parameters
         .formals <- modify.args(.formals, parameters)
         # now add dots
-        .formals <- modify.args(.formals, list(...))
+        .formals <- modify.args(.formals, ...)
         
         # any rule-specific prefer-parameters should override global prefer parameter
         if(!is.null(rule$arguments$prefer)) .formals$prefer = rule$arguments$prefer
         
-        tmp_val <- do.call(rule$name, .formals)
+        # evaluate rule in applyRules' environment
+        tmp_val <- do.call(rule$name, .formals, envir=parent.frame(2))
                 
 #            print(paste('tmp_val ==', tmp_val))
     } #end rules loop

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/signals.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -105,7 +105,7 @@
         # now add arguments from parameters
         .formals <- modify.args(.formals, parameters)
         # now add dots
-        .formals <- modify.args(.formals, list(...))
+        .formals <- modify.args(.formals, ...)
 
         tmp_val <- do.call(signal$name, .formals)
 		

Modified: pkg/quantstrat/R/utils.R
===================================================================
--- pkg/quantstrat/R/utils.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/utils.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -52,8 +52,15 @@
     }
 }
 
-modify.args <- function(formals, arglist, dots=FALSE)
+modify.args <- function(formals, arglist, ..., dots=FALSE)
 {
+    # avoid evaluating '...' to make things faster
+    dots.names <- eval(substitute(alist(...)))
+
+    if(missing(arglist))
+        arglist <- NULL
+    arglist <- c(arglist, dots.names)
+
     # see 'S Programming' p. 67 for this matching
 
     # nothing to do if arglist is empty; return formals

Modified: pkg/quantstrat/R/wrapup.R
===================================================================
--- pkg/quantstrat/R/wrapup.R	2013-10-17 00:02:07 UTC (rev 1532)
+++ pkg/quantstrat/R/wrapup.R	2013-10-17 13:04:13 UTC (rev 1533)
@@ -115,7 +115,7 @@
             # now add arguments from parameters
             .formals <- modify.args(.formals, parameters)
             # now add dots
-            .formals <- modify.args(.formals, list(...))
+            .formals <- modify.args(.formals, ...)
             
             out[[wrapup_o$name]] <- do.call(wrapup_o$name, .formals)
         }            



More information about the Blotter-commits mailing list