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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 25 22:00:11 CEST 2011


Author: braverock
Date: 2011-08-25 22:00:10 +0200 (Thu, 25 Aug 2011)
New Revision: 739

Removed:
   pkg/quantstrat/man/add.paramLookupTable.Rd
   pkg/quantstrat/man/add.parameter.Rd
   pkg/quantstrat/man/getParams.Rd
   pkg/quantstrat/man/paramLookup.Rd
Modified:
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/NAMESPACE
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/R/parameters.R
   pkg/quantstrat/R/traderules.R
   pkg/quantstrat/man/applyParameter.Rd
   pkg/quantstrat/man/getOrders.Rd
   pkg/quantstrat/man/getParameterTable.Rd
   pkg/quantstrat/man/paramConstraint.Rd
   pkg/quantstrat/man/ruleSignal.Rd
   pkg/quantstrat/man/setParameterConstraint.Rd
   pkg/quantstrat/man/setParameterDistribution.Rd
   pkg/quantstrat/man/updateOrders.Rd
Log:
- update roxygen documentation

Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/DESCRIPTION	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,7 +1,7 @@
 Package: quantstrat
 Type: Package
 Title: Quantitative Strategy Model Framework
-Version: 0.5.1
+Version: 0.5.2
 Date: $Date$
 Author: Peter Carl, Dirk Eddelbuettel, Brian G. Peterson,
     Jeffrey A. Ryan, Joshua Ulrich, Garrett See, Yu Chen

Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/NAMESPACE	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,7 +1,5 @@
 export(add.indicator)
 export(addOrder)
-export(add.parameter)
-export(add.paramLookupTable)
 export(addPosLimit)
 export(add.rule)
 export(add.signal)

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/R/orders.R	2011-08-25 20:00:10 UTC (rev 739)
@@ -68,6 +68,7 @@
 #' @param timespan xts-style character timespan to be the period to find orders of the given status and ordertype
 #' @param ordertype one of NULL, "market","limit","stoplimit", "stoptrailing", or "iceberg" default NULL
 #' @param side one of NULL, "long" or "short", default NULL 
+#' @param qtysign one of NULL, -1,0,1 ; could be useful when all qty's are reported as positive numbers and need to be identified other ways, default NULL
 #' @param which.i if TRUE, return the row index numbers rather than the order rows matching the criteria, default FALSE
 #' @export
 getOrders <- function(portfolio,symbol,status="open",timespan=NULL,ordertype=NULL, side=NULL, qtysign=NULL, which.i=FALSE)
@@ -324,6 +325,7 @@
 #' @param timespan xts-style character timespan to be the period to find orders of the given status and ordertype 
 #' @param ordertype one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL
 #' @param side one of NULL, "long" or "short", default NULL 
+#' @param qtysign one of NULL, -1,0,1 ; could be useful when all qty's are reported as positive numbers and need to be identified other ways, default NULL
 #' @param oldstatus one of NULL, "open", "closed", "canceled", or "replaced", default "open"
 #' @param newstatus one of "open", "closed", "canceled", or "replaced"
 #' @param statustimestamp timestamp of a status update, will be blank when order is initiated 
@@ -338,8 +340,7 @@
     if(!is.null(side) & !length(grep(side,c('long','short')))==1) 
         stop(paste("side:",side," must be one of 'long' or 'short'"))
     if(!is.null(qtysign) && (qtysign != -1 && qtysign != 1 && qtysign != 0))
-        stop(paste("qtysign:",qtysign," must be one of -1, 0, or 1"))
-    #if(is.null(side)) side<-NA
+        stop(paste("qtysign:",qtysign," must be one of NULL, -1, 0, or 1"))
     if(!is.null(ordertype) & is.na(charmatch(ordertype,c("market","limit","stoplimit","stoptrailing","iceberg")))) 
         stop(paste("ordertype:",ordertype,' must be one of "market","limit","stoplimit","stoptrailing", or "iceberg"'))
     

