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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 6 12:04:14 CET 2010


Author: braverock
Date: 2010-02-06 12:04:13 +0100 (Sat, 06 Feb 2010)
New Revision: 230

Modified:
   pkg/quantstrat/R/strategy.R
   pkg/quantstrat/R/traderules.R
Log:
- add rule types to the strategy container

Modified: pkg/quantstrat/R/strategy.R
===================================================================
--- pkg/quantstrat/R/strategy.R	2010-02-06 00:09:17 UTC (rev 229)
+++ pkg/quantstrat/R/strategy.R	2010-02-06 11:04:13 UTC (rev 230)
@@ -35,7 +35,13 @@
         }
         # if assets is a named vector, we'll assume it is current weights
     }
-       
+    rules<-list()
+    rules$risk<-list()
+    rules$order<-list()
+    rules$rebalance<-list()
+    rules$exit<-list()
+    rules$entry<-list()
+    
     ## now structure and return
     strat<-structure(
                     list(
@@ -43,7 +49,7 @@
                             assets = assets,
                             indicators = list(),
                             signals = list(),
-                            rules = list(),
+                            rules = rules,
                             constraints = NULL,
                             call = match.call()
                     ),

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2010-02-06 00:09:17 UTC (rev 229)
+++ pkg/quantstrat/R/traderules.R	2010-02-06 11:04:13 UTC (rev 230)
@@ -47,9 +47,9 @@
     if (!is.list(arguments)) stop("arguments must be passed as a named list")
     arguments$label=label
     tmp_rule$arguments<-arguments
-    if(!hasArg(indexnum) | (hasArg(indexnum) & is.null(indexnum))) indexnum = length(strategy$rules)+1
+    if(!hasArg(indexnum) | (hasArg(indexnum) & is.null(indexnum))) indexnum = length(strategy$rules[type])+1
     tmp_rule$call<-match.call()
-    strategy$rules[[indexnum]]<-tmp_rule
+    strategy$rules[type][[indexnum]]<-tmp_rule
     
     if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
     else return(strategy)



More information about the Blotter-commits mailing list