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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 26 20:19:52 CET 2015


Author: bodanker
Date: 2015-12-26 20:19:52 +0100 (Sat, 26 Dec 2015)
New Revision: 1729

Modified:
   pkg/quantstrat/R/paramsets.R
   pkg/quantstrat/R/signals.R
Log:
Fix signal analysis with only one distribution

The signal analysis code would only run the first distribution value if
there is only one distribution, because it subset a data.frame with
only a value for 'i'. If there's only one distrubtion, there's only one
column in the data.frame, so subsetting by 'i' returns a vector.

Add a check in install.param.combo to throw an error if it is passed a
vector instead of an object with a dim attribute.


Modified: pkg/quantstrat/R/paramsets.R
===================================================================
--- pkg/quantstrat/R/paramsets.R	2015-12-25 15:27:55 UTC (rev 1728)
+++ pkg/quantstrat/R/paramsets.R	2015-12-26 19:19:52 UTC (rev 1729)
@@ -151,6 +151,10 @@
 
 install.param.combo <- function(strategy, param.combo, paramset.label)
 {
+    if (is.null(dim(param.combo))) {
+        stop("'param.combo' must have a dim attribute")
+    }
+
     for(param.label in colnames(param.combo))
     {
         distribution <- strategy$paramsets[[paramset.label]]$distributions[[param.label]]

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2015-12-25 15:27:55 UTC (rev 1728)
+++ pkg/quantstrat/R/signals.R	2015-12-26 19:19:52 UTC (rev 1729)
@@ -472,7 +472,7 @@
   #   Loop through each symbol
   # TODO: parallelize it
   for(i in 1:nrow(param.combos)){  # param.combo = param.combos[1,]
-    param.combo = param.combos[i,]
+    param.combo <- param.combos[i,,drop=FALSE]
     
     if(verbose)cat("Applying Parameter Set: ",toString(param.combo),'\n')  
     



More information about the Blotter-commits mailing list