Modified: pkg/quantstrat/R/parameters.R
===================================================================
--- pkg/quantstrat/R/parameters.R	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/R/parameters.R	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,107 +1,83 @@
-#' add parameters to strategy objects: ALPHA CODE USE WITH CARE 
-#' @param strategy 
-#' @param type 
-#' @param add.to.name 
-#' @param method 
-#' @param arguments 
-#' @param label 
-#' @param ... 
-#' @param store 
-#' @export
-add.parameter <- 
-		function (strategy, 
-				type = c('indicator','signal'), 
-				add.to.name,
-				method = c('lookup','lookup.range','calc'), 
-				arguments = NULL, 
-				label = NULL,
-				...,
-				store=FALSE) 
-{
-	if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
-	# perhaps I should add parameters and parameter.args as arguments to the constructors...
-	
-	tmp.param<-list()
-	
-	type=type[1] #this should probably come out eventually
-	
-	method = method[1] #only use the first if the user didn't specify, or over-specified
-	
-	if(is.null(label)) {
-		label<-method
-	}
-	tmp.param$label <- label
-	tmp.param$method <- method
-	tmp.param$call <- match.call()
-	tmp.param$arguments <- arguments
-	class(tmp.param)<-'quantstrat.parameter'
-	
-	switch(type,
-			indicator = {type='indicators'},
-			signal = {type='signals'},
-			rule = {type='rules'}) #NOTE rules not supported yet, since they need a rule type too
-	
-	# need to think about how to create a 'parameters' list, and whether 
-	# it should be at the strategy level or lower down, on the individual 
-	# signal/indicator/rule
-	
-	if(!is.list(strategy[[type]][[add.to.name]]$parameters)){
-		strategy[[type]][[add.to.name]]$parameters <- list()
-	}
-	strategy[[type]][[add.to.name]][['parameters']][[method]] <- tmp.param
-	
-	if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
-	else return(strategy)
-}
+## add parameters to strategy objects: ALPHA CODE USE WITH CARE 
+#add.parameter <- 
+#		function (strategy, 
+#				type = c('indicator','signal'), 
+#				add.to.name,
+#				method = c('lookup','lookup.range','calc'), 
+#				arguments = NULL, 
+#				label = NULL,
+#				...,
+#				store=FALSE) 
+#{
+#	if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
+#	# perhaps I should add parameters and parameter.args as arguments to the constructors...
+#	
+#	tmp.param<-list()
+#	
+#	type=type[1] #this should probably come out eventually
+#	
+#	method = method[1] #only use the first if the user didn't specify, or over-specified
+#	
+#	if(is.null(label)) {
+#		label<-method
+#	}
+#	tmp.param$label <- label
+#	tmp.param$method <- method
+#	tmp.param$call <- match.call()
+#	tmp.param$arguments <- arguments
+#	class(tmp.param)<-'quantstrat.parameter'
+#	
+#	switch(type,
+#			indicator = {type='indicators'},
+#			signal = {type='signals'},
+#			rule = {type='rules'}) #NOTE rules not supported yet, since they need a rule type too
+#	
+#	# need to think about how to create a 'parameters' list, and whether 
+#	# it should be at the strategy level or lower down, on the individual 
+#	# signal/indicator/rule
+#	
+#	if(!is.list(strategy[[type]][[add.to.name]]$parameters)){
+#		strategy[[type]][[add.to.name]]$parameters <- list()
+#	}
+#	strategy[[type]][[add.to.name]][['parameters']][[method]] <- tmp.param
+#	
+#	if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
+#	else return(strategy)
+#}
+#
+#
+## add parameters to strategy objects: ALPHA CODE USE WITH CARE 
+#paramLookup <- function(strategy, symbol , type, name, parameter, ...) {
+#	# should take in a strategy and parameter object, and return an argument list for 'symbol'
+#	#as.pairlist(paramTable[,symbol]
+#	paramTable<-get(paste(strategy,type,name,'table',pos=.strategy))
+#	as.pairlist(paramTable[,symbol])
+#}
+#
+## add parameters to strategy objects: ALPHA CODE USE WITH CARE 
+#add.paramLookupTable <- function(strategy, type, name, paramTable){
+#	assign(paste(strategy,type,name,'table',pos=.strategy),paramTable)
+#}
+#
+## get parameterized arguments list out of the strategy environment
+#getParams <- function (strategy, symbol, type, name)
+#{
+#	
+#	params <- strategy[[type]][[name]]$parameters
+#	param.ret<-list()
+#	for (param in params) {
+#		switch(param$method,
+#				lookup = {param.ret<-c(param.ret,paramLookup(strategy,symbol,parameter=param))},
+#				lookup.range = {},
+#				calc = {},
+#				{warning("parameter method",param$method,'not recognized for',type,name); next()}
+#		)
+#	}
+#	# return an arguments list back to the 'apply*' fn
+#	return(param.ret)
+#}
 
 
-#' add parameters to strategy objects: ALPHA CODE USE WITH CARE 
-#' @param strategy 
-#' @param symbol 
-#' @param type 
-#' @param name 
-#' @param parameter 
-#' @param ... 
-paramLookup <- function(strategy, symbol , type, name, parameter, ...) {
-	# should take in a strategy and parameter object, and return an argument list for 'symbol'
-	#as.pairlist(paramTable[,symbol]
-	paramTable<-get(paste(strategy,type,name,'table',pos=.strategy))
-	as.pairlist(paramTable[,symbol])
-}
-
-#' add parameters to strategy objects: ALPHA CODE USE WITH CARE 
-#' @param strategy 
-#' @param type 
-#' @param name 
-#' @param paramTable 
-#' @export
-add.paramLookupTable <- function(strategy, type, name, paramTable){
-	assign(paste(strategy,type,name,'table',pos=.strategy),paramTable)
-}
-
-#' get parameterized arguments list out of the strategy environment
-#' @param strategy 
-#' @param symbol 
-#' @param type 
-#' @param name 
-getParams <- function (strategy, symbol, type, name)
-{
-	
-	params <- strategy[[type]][[name]]$parameters
-	param.ret<-list()
-	for (param in params) {
-		switch(param$method,
-				lookup = {param.ret<-c(param.ret,paramLookup(strategy,symbol,parameter=param))},
-				lookup.range = {},
-				calc = {},
-				{warning("parameter method",param$method,'not recognized for',type,name); next()}
-		)
-	}
-	# return an arguments list back to the 'apply*' fn
-	return(param.ret)
-}
-
-
 ###############################################################################
 # R (http://r-project.org/) Quantitative Strategy Model Framework
 #
