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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 16 20:00:48 CEST 2010


Author: braverock
Date: 2010-07-16 20:00:48 +0200 (Fri, 16 Jul 2010)
New Revision: 354

Modified:
   pkg/quantstrat/R/rules.R
Log:
- pass ruletype into ruleProc

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2010-07-16 17:44:32 UTC (rev 353)
+++ pkg/quantstrat/R/rules.R	2010-07-16 18:00:48 UTC (rev 354)
@@ -106,7 +106,7 @@
         nargs=NULL
     }
     
-    ruleProc <- function (ruletypelist,timestamp=NULL, path.dep, ...){
+    ruleProc <- function (ruletypelist,timestamp=NULL, path.dep, ruletype, ...){
         for (rule in ruletypelist){
             #TODO check to see if they've already been calculated
             if (!rule$path.dep==path.dep) next()
@@ -133,7 +133,8 @@
             
             .formals  <- formals(fun)
             onames <- names(.formals)
-            rule$arguments$timestamp=timestamp
+            rule$arguments$timestamp = timestamp
+			rule$arguments$ruletype  = ruletype
             pm <- pmatch(names(rule$arguments), onames, nomatch = 0L)
             # if (any(pm == 0L)) message(paste("some arguments stored for",rule$name,"do not match"))
             names(rule$arguments[pm > 0L]) <- onames[pm]
@@ -187,18 +188,18 @@
             switch( type ,
                     pre = {
                         if(length(strategy$rules[[type]])>=1){
-                            ruleProc(strategy$rules$pre,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol)    
+                            ruleProc(strategy$rules$pre,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type)    
                         }
                     },
                     risk = {
                         if(length(strategy$rules$risk)>=1){
-                            ruleProc(strategy$rules$risk,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol)    
+                            ruleProc(strategy$rules$risk,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type)    
                         }       
                     },
                     order = {
                         if(isTRUE(hold)) next()
                         if(length(strategy$rules[[type]])>=1) {
-                            ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol)
+                            ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type)
                         } else {
                             #(mktdata, portfolio, symbol, timestamp, slippageFUN=NULL)
                             timespan<-paste("::",timestamp,sep='')
@@ -212,13 +213,13 @@
                             if (getPosQty(Portfolio=portfolio,Symbol=symbol,Date=timestamp)==0) next()
                         }
                         if(length(strategy$rules[[type]])>=1) {
-                            ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol)
+                            ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type)
                         }      
                     },
                     post = {
                         #TODO do we processfor hold here, or not?
                         if(length(strategy$rules$post)>=1) {
-                            ruleProc(strategy$rules$post,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol)    
+                            ruleProc(strategy$rules$post,timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type)    
                         }
                     }
             ) # end switch            



More information about the Blotter-commits mailing list