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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 20 23:38:59 CET 2013


Author: opentrades
Date: 2013-01-20 23:38:58 +0100 (Sun, 20 Jan 2013)
New Revision: 1372

Modified:
   pkg/quantstrat/R/paramsets.R
   pkg/quantstrat/R/walk.forward.R
Log:
- added some more results objects to paramsets() + walk.forward() returned environment in preparation for walk.forward() graph



Modified: pkg/quantstrat/R/paramsets.R
===================================================================
--- pkg/quantstrat/R/paramsets.R	2013-01-20 21:59:33 UTC (rev 1371)
+++ pkg/quantstrat/R/paramsets.R	2013-01-20 22:38:58 UTC (rev 1372)
@@ -476,11 +476,21 @@
         return(result)
     }
 
-    results$distributions <- distributions
-    results$constraints <- constraints
+    #results$distributions <- distributions
+    #results$constraints <- constraints
 
     if(is.null(audit))
         .audit <- NULL
+    else
+    {
+        assign('distributions', distributions, envir=.audit)
+        assign('constraints', constraints, envir=.audit)
+        assign('paramset.label', paramset.label, envir=.audit)
+        assign('param.combos', param.combos, envir=.audit)
+        assign('param.combos', param.combos, envir=.audit)
+        assign('tradeStats', results$tradeStats, envir=.audit)
+        assign('user.func', results$user.func, envir=.audit)
+    }
 
     return(results)
 }

Modified: pkg/quantstrat/R/walk.forward.R
===================================================================
--- pkg/quantstrat/R/walk.forward.R	2013-01-20 21:59:33 UTC (rev 1371)
+++ pkg/quantstrat/R/walk.forward.R	2013-01-20 22:38:58 UTC (rev 1372)
@@ -101,23 +101,16 @@
 
             print(paste('=== training', paramset.label, 'on', training.timespan))
 
-            audit.env <- NULL
+            .audit <- NULL
             if(!is.null(audit.prefix))
-                audit.env <- new.env()
+                .audit <- new.env()
 
             # run backtests on training window
             result$apply.paramset <- apply.paramset(strategy.st=strategy.st, paramset.label=paramset.label,
                 portfolio.st=portfolio.st, account.st=account.st,
                 mktdata=symbol[training.timespan], nsamples=nsamples,
-                calc='slave', audit=audit.env, verbose=verbose, ...=...)
+                calc='slave', audit=.audit, verbose=verbose, ...=...)
 
-            if(!is.null(audit.prefix))
-            {
-                save(audit.env, file=paste(audit.prefix, index(symbol[training.start]), index(symbol[training.end]), 'RData', sep='.'))
-
-                audit.env <- NULL
-            }
-
             tradeStats.list <- result$apply.paramset$tradeStats
 
             if(!missing(k.testing) && k.testing>0)
@@ -129,6 +122,10 @@
                 param.combo.nr <- do.call(obj.func, obj.args)
                 param.combo <- tradeStats.list[param.combo.nr, 1:grep('Portfolio', names(tradeStats.list)) - 1]
 
+                assign('obj.func', obj.func, envir=.audit)
+                assign('param.combo.nr', param.combo.nr, envir=.audit)
+                assign('param.combo', param.combo, envir=.audit)
+
                 # configure strategy to use selected param.combo
                 strategy <- quantstrat:::install.param.combo(strategy, param.combo, paramset.label)
 
@@ -151,6 +148,13 @@
                 k <- k + 1
             }
 
+            if(!is.null(audit.prefix))
+            {
+                save(.audit, file=paste(audit.prefix, index(symbol[training.start]), index(symbol[training.end]), 'RData', sep='.'))
+
+                .audit <- NULL
+            }
+
             results[[k]] <- result
 
             k <- k + k.testing



More information about the Blotter-commits mailing list