@@ -129,21 +105,19 @@
 #' when they create the parameter distribution. But it's not required to be used to specify the distribution of parameters. 
 #' 
 #' @examples
-#' When strategy object stratMACD has already been created by macd.R demo:
-#' following line will return the parameter information to object paramStructure:
-#' 
+#' # When strategy object stratMACD has already been created by macd.R demo:
+#' # bfollowing line will return the parameter information to object paramStructure:
+#' \dontrun{
 #' x<-getParameterTable(stratMACD)
-#' 
+#' }
 #' @return
-#' In the returned list of object:
-#' 
-#' paramNameList is the list of parameters used in the strategy, easy for print and view as a table.
-#' strategyName is the name of the strategy itself.
-#' structure is the detailed paramter structure in the input strategy, can be used when user wants to look into more details of the parameter structure.
-#' 
+#' A list of objects that contains the parameter structure  information"
+#' \describe{
+#'    \item{paramNameList}{the list of parameters used in the strategy, for printing or viewing as a table.}
+#'    \item{strategyName}{ string name of the strategy}
+#'    \item{structure}{the detailed paramter structure in the input strategy, can be used when user wants to look into more details of the parameter structure.}
+#' }
 #' @param strategy The strategy object.
-#' @returnType A list of objects that contains the parameter structure  information, see detail.
-#' 
 #' @author Yu Chen
 #' @export
 getParameterTable<-function (strategy) #,staticSwitch)
@@ -259,6 +233,7 @@
 #' @param indexnum Tells the sequence within the type, (If the type is 'signal', indexnum =2 tells the function to update the 2nd signal in the strategy)  
 #' @param distribution Distribution of the parameter, can be any function that return a vector of value. See detail. (A numerical example: 1:10 or sample(1:20,6)
 #' @param weight The weight of each value in the distribution, default value will be all equally weighted.
