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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 28 17:58:53 CEST 2015


Author: bodanker
Date: 2015-05-28 17:58:53 +0200 (Thu, 28 May 2015)
New Revision: 1688

Modified:
   pkg/quantstrat/R/paramsets.R
Log:
Fix environment subsetting in clone.portfolio

clone.portfolio() was originally written when blotter portfolio objects
were lists. Now that they're environments, subsetting by xts.tables
fails because grep() returns positions and you can't subset environments
by integers.

Use grep(..., value=TRUE) to get the values of the tables that match
the pattern, and use those character strings to subset the symbols
environment.


Modified: pkg/quantstrat/R/paramsets.R
===================================================================
--- pkg/quantstrat/R/paramsets.R	2015-05-21 19:45:04 UTC (rev 1687)
+++ pkg/quantstrat/R/paramsets.R	2015-05-28 15:58:53 UTC (rev 1688)
@@ -60,7 +60,7 @@
         {
             portfolio$symbols[[symbol]]$txn <- portfolio$symbols[[symbol]]$txn[1,]
 
-            xts.tables <- grep('(^posPL|txn)',names(portfolio$symbols[[symbol]]))
+            xts.tables <- grep('(^posPL|txn)',names(portfolio$symbols[[symbol]]), value=TRUE)
             for(xts.table in xts.tables)
                 portfolio$symbols[[symbol]][[xts.table]] <- portfolio$symbols[[symbol]][[xts.table]][1,]
         }



More information about the Blotter-commits mailing list