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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 26 21:08:35 CEST 2010


Author: braverock
Date: 2010-07-26 21:08:35 +0200 (Mon, 26 Jul 2010)
New Revision: 360

Modified:
   pkg/quantstrat/R/indicators.R
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/R/signals.R
   pkg/quantstrat/R/strategy.R
   pkg/quantstrat/demo/00Index
   pkg/quantstrat/demo/BBands.R
   pkg/quantstrat/man/add.indicator.Rd
   pkg/quantstrat/man/add.rule.Rd
   pkg/quantstrat/man/add.signal.Rd
   pkg/quantstrat/man/applyIndicators.Rd
   pkg/quantstrat/man/applyRules.Rd
   pkg/quantstrat/man/applySignals.Rd
   pkg/quantstrat/man/applyStrategy.Rd
   pkg/quantstrat/man/stratBBands.Rd
Log:
- add parameter support for passing parameters at evaluation-time
- update BBands demo to use parameters
- update docs


Modified: pkg/quantstrat/R/indicators.R
===================================================================
--- pkg/quantstrat/R/indicators.R	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/R/indicators.R	2010-07-26 19:08:35 UTC (rev 360)
@@ -15,13 +15,14 @@
 #' @param strategy an object of type 'strategy' to add the indicator to
 #' @param name name of the indicator, must correspond to an R function
 #' @param arguments default arguments to be passed to an indicator function when executed
+#' @param parameters vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision
 #' @param label arbitrary text label for indicator output, NULL default will be converted to '<name>.ind'
 #' @param ... any other passthru parameters
 #' @param enabled TRUE/FALSE whether the indicator is enabled for use in applying the strategy, default TRUE
 #' @param indexnum if you are updating a specific indicator, the index number in the $indicators list to update
 #' @param store TRUE/FALSE whether to store the strategy in the .strategy environment, or return it.  default FALSE
 #' @export