+#' @param label string label to apply to the parameter distribution
 #' @param psindex specify the index within the parameter distribution object, it is used to make change/ repalce a parameter distribution in the object.
 #' @return The returned object is a structure contains the distribution of parameters, is of the same type as the input parameter paramDist (if provided), the function update the input paramDist object and return the updated one. Usually the returned value is pass to the same object as parameter. See details. 
 #' @author Yu Chen
@@ -709,11 +684,10 @@
 #' 
 #' Relationship 'op' means 'opposite' side.  Reasonable attempt will be made to match.
 #' 
-#' @param label text label to apply to the output
+#' @param label text label to apply to the constraint
 #' @param data data to apply comparison to
 #' @param columns named columns to apply comparison to
 #' @param relationship one of c("gt","lt","eq","gte","lte","op") or reasonable alternatives
-
 paramConstraint <- function(label,data=mktdata, columns, relationship=c("gt","lt","eq","gte","lte")) {
 	relationship=relationship[1] #only use the first one
 #	print(columns)
@@ -757,15 +731,15 @@
 #' Function to construct parameter constraint object.
 #'  
 #' @examples
-#' (For complete demo see parameterTestMACD.R)
+#' #(For complete demo see parameterTestMACD.R)
 #' #In a MACD strategy, we want to fast macd calcuated from less time periods (days) than slow macd signal:
-#'   
+#' \dontrun{  
 #' pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')
-#' 
+#' }
 #' #The object pConstraint2 then can be used in applyParameter function to specify the constrains between parameters. 
 #' 
 #' @param paramConstraintObj the ParameterConstraint object to be updated on, if missing, funtion will create a new one.
-#' @param constrainlabel User can give a character label to the constraint.
+#' @param constraintLabel string label to apply to the constraint
 #' @param paramList the two name of the prameters as a list contains two strings.
 #' @param relationship relationship between the 1st parameter and 2nd one. ('gt' means 1st parameter > 2nd parameter)
 #' @author Yu Chen

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/R/traderules.R	2011-08-25 20:00:10 UTC (rev 739)
@@ -2,17 +2,17 @@
 #' default rule to generate a trade order on a signal
 #' 
 #' \code{pricemethod} may be one of 
-#'   \itemize{ 
-#'      \item{'market', 'opside', or 'maker'}{ will use the 'ask' price if you're buying and 
+#'      \describe{ 
+#'          \item{'market', 'opside', or 'maker'}{ will use the 'ask' price if you're buying and 
 #'            the 'bid' price if you're selling, crossing the market at the time of 
 #'            order entry to attempt to set an aggressive price to get the trade. }
-#' 		\item{'passive', 'work' or 'join'}{ which will join the 'bid' price if you are buying
-#'      	  or join the 'ask' price if you are selling, passively working to make liquidity \
+#' 		   \item{'passive', 'work' or 'join'}{ which will join the 'bid' price if you are buying
+#'      	  or join the 'ask' price if you are selling, passively working to make liquidity 
 #'            at the prevailing market price without crossing the market at time of order entry}
-#' 		\item{'maker'}{will create a pair of orders for both bid and offer, modeling 
+#' 		   \item{'maker'}{will create a pair of orders for both bid and offer, modeling 
 #' 		      market making activities by having orders on both sides.  
 #'            This will then create an Order.Set, and use the \code{threshold} to set the prices for these orders.}
-#' } 
+#'      } 
 #' 
 #' If \code{threshold} is not numeric or \code{NULL} it should be the character string describing a function that can calculate a threshold.  
 #' Ideally this will be a column lookup on a non-path-dependent indicator calculated in advance.

Deleted: pkg/quantstrat/man/add.paramLookupTable.Rd
===================================================================
--- pkg/quantstrat/man/add.paramLookupTable.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/add.paramLookupTable.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,20 +0,0 @@
-\name{add.paramLookupTable}
-\alias{add.paramLookupTable}
-\title{add parameters to strategy objects: ALPHA CODE USE WITH CARE}
-\usage{
-  add.paramLookupTable(strategy, type, name, paramTable)
-}
-\arguments{
-  \item{strategy}{}
-
-  \item{type}{}
-
-  \item{name}{}
-
-  \item{paramTable}{}
-}
-\description{
-  add parameters to strategy objects: ALPHA CODE USE WITH
-  CARE
-}
-

Deleted: pkg/quantstrat/man/add.parameter.Rd
===================================================================
--- pkg/quantstrat/man/add.parameter.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/add.parameter.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,31 +0,0 @@
-\name{add.parameter}
-\alias{add.parameter}
-\title{add parameters to strategy objects: ALPHA CODE USE WITH CARE}
-\usage{
-  add.parameter(strategy, type = c("indicator", "signal"),
-  add.to.name, method = c("lookup", "lookup.range",
-  "calc"), arguments = NULL, label = NULL, ..., store =
-  FALSE)
-}
-\arguments{
-  \item{strategy}{}
-
-  \item{type}{}
-
-  \item{add.to.name}{}
-
-  \item{method}{}
-
-  \item{arguments}{}
-
-  \item{label}{}
-
-  \item{...}{}
-
-  \item{store}{}
-}
-\description{
-  add parameters to strategy objects: ALPHA CODE USE WITH
-  CARE
-}
-

Modified: pkg/quantstrat/man/applyParameter.Rd
===================================================================
--- pkg/quantstrat/man/applyParameter.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/applyParameter.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,9 +1,9 @@
 \name{applyParameter}
 \alias{applyParameter}
-\title{Generate parameter sets based on specified distribution and constrains, apply the parameters to the specified strategy and return the results package.}
+\title{Generate parameter sets for a specific strategy, test the strategy on each set of parameters, output result package.}
 \usage{
   applyParameter(strategy, portfolios, parameterPool,
-  parameterConstrains, method, sampleSize)
+  parameterConstraints, method, sampleSize)
 }
 \arguments{
   \item{strategy}{The strategy to test paramters to.}
@@ -15,7 +15,7 @@
   setParameterDistribution function, which includes all the
   parameter legal values and distribution/weights.}
 
