[Blotter-commits] r1404 - in pkg/quantstrat: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 26 16:05:57 CET 2013


Author: opentrades
Date: 2013-02-26 16:05:56 +0100 (Tue, 26 Feb 2013)
New Revision: 1404

Modified:
   pkg/quantstrat/R/ruleSignal.R
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/man/ruleSignal.Rd
Log:
- renamed ruleSignal() order.price parameter to chain.price (to pass fill price in chained orders)
- added new order.price parameter to ruleSignal() to force the order.price, ignoring mktdata etc, to allow for stop prices that are not related to chain order fill price



Modified: pkg/quantstrat/R/ruleSignal.R
===================================================================
--- pkg/quantstrat/R/ruleSignal.R	2013-02-25 22:33:57 UTC (rev 1403)
+++ pkg/quantstrat/R/ruleSignal.R	2013-02-26 15:05:56 UTC (rev 1404)
@@ -48,11 +48,12 @@
 #' @param prefer price method for getPrice
 #' @param sethold boolean, puts entry Rule processing on hold, default FALSE
 #' @param label rule label, default '', added by \code{\link{applyRules}}
-#' @param orderprice a fixed order price, will overrule all mktdata lookup, only meant for internal use really, default NULL
+#' @param order.price the order price to use, will overrule any mktdata lookup as well as chain.price (see below), meant to specify eg. a stop-loss price that is unrelated to the fill price (see chain.price)
+#' @param chain.price the price that the parent order got filled for, used to pass to children in the order chain, will overrule all mktdata lookup, only meant for internal use really, default NULL
 #' @seealso \code{\link{osNoOp}} , \code{\link{add.rule}}
 #' @export
 
-ruleSignal <- function(mktdata=mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside=NULL, orderset=NULL, threshold=NULL, tmult=FALSE, replace=TRUE, delay=0.0001, osFUN='osNoOp', pricemethod=c('market','opside','active'), portfolio, symbol, ..., ruletype, TxnFees=0, prefer=NULL, sethold=FALSE, label='', orderprice=NULL)
+ruleSignal <- function(mktdata=mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside=NULL, orderset=NULL, threshold=NULL, tmult=FALSE, replace=TRUE, delay=0.0001, osFUN='osNoOp', pricemethod=c('market','opside','active'), portfolio, symbol, ..., ruletype, TxnFees=0, prefer=NULL, sethold=FALSE, label='', order.price=NULL, chain.price=NULL)
 {
     if(!is.function(osFUN))
         osFUN<-match.fun(osFUN)
@@ -118,8 +119,17 @@
             tmpqty <- orderqty
         }
 
-	if(is.null(orderprice))
+	if(!is.null(order.price))
 	{
+print(paste('--- order.price =', order.price))
+		orderprice <- order.price
+	}
+	else if(!is.null(chain.price))
+	{
+		orderprice <- chain.price
+	}
+	else
+	{
 		switch(pricemethod,
 			market = ,
 			opside = ,
@@ -186,7 +196,7 @@
 	}
 
         if(is.null(orderset)) orderset=NA
-
+print(paste('=== orderprice =', orderprice))
         
         ## now size the order
         #TODO add fancy formals matching for osFUN

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-02-25 22:33:57 UTC (rev 1403)
+++ pkg/quantstrat/R/rules.R	2013-02-26 15:05:56 UTC (rev 1404)
@@ -639,7 +639,7 @@
                                 }
                                 if(length(rules) > 0)
                                 {
-                                    ruleProc(rules, timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list('orderprice'=as.numeric(closed.orders$Order.Price), ...))
+                                    ruleProc(rules, timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list('chain.price'=as.numeric(closed.orders$Order.Price), ...))
                                 }
                             }
                         }

Modified: pkg/quantstrat/man/ruleSignal.Rd
===================================================================
--- pkg/quantstrat/man/ruleSignal.Rd	2013-02-25 22:33:57 UTC (rev 1403)
+++ pkg/quantstrat/man/ruleSignal.Rd	2013-02-26 15:05:56 UTC (rev 1404)
@@ -9,7 +9,7 @@
     pricemethod = c("market", "opside", "active"),
     portfolio, symbol, ..., ruletype, TxnFees = 0,
     prefer = NULL, sethold = FALSE, label = "",
-    orderprice = NULL)
+    order.price = NULL, chain.price = NULL)
 }
 \arguments{
   \item{mktdata}{an xts object containing market data.
@@ -81,9 +81,15 @@
   \item{label}{rule label, default '', added by
   \code{\link{applyRules}}}
 
-  \item{orderprice}{a fixed order price, will overrule all
-  mktdata lookup, only meant for internal use really,
-  default NULL}
+  \item{order.price}{the order price to use, will overrule
+  any mktdata lookup as well as chain.price (see below),
+  meant to specify eg. a stop-loss price that is unrelated
+  to the fill price (see chain.price)}
+
+  \item{chain.price}{the price that the parent order got
+  filled for, used to pass to children in the order chain,
+  will overrule all mktdata lookup, only meant for internal
+  use really, default NULL}
 }
 \description{
   As described elsewhere in the documentation, quantstrat



More information about the Blotter-commits mailing list