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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 11 21:01:24 CEST 2010


Author: braverock
Date: 2010-10-11 21:01:24 +0200 (Mon, 11 Oct 2010)
New Revision: 416

Modified:
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/R/parameters.R
   pkg/quantstrat/R/signals.R
   pkg/quantstrat/R/traderules.R
Log:
- update sigFormula to make it more robust (thanks to THomas Bolton)
- minor updates to roxygen docs

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2010-10-11 13:23:33 UTC (rev 415)
+++ pkg/quantstrat/R/orders.R	2010-10-11 19:01:24 UTC (rev 416)
@@ -178,7 +178,7 @@
 #' @param tmult if TRUE, threshold is a percent multiplier for \code{price}, not a scalar to be added/subtracted from price.  threshold will be dynamically converted to a scalar at time of order entry
 #' @param replace TRUE/FALSE, whether to replace any other open order(s) on this portfolio symbol, default TRUE 
 #' @param return if TRUE, return the row that makes up the order, default FALSE (will assign into the environment)
-#' @param dots any other passthru parameters
+#' @param \dots any other passthru parameters
 #' @param TxnFees numeric fees (usually negative) or function name for calculating TxnFees (processing happens later, not in this function)
 #' @export
 addOrder <- function(portfolio, symbol, timestamp, qty, price, ordertype, side, threshold=NULL, status="open", statustimestamp='' , delay=.00001, tmult=FALSE, replace=TRUE, return=FALSE, ..., TxnFees=0)

Modified: pkg/quantstrat/R/parameters.R
===================================================================
--- pkg/quantstrat/R/parameters.R	2010-10-11 13:23:33 UTC (rev 415)
+++ pkg/quantstrat/R/parameters.R	2010-10-11 19:01:24 UTC (rev 416)
@@ -7,7 +7,7 @@
 #' @param label 
 #' @param ... 
 #' @param store 
-#' @export
+# @export
 add.parameter <- 
 function (strategy, 
           type = c('indicator','signal'), 
@@ -74,7 +74,7 @@
 #' @param type 
 #' @param name 
 #' @param paramTable 
-#' @export
+# @export
 add.paramLookupTable <- function(strategy, type, name, paramTable){
     assign(paste(strategy,type,name,'table',pos=.strategy),paramTable)
 }

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2010-10-11 13:23:33 UTC (rev 415)
+++ pkg/quantstrat/R/signals.R	2010-10-11 19:01:24 UTC (rev 416)
@@ -262,7 +262,7 @@
 #' This allows the columns of the data to be addressed without any major manipulation, simply by column name.  In most cases in quantstrat, this will be either the price/return columns, or columns added by indicators or prior signals.
 #' The formula will return TRUE/FALSE for each row comparison as a time series column which can then be used for rule execution.  The \code{formula} will be evaluated using \code{\link{eval}} as though in an if statement. 
 #' 
-#' This code is adapted from the approach used by Vijay Vaidyanthan in his PAST/AAII/SIPRO code to construct arbitrary, formulaic, comparisons.  Many thanks to Vijay for sharing his expertise.
+#' This code is adapted from the approach used by Vijay Vaidyanthan in his PAST(AAII/SIPRO) code to construct arbitrary, formulaic, comparisons.  Many thanks to Vijay for sharing his expertise.
 #'  
 #' @param label text label to apply to the output
 #' @param data data to apply formula to
@@ -271,11 +271,13 @@
 #' @export
 sigFormula <- function(label, data=mktdata, formula ,cross=FALSE){
 	# Vijay's PAST/AAII/SIPRO example
-	# fieldVals <- try(eval(parse(text=expression), al, parent.frame()))
+	# fieldVals <- try(eval(parse(text=expression), data))
 	ret_sig=NULL
-	ret_sig <- try(eval(parse(text=formula), data, parent.frame()))
-	if(isTRUE(cross)) ret_sig <- diff(ret_sig)==1
-	colnames(ret_sig)<-label
+	ret_sig <- try(xts(eval(parse(text=formula), as.data.frame(data)),order.by=index(data)))
+	if(is.xts(ret_sig)){
+		if(isTRUE(cross)) ret_sig <- diff(ret_sig)==1
+		colnames(ret_sig)<-label
+	}
 	return(ret_sig)
 }
 

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2010-10-11 13:23:33 UTC (rev 415)
+++ pkg/quantstrat/R/traderules.R	2010-10-11 19:01:24 UTC (rev 416)
@@ -31,6 +31,7 @@
 #' @param symbol identifier of the instrument to place orders for.  The name of any associated price objects (xts prices, usually OHLC) should match these
 #' @param ... any other passthru parameters
 #' @param ruletype one of "risk","order","rebalance","exit","entry", see \code{\link{add.rule}}
+#' @param TxnFees numeric fees (usually negative) or function name for calculating TxnFees (processing happens later, not in this function)
 #' @seealso \code{\link{osNoOp}} , \code{\link{add.rule}}
 #' @export
 ruleSignal <- function(data=mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside=NULL, threshold=NULL, replace=TRUE, delay=0.0001, osFUN='osNoOp', pricemethod=c('market','opside','maker'), portfolio, symbol, ..., ruletype, TxnFees=0 )



More information about the Blotter-commits mailing list