-  \item{parameterConstrains}{The object created by
+  \item{parameterConstraints}{The object created by
   setParameterConstraint function that specifies the
   constrains between each parameters,}
 
@@ -27,7 +27,7 @@
   many parameter sets to generate and run test of.}
 }
 \value{
-  In the returned Object:
+  In the returned result pack as a list of object:
 
   \describe{ \item{statsTable}{is the summary table show
   stats from all the runs} \item{eachRun}{contains the
@@ -40,31 +40,36 @@
   the parameters, in a table for print}
   \item{parameterDistribution}{is the parameter
   distribution passed in as argument}
-  \item{parameterConstrains}{is the constraints apply to
+  \item{parameterConstraints}{is the constraints apply to
   the parameters, passed in as argument} }
 }
 \description{
-  Given a parameter distribution object generated by
-  setParameterDistribution function, generate parameter
-  sets and test each set on the specified strategy.
+  Generate parameter sets based on specified distribution
+  (a defined parameter distribution object generated by
+  setParameterDistribution function) and constraints (A
+  defined parameter constraint object generated by
+  setParameterConstraint function), apply the generated
+  parameter sets to the specified strategy and return the
+  results package, put the generated portfolio objects and
+  account objects in .blotter environment.
 }
 \details{
-  The function support parallel execution, user only need
+  Other than the returned result pack, the function puts
+  the generated portfolio and account objects in the
+  .blotter environment. The names of those objects will be
+  extension of the names created by initial
+  strategy/portfolios are created. For example, in macd.R
+  demo, account.macd and portfolio.macd are created in
+  .blotter environment. After calling the applyParameter
+  function and did the parameter test, series of similar
+  objects are created with names account.macd.p.1,
+  account.macd.p.2 ... and portfolio.macd.p.1,
+  portfolio.macd.p.2 ...
+
+  The function supports parallel execution, user only need
   to initial the parallel package and wrap up afterwards.
   The function will automaticly use the number of
-  registered parallel sessions to run testing.
-
-  Other than returned value, the function puts portfolio
-  and account objects in the .blotter environment. The
-  names of those objects will be extension of the names
-  created by initial strategy/portfolios are created. For
-  example, in macd.R demo, account.macd and portfolio.macd
-  are created in .blotter environment. After calling the
-  function and did the parameter test, series of similar
-  objects are created with names
-
-  account.macd.p.1, account.macd.p.2 ... and
-  portfolio.macd.p.1, portfolio.macd.p.2 ...
+  registered parallel sessions to run testing, See example.
 }
 \examples{
 \dontrun{
@@ -76,10 +81,10 @@
 #PUT ALL CODE RELATED TO QUANTSTRAT HERE
 #Example to call the function:  (For complete demo see parameterTestMACD.R)
 x<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,
-method='random',sampleSize=20,parameterConstrains=pConstraint2)
+method='random',sampleSize=20,parameterConstraints=pConstraint2)
 #or
 x<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,
-method='expand',parameterConstrains=pConstraint2)
+method='expand',parameterConstraints=pConstraint2)
 
 stopWorkers(workers)
 rmSessions(all=TRUE)
