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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 8 19:57:47 CET 2011


Author: braverock
Date: 2011-03-08 19:57:47 +0100 (Tue, 08 Mar 2011)
New Revision: 567

Modified:
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/R/traderules.R
Log:
- minor improvements to hold/holdtill

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2011-03-02 20:03:33 UTC (rev 566)
+++ pkg/quantstrat/R/rules.R	2011-03-08 18:57:47 UTC (rev 567)
@@ -117,7 +117,11 @@
 #' and then again in stepping over the time indexes of the mktdata object.
 #' 
 #' Individual rule functions may need to use <<- to place \code{hold} and \code{holdtill}
-#' variables into play.  These would be most likely implemented by risk rules.
+#' variables into play.  These would be most likely implemented by risk rules.  When
+#' \code{hold==TRUE}, any open oders will still be processed (orders are \emph{NOT} 
+#' canceled automatically, but no new orders may be entered.  \code{type='risk'}
+#' rules will still function during a hold.  Note that hold must be set via a custom
+#' rule.  We tend to set hold in an order or risk rule. 
 #' 
 #' \code{quantstrat} has a significant amount of logic devoted to handling 
 #' path-dependent rule execution.  Most of that code/logic resides in this
@@ -284,7 +288,8 @@
             mktdata <<- mktdata
             ret <<- ret
             hold <<- hold #TODO FIXME hold processing doesn't work unless custom rule has set it with <<-
-
+            holdtill <<- holdtill 
+            
             #print(tmp_val)
         } #end rules loop
     } # end sub process function ruleProc
@@ -523,7 +528,6 @@
                         }
                     },
                     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, ruletype=type, mktinstr=mktinstr, ...)
                         } else {

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2011-03-02 20:03:33 UTC (rev 566)
+++ pkg/quantstrat/R/traderules.R	2011-03-08 18:57:47 UTC (rev 567)
@@ -216,7 +216,7 @@
 getPosLimit <- function(portfolio, symbol, timestamp){
     portf<-getPortfolio(portfolio)
     # try to get on timestamp, otherwise find the most recent
-    toDate = paste('::', as.character(timestamp), sep="")
+    toDate = paste('::', timestamp, sep="")
     PosLimit = last(portf$symbols[[symbol]]$PosLimit[toDate])
     return(PosLimit)
 }



More information about the Blotter-commits mailing list