-add.indicator <- function(strategy, name, arguments, label=NULL, ..., enabled=TRUE, indexnum=NULL, store=FALSE) {
+add.indicator <- function(strategy, name, arguments, parameters=NULL, label=NULL, ..., enabled=TRUE, indexnum=NULL, store=FALSE) {
     if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
     tmp_indicator<-list()
     tmp_indicator$name<-name
@@ -30,8 +31,13 @@
     tmp_indicator$enabled=enabled
     if (!is.list(arguments)) stop("arguments must be passed as a named list")
     tmp_indicator$arguments<-arguments
+	if(!is.null(parameters)) tmp_indicator$parameters = parameters
+	if(length(list(...))) tmp_indicator<-c(tmp_indicator,list(...))
+	
     if(!hasArg(indexnum) | (hasArg(indexnum) & is.null(indexnum))) indexnum = length(strategy$indicators)+1
     tmp_indicator$call<-match.call()
+	class(tmp_indicator)<-'strat_indicator'
+	
     strategy$indicators[[indexnum]]<-tmp_indicator
     
     if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
@@ -41,9 +47,10 @@
 #' apply the indicators in the strategy to arbitrary market data
 #' @param strategy an object of type 'strategy' to add the indicator to
 #' @param mktdata an xts object containing market data.  depending on indicators, may need to be in OHLCV or BBO formats
+#' @param parameters named list of parameters to be applied during evaluation of the strategy
 #' @param ... any other passthru parameters
 #' @export
-applyIndicators <- function(strategy, mktdata, ...) {
+applyIndicators <- function(strategy, mktdata, parameters=NULL, ...) {
     #TODO add Date subsetting
     
     # TODO check for symbol name in mktdata using Josh's code:
@@ -66,7 +73,15 @@
         #TODO check to see if they've already been calculated
 
         if(!is.function(get(indicator$name))){
-            if(!is.function(get(paste("sig",indicator$name,sep='.')))){
+            if(!is.function(get(paste("sig",indicator$name,sep='.')))){		
+				# now add arguments from parameters
+				if(length(parameters)){
+					pm <- pmatch(names(parameters), onames, nomatch = 0L)
+					names(parameters[pm > 0L]) <- onames[pm]
+					.formals[pm] <- parameters[pm > 0L]
+				}
+				
+				
                 message(paste("Skipping indicator",indicator$name,"because there is no function by that name to call"))
                 next()      
             } else {
@@ -86,6 +101,14 @@
             warning(paste("some arguments stored for",indicator$name,"do not match"))
         names(indicator$arguments[pm > 0L]) <- onames[pm]
         .formals[pm] <- indicator$arguments[pm > 0L]
+		
+		# now add arguments from parameters
+		if(length(parameters)){
+			pm <- pmatch(names(parameters), onames, nomatch = 0L)
+			names(parameters[pm > 0L]) <- onames[pm]
+			.formals[pm] <- parameters[pm > 0L]
+		}
+		
         #now add arguments from dots
         if (length(nargs)) {
             pm <- pmatch(names(nargs), onames, nomatch = 0L)

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/R/rules.R	2010-07-26 19:08:35 UTC (rev 360)
@@ -36,7 +36,8 @@
 #'    
 #' @param strategy an object of type 'strategy' to add the rule to
 #' @param name name of the rule, must correspond to an R function
-#' @param arguments default arguments to be passed to an rule function when executed
+#' @param arguments named list of default arguments to be passed to an rule function when executed
+#' @param parameters vector of strings naming parameters to be saved for apply-time definition
 #' @param label arbitrary text label for rule output, NULL default will be converted to '<name>.rule'
 #' @param type one of "risk","order","rebalance","exit","enter", see Details
 #' @param ... any other passthru parameters
@@ -45,7 +46,7 @@
 #' @param path.dep TRUE/FALSE whether rule is path dependent, default TRUE, see Details 
 #' @param store TRUE/FALSE whether to store the strategy in the .strategy environment, or return it.  default FALSE
 #' @export
-add.rule <- function(strategy, name, arguments, label=NULL, type=c(NULL,"risk","order","rebalance","exit","enter"), ..., enabled=TRUE, indexnum=NULL, path.dep=TRUE, store=FALSE) {
+add.rule <- function(strategy, name, arguments, parameters=NULL, label=NULL, type=c(NULL,"risk","order","rebalance","exit","enter"), ..., enabled=TRUE, indexnum=NULL, path.dep=TRUE, store=FALSE) {
     if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
     type=type[1]
     if(is.null(type)) stop("You must specify a type")
@@ -54,10 +55,13 @@
     tmp_rule$type<-type
     tmp_rule$enabled<-enabled
     if (!is.list(arguments)) stop("arguments must be passed as a named list")
-    if(is.null(label)) label = paste(name,"rule",sep='.')
+	if(is.null(label)) label = paste(name,"rule",sep='.')
     tmp_rule$label<-label
     tmp_rule$arguments<-arguments
-    tmp_rule$path.dep<-path.dep
+	if(!is.null(parameters)) tmp_rule$parameters = parameters
+	tmp_rule$path.dep<-path.dep
+	if(length(list(...))) tmp_rule<-c(tmp_rule,list(...))
+	
     tmp_rule$call<-match.call()
     class(tmp_rule)<-'trade_rule'
     if(!hasArg(indexnum) | (hasArg(indexnum) & is.null(indexnum))) indexnum = length(strategy$rules[[type]])+1
@@ -83,11 +87,12 @@
 #' @param Dates default NULL, list of time stamps to iterate over, ignored if \code{path.dep=FALSE}
 #' @param indicators if indicator output is not contained in the mktdata object, it may be passed separately as an xts object or a list.
 #' @param signals if signal output is not contained in the mktdata object, it may be passed separately as an xts object or a list.
+#' @param parameters named list of parameters to be applied during evaluation of the strategy,default NULL, only needed if you need special names to avoid argument collision
 #' @param ... any other passthru parameters
 #' @param path.dep TRUE/FALSE whether rule is path dependent, default TRUE, see Details 
 #' @seealso \code{\link{add.rule}} \code{\link{applyStrategy}} 
 #' @export
-applyRules <- function(portfolio, symbol, strategy, mktdata, Dates=NULL, indicators=NULL, signals=NULL,  ..., path.dep=TRUE) {
+applyRules <- function(portfolio, symbol, strategy, mktdata, Dates=NULL, indicators=NULL, signals=NULL, parameters=NULL,   ..., path.dep=TRUE) {
     # TODO check for symbol name in mktdata using Josh's code:
     # symbol <- strsplit(colnames(mktdata)[1],"\\.")[[1]][1]
     
@@ -139,6 +144,14 @@
             # if (any(pm == 0L)) message(paste("some arguments stored for",rule$name,"do not match"))
             names(rule$arguments[pm > 0L]) <- onames[pm]
             .formals[pm] <- rule$arguments[pm > 0L]
+			
+			# now add arguments from parameters
+			if(length(parameters)){
+				pm <- pmatch(names(parameters), onames, nomatch = 0L)
+				names(parameters[pm > 0L]) <- onames[pm]
+				.formals[pm] <- parameters[pm > 0L]
+			}
+			
             #now add dots
             if (length(nargs)) {
                 pm <- pmatch(names(nargs), onames, nomatch = 0L)

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/R/signals.R	2010-07-26 19:08:35 UTC (rev 360)
@@ -2,14 +2,15 @@
 #' add a signal to a strategy
 #' @param strategy an object of type 'strategy' to add the signal to
 #' @param name name of the signal, must correspond to an R function
-#' @param arguments default arguments to be passed to an signal function when executed
+#' @param arguments named list of default arguments to be passed to an signal function when executed
+#' @param parameters vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision
 #' @param label arbitrary text label for signal output, NULL default will be converted to '<name>.sig'
 #' @param ... any other passthru parameters
 #' @param enabled TRUE/FALSE whether the signal is enabled for use in applying the strategy, default TRUE
 #' @param indexnum if you are updating a specific signal, the index number in the $signals list to update
 #' @param store TRUE/FALSE whether to store the strategy in the .strategy environment, or return it.  default FALSE
 #' @export
-add.signal <- function(strategy, name, arguments, label=NULL, ..., enabled=TRUE, indexnum=NULL, store=FALSE) {
+add.signal <- function(strategy, name, arguments, parameters=NULL, label=NULL, ..., enabled=TRUE, indexnum=NULL, store=FALSE) {
     if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
     tmp_signal<-list()
     tmp_signal$name<-name
@@ -17,10 +18,14 @@
     tmp_signal$label<-label
     tmp_signal$enabled<-enabled
     if (!is.list(arguments)) stop("arguments must be passed as a named list")
-    arguments$label=label
+	arguments$label=label
     tmp_signal$arguments<-arguments
+	if(!is.null(parameters)) tmp_signal$parameters = parameters
+	if(length(list(...))) tmp_signal<-c(tmp_signal,list(...))
+	
     if(!hasArg(indexnum) | (hasArg(indexnum) & is.null(indexnum))) indexnum = length(strategy$signals)+1
     tmp_signal$call<-match.call()
+	class(tmp_signal)<-'strat_signal'
     strategy$signals[[indexnum]]<-tmp_signal
     
     if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
@@ -31,9 +36,10 @@
 #' @param strategy an object of type 'strategy' to add the signal to
 #' @param mktdata an xts object containing market data.  depending on signals, may need to be in OHLCV or BBO formats
 #' @param indicators if indicator output is not contained in the mktdata object, it may be passed separately as an xts object or a list.
+#' @param parameters named list of parameters to be applied during evaluation of the strategy
 #' @param ... any other passthru parameters
 #' @export
-applySignals <- function(strategy, mktdata, indicators=NULL, ...) {
+applySignals <- function(strategy, mktdata, indicators=NULL, parameters=NULL, ...) {
     #TODO add Date subsetting
     
     # TODO check for symbol name in mktdata using Josh's code:
@@ -78,7 +84,15 @@
         if (any(pm == 0L))
             warning(paste("some arguments stored for",signal$name,"do not match"))
         names(signal$arguments[pm > 0L]) <- onames[pm]
-        .formals[pm] <- signal$arguments[pm > 0L]
+        .formals[pm] <- signal$arguments[pm > 0L]		
+		
+		# now add arguments from parameters
+		if(length(parameters)){
+			pm <- pmatch(names(parameters), onames, nomatch = 0L)
+			names(parameters[pm > 0L]) <- onames[pm]
+			.formals[pm] <- parameters[pm > 0L]
+		}
+		
         #now add dots
         if (length(nargs)) {
             pm <- pmatch(names(nargs), onames, nomatch = 0L)

Modified: pkg/quantstrat/R/strategy.R
===================================================================
--- pkg/quantstrat/R/strategy.R	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/R/strategy.R	2010-07-26 19:08:35 UTC (rev 360)
@@ -68,9 +68,10 @@
 #' @param strategy an object of type 'strategy' to add the indicator to
 #' @param portfolios a list of portfolios to apply the strategy to
 #' @param mktdata an xts object containing market data.  depending on indicators, may need to be in OHLCV or BBO formats, default NULL
+#' @param parameters named list of parameters to be applied during evaluation of the strategy, default NULL
 #' @param ... any other passthru parameters
 #' @export
-applyStrategy <- function(strategy , portfolios, mktdata=NULL , ... ) {
+applyStrategy <- function(strategy , portfolios, mktdata=NULL , parameters=NULL, ... ) {
     #TODO add Date subsetting
     #TODO add saving of modified market data
     
@@ -81,8 +82,13 @@
         if(inherits(strategy,"try-error"))
             stop ("You must supply an object of type 'strategy'.")
     } 
+	
+	
     for (portfolio in portfolios) {
-        ret[[portfolio]]<-list() # this is slot [[i]] which we will use later
+		
+		# TODO FIXME evaluate parameter table here, add outer loop
+		
+		ret[[portfolio]]<-list() # this is slot [[i]] which we will use later
         pobj<-getPortfolio(portfolio)
         symbols<-names(pobj)
         sret<-list()
@@ -93,14 +99,14 @@
             mktdata <- get(symbol)
             #print(head(mktdata))
             #loop over indicators
-            sret$indicators <- applyIndicators(strategy=strategy , mktdata=mktdata , ... )
+            sret$indicators <- applyIndicators(strategy=strategy , mktdata=mktdata , parameters=parameters, ... )
             #this should be taken care of by the mktdata<<-mktdata line in the apply* fn
             if(inherits(sret$indicators,"xts") & nrow(mktdata)==nrow(sret$indicators)){
                 mktdata<-sret$indicators
             }
                 
             #loop over signal generators
-            sret$signals <- applySignals(strategy=strategy, mktdata=mktdata, ret$indicators, ... )
+            sret$signals <- applySignals(strategy=strategy, mktdata=mktdata, ret$indicators, parameters=parameters, ... )
             #this should be taken care of by the mktdata<<-mktdata line in the apply* fn
             if(inherits(sret$signals,"xts") & nrow(mktdata)==nrow(sret$signals)){
                 mktdata<-sret$signals    
@@ -109,8 +115,8 @@
             #loop over rules  
             # non-path-dep first
             sret$rules<-list()
-            sret$rules$nonpath<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals,  ..., path.dep=FALSE)
-            sret$rules$pathdep<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals,  ..., path.dep=TRUE)
+            sret$rules$nonpath<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=FALSE)
+            sret$rules$pathdep<-applyRules(portfolio=portfolio, symbol=symbol, strategy=strategy, mktdata=mktdata, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=TRUE)
         }
         ret[[portfolio]][[symbol]]<-sret
     }

Modified: pkg/quantstrat/demo/00Index
===================================================================
--- pkg/quantstrat/demo/00Index	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/demo/00Index	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,2 +1,5 @@
 BBands     Build a simple Bollinger Bands strategy using one indicator, three signals, and three trade rules
 faber      demonstrate a simple long term trend model using a 10-month SMA on a small portfolio of ETFs based on Mebane Faber paper
+MACD       example of Moving Average Convergence/Divergence used as a trend indicator
+maCross    classic 'Golden Cross' 50/200 period moving average cross strategy, long only, with long/short extra rules commented out
+RSI        Relative Strength Index (RSI) strategy demonstrating long-only threshold actions

Modified: pkg/quantstrat/demo/BBands.R
===================================================================
--- pkg/quantstrat/demo/BBands.R	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/demo/BBands.R	2010-07-26 19:08:35 UTC (rev 360)
@@ -5,8 +5,10 @@
 
 # some things to set up here
 stock.str='IBM' # what are we trying it on
+
+# we'll pass these 
 SD = 2 # how many standard deviations, traditionally 2
-N = 20 # how many periods for the moving average
+N = 20 # how many periods for the moving average, traditionally 20
 
 
 currency('USD')
@@ -24,35 +26,32 @@
 
 s <- strategy("bbands")
 
-#s <- add.indicator(strategy = s, name = "SMA", arguments = list(x = quote(Cl(mktdata)), n=10), label="SMA10")
-s <- add.indicator(strategy = s, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), sd=SD, n=N, maType=quote(SMA)))
+#one indicator
+s <- add.indicator(strategy = s, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), maType='SMA'))
 
 
 #if you wanted to manually apply a signal function for demonstration
 #cbind(IBM.mod,sigComparison(label="Close.gt.Open",data=IBM.inds,columns=c("Close","Open"),">"))
 #cbind(IBM.mod,sigComparison(label="Adjusted.gt.SMA",data=IBM.inds,columns=c("Adjusted","SMA10"),">"))
 
-#do it properly and add it to the strategy:
-#s<- add.signal(s,name="sigComparison",arguments = list(data=quote(mktdata),columns=c("Close","Open"),relationship="gt"),label="Cl.gt.Op")
+#add signals:
 s<- add.signal(s,name="sigCrossover",arguments = list(data=quote(mktdata),columns=c("Close","up"),relationship="gt"),label="Cl.gt.UpperBand")
 s<- add.signal(s,name="sigCrossover",arguments = list(data=quote(mktdata),columns=c("Close","dn"),relationship="lt"),label="Cl.lt.LowerBand")
-#s<- add.signal(s,name="sigCrossover",arguments = list(data=quote(mktdata),columns=c("Low","up"),  relationship="gt"),label="Lo.gt.UpperBand")
-#s<- add.signal(s,name="sigCrossover",arguments = list(data=quote(mktdata),columns=c("High","dn"), relationship="lt"),label="Hi.lt.LowerBand")
 s<- add.signal(s,name="sigCrossover",arguments = list(data=quote(mktdata),columns=c("High","Low","mavg"),relationship="op"),label="Cross.Mid")
-#IBM.sigs<-applySignals(s,mktdata=IBM.inds)
 
 # lets add some rules
 s 
 s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Cl.gt.UpperBand",sigval=TRUE, orderqty=-100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
 s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Cl.lt.LowerBand",sigval=TRUE, orderqty= 100, ordertype='market', orderside=NULL, threshold=NULL),type='enter')
+s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Cross.Mid",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
 #s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Lo.gt.UpperBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
 #s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Hi.lt.LowerBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
-s <- add.rule(s,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Cross.Mid",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
 #TODO add thresholds and stop-entry and stop-exit handling to test
 
 getSymbols(stock.str,from=initDate)
 start_t<-Sys.time()
-out<-try(applyStrategy(strategy='s' , portfolios='bbands'))
+out<-try(applyStrategy(strategy='s' , portfolios='bbands',parameters=list(sd=SD,n=N)))
+
 # look at the order book
 #getOrderBook('bbands')
 end_t<-Sys.time()

Modified: pkg/quantstrat/man/add.indicator.Rd
===================================================================
--- pkg/quantstrat/man/add.indicator.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/add.indicator.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,8 +1,8 @@
 \name{add.indicator}
 \alias{add.indicator}
 \title{add an indicator to a strategy...}
-\usage{add.indicator(strategy, name, arguments, label, ..., enabled=TRUE,
-    indexnum, store=FALSE)}
+\usage{add.indicator(strategy, name, arguments, parameters, label, ...,
+    enabled=TRUE, indexnum, store=FALSE)}
 \description{add an indicator to a strategy}
 \details{Indicators are typically standard technical or statistical analysis outputs, 
 such as moving averages, bands, or pricing models.
@@ -14,6 +14,7 @@
 \arguments{\item{strategy}{an object of type 'strategy' to add the indicator to}
 \item{name}{name of the indicator, must correspond to an R function}
 \item{arguments}{default arguments to be passed to an indicator function when executed}
+\item{parameters}{vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision}
 \item{label}{arbitrary text label for indicator output, NULL default will be converted to '<name>.ind'}
 \item{...}{any other passthru parameters}
 \item{enabled}{TRUE/FALSE whether the indicator is enabled for use in applying the strategy, default TRUE}

Modified: pkg/quantstrat/man/add.rule.Rd
===================================================================
--- pkg/quantstrat/man/add.rule.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/add.rule.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,8 +1,8 @@
 \name{add.rule}
 \alias{add.rule}
 \title{add a rule to a strategy...}
-\usage{add.rule(strategy, name, arguments, label, type=c(NULL, "risk",
-    "order", "rebalance", "exit", "enter"), ..., enabled=TRUE,
+\usage{add.rule(strategy, name, arguments, parameters, label, type=c(NULL,
+    "risk", "order", "rebalance", "exit", "enter"), ..., enabled=TRUE,
     indexnum, path.dep=TRUE, store=FALSE)}
 \description{add a rule to a strategy}
 \details{Rules will be processed in a very particular manner, so it bears going over.
@@ -40,7 +40,8 @@
 authors a place to start.}
 \arguments{\item{strategy}{an object of type 'strategy' to add the rule to}
 \item{name}{name of the rule, must correspond to an R function}
-\item{arguments}{default arguments to be passed to an rule function when executed}
+\item{arguments}{named list of default arguments to be passed to an rule function when executed}
+\item{parameters}{vector of strings naming parameters to be saved for apply-time definition}
 \item{label}{arbitrary text label for rule output, NULL default will be converted to '<name>.rule'}
 \item{type}{one of "risk","order","rebalance","exit","enter", see Details}
 \item{...}{any other passthru parameters}

Modified: pkg/quantstrat/man/add.signal.Rd
===================================================================
--- pkg/quantstrat/man/add.signal.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/add.signal.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,12 +1,13 @@
 \name{add.signal}
 \alias{add.signal}
 \title{add a signal to a strategy...}
-\usage{add.signal(strategy, name, arguments, label, ..., enabled=TRUE,
-    indexnum, store=FALSE)}
+\usage{add.signal(strategy, name, arguments, parameters, label, ...,
+    enabled=TRUE, indexnum, store=FALSE)}
 \description{add a signal to a strategy}
 \arguments{\item{strategy}{an object of type 'strategy' to add the signal to}
 \item{name}{name of the signal, must correspond to an R function}
-\item{arguments}{default arguments to be passed to an signal function when executed}
+\item{arguments}{named list of default arguments to be passed to an signal function when executed}
+\item{parameters}{vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision}
 \item{label}{arbitrary text label for signal output, NULL default will be converted to '<name>.sig'}
 \item{...}{any other passthru parameters}
 \item{enabled}{TRUE/FALSE whether the signal is enabled for use in applying the strategy, default TRUE}

Modified: pkg/quantstrat/man/applyIndicators.Rd
===================================================================
--- pkg/quantstrat/man/applyIndicators.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/applyIndicators.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,8 +1,9 @@
 \name{applyIndicators}
 \alias{applyIndicators}
 \title{apply the indicators in the strategy to arbitrary market data...}
-\usage{applyIndicators(strategy, mktdata, ...)}
+\usage{applyIndicators(strategy, mktdata, parameters, ...)}
 \description{apply the indicators in the strategy to arbitrary market data}
 \arguments{\item{strategy}{an object of type 'strategy' to add the indicator to}
 \item{mktdata}{an xts object containing market data.  depending on indicators, may need to be in OHLCV or BBO formats}
+\item{parameters}{named list of parameters to be applied during evaluation of the strategy}
 \item{...}{any other passthru parameters}}

Modified: pkg/quantstrat/man/applyRules.Rd
===================================================================
--- pkg/quantstrat/man/applyRules.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/applyRules.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -2,7 +2,7 @@
 \alias{applyRules}
 \title{apply the rules in the strategy to arbitrary market data...}
 \usage{applyRules(portfolio, symbol, strategy, mktdata, Dates, indicators,
-    signals, ..., path.dep=TRUE)}
+    signals, parameters, ..., path.dep=TRUE)}
 \description{apply the rules in the strategy to arbitrary market data}
 \details{In typical usage, this function will be called via \code{\link{applyStrategy}}.  
 In this mode, this function will be called twice, once with \code{path.dep=FALSE} 
@@ -18,5 +18,6 @@
 \item{Dates}{default NULL, list of time stamps to iterate over, ignored if \code{path.dep=FALSE}}
 \item{indicators}{if indicator output is not contained in the mktdata object, it may be passed separately as an xts object or a list.}
 \item{signals}{if signal output is not contained in the mktdata object, it may be passed separately as an xts object or a list.}
+\item{parameters}{named list of parameters to be applied during evaluation of the strategy,default NULL, only needed if you need special names to avoid argument collision}
 \item{...}{any other passthru parameters}
 \item{path.dep}{TRUE/FALSE whether rule is path dependent, default TRUE, see Details}}

Modified: pkg/quantstrat/man/applySignals.Rd
===================================================================
--- pkg/quantstrat/man/applySignals.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/applySignals.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,9 +1,10 @@
 \name{applySignals}
 \alias{applySignals}
 \title{apply the signals in the strategy to arbitrary market data...}
-\usage{applySignals(strategy, mktdata, indicators, ...)}
+\usage{applySignals(strategy, mktdata, indicators, parameters, ...)}
 \description{apply the signals in the strategy to arbitrary market data}
 \arguments{\item{strategy}{an object of type 'strategy' to add the signal to}
 \item{mktdata}{an xts object containing market data.  depending on signals, may need to be in OHLCV or BBO formats}
 \item{indicators}{if indicator output is not contained in the mktdata object, it may be passed separately as an xts object or a list.}
+\item{parameters}{named list of parameters to be applied during evaluation of the strategy}
 \item{...}{any other passthru parameters}}

Modified: pkg/quantstrat/man/applyStrategy.Rd
===================================================================
--- pkg/quantstrat/man/applyStrategy.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/applyStrategy.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -1,11 +1,12 @@
 \name{applyStrategy}
 \alias{applyStrategy}
 \title{apply the strategy to arbitrary market data...}
-\usage{applyStrategy(strategy, portfolios, mktdata, ...)}
+\usage{applyStrategy(strategy, portfolios, mktdata, parameters, ...)}
 \description{apply the strategy to arbitrary market data}
 \details{if \code{mktdata} is NULL, the default, the mktdata variable will be populated 
 for each symbol via a call to get (getSymbols??, not yet)}
 \arguments{\item{strategy}{an object of type 'strategy' to add the indicator to}
 \item{portfolios}{a list of portfolios to apply the strategy to}
 \item{mktdata}{an xts object containing market data.  depending on indicators, may need to be in OHLCV or BBO formats, default NULL}
+\item{parameters}{named list of parameters to be applied during evaluation of the strategy, default NULL}
 \item{...}{any other passthru parameters}}

Modified: pkg/quantstrat/man/stratBBands.Rd
===================================================================
--- pkg/quantstrat/man/stratBBands.Rd	2010-07-22 12:22:24 UTC (rev 359)
+++ pkg/quantstrat/man/stratBBands.Rd	2010-07-26 19:08:35 UTC (rev 360)
@@ -12,9 +12,9 @@
 
     If constructed from scratch, the indicators would consist of:
     \describe{
-	\item{moving average}{a moving average parameterized by MA type (simple, expontnetial, Kalman, etc.) and MA periods to smooth over}
+	\item{moving average}{a moving average parameterized by MA type (simple, exponential, Kalman, etc.) and MA periods to smooth over}
 	\item{upper band}{ the upper band constructed classically by standard deviations from the moving average, or alternately by some other upper band generating function, and parameterized chiefly by the amplitude of the band, typically number of standard deviations from the midpoint or moving average indicator}
-	\item{lower band}{ the lower band traditionally constructed to be symetrical and opposite the upper band, but potentially constructed via a different function or parameterized differently than the upper band function}
+	\item{lower band}{ the lower band traditionally constructed to be symmetrical and opposite the upper band, but potentially constructed via a different function or parameterized differently than the upper band function}
     }
 }
 \section{Signals}{



More information about the Blotter-commits mailing list