@@ -88,4 +93,8 @@
 \author{
   Yu Chen
 }
+\seealso{
+  \code{\link{setParameterDistribution}},
+  \code{\link{setParameterConstraint}}
+}
 

Modified: pkg/quantstrat/man/getOrders.Rd
===================================================================
--- pkg/quantstrat/man/getOrders.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/getOrders.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -26,6 +26,10 @@
 
   \item{side}{one of NULL, "long" or "short", default NULL}
 
+  \item{qtysign}{one of NULL, -1,0,1 ; could be useful when
+  all qty's are reported as positive numbers and need to be
+  identified other ways, default NULL}
+
   \item{which.i}{if TRUE, return the row index numbers
   rather than the order rows matching the criteria, default
   FALSE}

Modified: pkg/quantstrat/man/getParameterTable.Rd
===================================================================
--- pkg/quantstrat/man/getParameterTable.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/getParameterTable.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -5,22 +5,32 @@
   getParameterTable(strategy)
 }
 \arguments{
-  \item{strategy}{The name of the strategy}
+  \item{strategy}{The strategy object.}
 }
+\value{
+  A list of objects that contains the parameter structure
+  information" \describe{ \item{paramNameList}{the list of
+  parameters used in the strategy, for printing or viewing
+  as a table.} \item{strategyName}{ string name of the
+  strategy} \item{structure}{the detailed paramter
+  structure in the input strategy, can be used when user
+  wants to look into more details of the parameter
+  structure.} }
+}
 \description{
-  This function is not required for user to specify the
-  distribution of parameters, Users can use this function
-  to extract the parameters used in a strategy, and as a
-  reminder/ cheatsheet when they create the parameter
-  distribution.
+  Users can use this function to extract the parameters
+  used in a strategy, and as a reminder/ cheatsheet when
+  they create the parameter distribution. But it's not
+  required to be used to specify the distribution of
+  parameters.
 }
-\details{
-  In the returned object: $paramNameList is the list of
-  parameters used in the strategy, easy for print and view
-  as a table. $strategyName is the name of the strategy
-  itself. $structure is the detailed paramter structure,
-  can be ignored.
+\examples{
+# When strategy object stratMACD has already been created by macd.R demo:
+# bfollowing line will return the parameter information to object paramStructure:
+\dontrun{
+x<-getParameterTable(stratMACD)
 }
+}
 \author{
   Yu Chen
 }

Deleted: pkg/quantstrat/man/getParams.Rd
===================================================================
--- pkg/quantstrat/man/getParams.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/getParams.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,20 +0,0 @@
-\name{getParams}
-\alias{getParams}
-\title{get parameterized arguments list out of the strategy environment}
-\usage{
-  getParams(strategy, symbol, type, name)
-}
-\arguments{
-  \item{strategy}{}
-
-  \item{symbol}{}
-
-  \item{type}{}
-
-  \item{name}{}
-}
-\description{
-  get parameterized arguments list out of the strategy
-  environment
-}
-

Modified: pkg/quantstrat/man/paramConstraint.Rd
===================================================================
--- pkg/quantstrat/man/paramConstraint.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/paramConstraint.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,12 +1,12 @@
 \name{paramConstraint}
 \alias{paramConstraint}
-\title{Basicly is the same as sigComparison function in signal.R wrote by Brian, with miner change.}
+\title{Internal function used in applyParameter function for process constraints on relationship between two parameter values. Basicly is the same as sigComparison function in signal.R written by Brian, with miner change.}
 \usage{
   paramConstraint(label, data = mktdata, columns,
   relationship = c("gt", "lt", "eq", "gte", "lte"))
 }
 \arguments{
-  \item{label}{text label to apply to the output}
+  \item{label}{text label to apply to the constraint}
 
   \item{data}{data to apply comparison to}
 

Deleted: pkg/quantstrat/man/paramLookup.Rd
===================================================================
--- pkg/quantstrat/man/paramLookup.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/paramLookup.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,24 +0,0 @@
-\name{paramLookup}
-\alias{paramLookup}
-\title{add parameters to strategy objects: ALPHA CODE USE WITH CARE}
-\usage{
-  paramLookup(strategy, symbol, type, name, parameter, ...)
-}
-\arguments{
-  \item{strategy}{}
-
-  \item{symbol}{}
-
-  \item{type}{}
-
-  \item{name}{}
-
-  \item{parameter}{}
-
-  \item{...}{}
-}
-\description{
-  add parameters to strategy objects: ALPHA CODE USE WITH
-  CARE
-}
-

Modified: pkg/quantstrat/man/ruleSignal.Rd
===================================================================
--- pkg/quantstrat/man/ruleSignal.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/ruleSignal.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -74,14 +74,14 @@
   hold, default FALSE}
 }
 \description{
-  \code{pricemethod} may be one of \itemize{
+  \code{pricemethod} may be one of \describe{
   \item{'market', 'opside', or 'maker'}{ will use the 'ask'
   price if you're buying and the 'bid' price if you're
   selling, crossing the market at the time of order entry
   to attempt to set an aggressive price to get the trade. }
   \item{'passive', 'work' or 'join'}{ which will join the
   'bid' price if you are buying or join the 'ask' price if
-  you are selling, passively working to make liquidity \ at
+  you are selling, passively working to make liquidity at
   the prevailing market price without crossing the market
   at time of order entry} \item{'maker'}{will create a pair
   of orders for both bid and offer, modeling market making

Modified: pkg/quantstrat/man/setParameterConstraint.Rd
===================================================================
--- pkg/quantstrat/man/setParameterConstraint.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/setParameterConstraint.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -6,8 +6,13 @@
   constraintLabel, paramList, relationship)
 }
 \arguments{
-  \item{constrainlabel}{give a label to the constraint.}
+  \item{paramConstraintObj}{the ParameterConstraint object
+  to be updated on, if missing, funtion will create a new
+  one.}
 
+  \item{constraintLabel}{string label to apply to the
+  constraint}
+
   \item{paramList}{the two name of the prameters as a list
   contains two strings.}
 
@@ -18,6 +23,14 @@
 \description{
   Function to construct parameter constraint object.
 }
+\examples{
+#(For complete demo see parameterTestMACD.R)
+#In a MACD strategy, we want to fast macd calcuated from less time periods (days) than slow macd signal:
+\dontrun{
+pConstraint2<-setParameterConstraint(constraintLabel='macdPC',paramList=c('nFast','nSlow'),relationship='lt')
+}
+#The object pConstraint2 then can be used in applyParameter function to specify the constrains between parameters.
+}
 \author{
   Yu Chen
 }

Modified: pkg/quantstrat/man/setParameterDistribution.Rd
===================================================================
--- pkg/quantstrat/man/setParameterDistribution.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/setParameterDistribution.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -1,37 +1,76 @@
 \name{setParameterDistribution}
 \alias{setParameterDistribution}
-\title{Function used to set distribution of a parameter in a strategy.}
+\title{Function used to set distribution of a parameter to be generated from, for testing a strategy.}
 \usage{
   setParameterDistribution(paramDist = NULL, type = NULL,
   indexnum = 0, distribution = NULL, weight, label, psindex
   = NULL)
 }
 \arguments{
-  \item{paramDist}{the object name that store the parameter
-  list}
+  \item{paramDist}{The object that store the parameter
+  list, if this parameter is missing, or object does not
+  exist, the function will create a new object.}
 
-  \item{type}{indicator/signal/enter/exit/order}
+  \item{type}{A character string that specifies the type of
+  the parameter, it takes the value of one of 'indicator',
+  'signal', 'enter', 'exit', 'order'.}
 
-  \item{indexnum}{tells the sequence within the type, (if
-  the type is signal, indexnum =2 means the 2nd signal in
-  the strategy)}
+  \item{indexnum}{Tells the sequence within the type, (If
+  the type is 'signal', indexnum =2 tells the function to
+  update the 2nd signal in the strategy)}
 
-  \item{distribution}{distribution of the parameter, can be
-  any function that return a vector. (example: 1:10 or
-  sample(1:20,6)}
+  \item{distribution}{Distribution of the parameter, can be
+  any function that return a vector of value. See detail.
+  (A numerical example: 1:10 or sample(1:20,6)}
 
-  \item{weight}{the weight of each value in the
+  \item{weight}{The weight of each value in the
   distribution, default value will be all equally
   weighted.}
 
+  \item{label}{string label to apply to the parameter
+  distribution}
+
   \item{psindex}{specify the index within the parameter
   distribution object, it is used to make change/ repalce a
   parameter distribution in the object.}
 }
+\value{
+  The returned object is a structure contains the
+  distribution of parameters, is of the same type as the
+  input parameter paramDist (if provided), the function
+  update the input paramDist object and return the updated
+  one. Usually the returned value is pass to the same
+  object as parameter. See details.
+}
 \description{
-  Function used to set distribution of a parameter in a
-  strategy.
+  Each call to the function will set/update the
+  distribution of ONE parameter in the strategy.
 }
+\details{
+  When call the function, the user must know the parameter
+  strcture of the strategy, function getParameterTable can
+  be used to layout the parameter structure of a certain
+  strategy. Parameter distribution object for one strategy
+  usually won't work for another strategy, because
+  different strategies has different parameter structure.
+  Type of the parameter and the sequence in that type is
+  needed to specify the exact parameter in THAT STRATEGY.
+
+  The parameter of the function 'distribution' is a list
+  contains vector of values named WITH THE NAME OF THE
+  PARAMETER, the values can be any type (integer,
+  characters, etc) matches with the leagal value of that
+  parameter. For example: distribution=list(nFast=(10:30))
+  or distribution=list(relationship=c('gt','gte'))
+}
+\examples{
+\dontrun{
+#(For complete demo see parameterTestMACD.R)
+tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nFast=(10:30)),label='nFast')
+tPD2<-setParameterDistribution(tPD2,'indicator',indexnum=1,distribution=list(nSlow=(20:40)),label='nSlow')
+tPD2<-setParameterDistribution(tPD2,'signal',indexnum=1,distribution=list(relationship=c('gt','gte')),label='sig1.gtgte')
+}
+}
 \author{
   Yu Chen
 }

Modified: pkg/quantstrat/man/updateOrders.Rd
===================================================================
--- pkg/quantstrat/man/updateOrders.Rd	2011-08-25 09:56:58 UTC (rev 738)
+++ pkg/quantstrat/man/updateOrders.Rd	2011-08-25 20:00:10 UTC (rev 739)
@@ -23,6 +23,10 @@
 
   \item{side}{one of NULL, "long" or "short", default NULL}
 
+  \item{qtysign}{one of NULL, -1,0,1 ; could be useful when
+  all qty's are reported as positive numbers and need to be
+  identified other ways, default NULL}
+
   \item{oldstatus}{one of NULL, "open", "closed",
   "canceled", or "replaced", default "open"}
 



More information about the Blotter-commits mailing list