[Blotter-commits] r731 - in pkg/quantstrat: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 16 21:38:36 CEST 2011
Author: braverock
Date: 2011-08-16 21:38:35 +0200 (Tue, 16 Aug 2011)
New Revision: 731
Modified:
pkg/quantstrat/R/parameters.R
pkg/quantstrat/man/applyParameter.Rd
Log:
- update roxygen documentation to separate return and examples
Modified: pkg/quantstrat/R/parameters.R
===================================================================
--- pkg/quantstrat/R/parameters.R 2011-08-12 20:24:51 UTC (rev 730)
+++ pkg/quantstrat/R/parameters.R 2011-08-16 19:38:35 UTC (rev 731)
@@ -301,35 +301,10 @@
#' Given a parameter distribution object generated by setParameterDistribution function,
#' generate parameter sets and test each set on the specified strategy.
#'
-#' 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)
-#' or
-#' x<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,method='expand',parameterConstrains=pConstraint2)
-#'
#' The function support 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.
-#' Example:
-#' ---------------------------------------------
-#' require(foreach)
-#' require(doSMP)
-#' workers <- startWorkers(2)
-#' registerDoSMP(workers)
#'
-#' #PUT ALL CODE RELATED TO QUANTSTRAT HERE
#'
-#' stopWorkers(workers)
-#' rmSessions(all=TRUE)
-#' ---------------------------------------------
-#'
-#'
-#' In the returned Object x:
-#' x$statsTable is the summary table show stats from all the runs.
-#' x$eachRun contains the details of test run with each parameter set, including portfolio name, account name, strategy used, parameters used, stats of the single run, object in .blotter but as a list named blotterl.
-#' x$paramTable is parameter samples used, in a table for print.
-#' x$paramConstrainTable is the constraints apply to the parameters, in a table for print.
-#' x$parameterDistribution is the parameter distribution passed in as argument.
-#' x$parameterConstrains is the constraints apply to the parameters, passed in as argument.
-#'
#' 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
@@ -338,7 +313,35 @@
#' account.macd.p.1, account.macd.p.2 ... and
#' portfolio.macd.p.1, portfolio.macd.p.2 ...
#'
+#' @return
+#' In the returned Object:
#'
+#' \describe{
+#' \item{statsTable}{is the summary table show stats from all the runs}
+#' \item{eachRun}{contains the details of test run with each parameter set, including portfolio name, account name, strategy used, parameters used, stats of the single run, object in .blotter but as a list named blotterl}
+#' \item{paramTable}{is parameter samples used, in a table for print}
+#' \item{paramConstrainTable}{is the constraints apply to the parameters, in a table for print}
+#' \item{parameterDistribution}{is the parameter distribution passed in as argument}
+#' \item{parameterConstrains}{is the constraints apply to the parameters, passed in as argument}
+#' }
+#' @examples
+#' \dontrun{
+#' require(foreach)
+#' require(doSMP)
+#' workers <- startWorkers(2)
+#' registerDoSMP(workers)
+#'
+#' #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)
+#' #or
+#' x<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,
+#' method='expand',parameterConstrains=pConstraint2)
+#'
+#' stopWorkers(workers)
+#' rmSessions(all=TRUE)
+#' }
#' @param strategy The strategy to test paramters to.
#' @param portfolios The character name of the portfolios to apply to.
#' @param parameterPool The object that created by setParameterDistribution function, which includes all the parameter legal values and distribution/weights.
Modified: pkg/quantstrat/man/applyParameter.Rd
===================================================================
--- pkg/quantstrat/man/applyParameter.Rd 2011-08-12 20:24:51 UTC (rev 730)
+++ pkg/quantstrat/man/applyParameter.Rd 2011-08-16 19:38:35 UTC (rev 731)
@@ -1,47 +1,90 @@
\name{applyParameter}
\alias{applyParameter}
-\title{Test different parameter sets on a strategy.}
+\title{Generate parameter sets based on specified distribution and constrains, apply the parameters to the specified strategy and return the results package.}
\usage{
applyParameter(strategy, portfolios, parameterPool,
parameterConstrains, method, sampleSize)
}
\arguments{
- \item{strategy}{name of the strategy to apply paramters
- to.}
+ \item{strategy}{The strategy to test paramters to.}
- \item{portfolios}{name of the portfolio to apply to.}
+ \item{portfolios}{The character name of the portfolios to
+ apply to.}
- \item{parameterPool}{a paramter distribution object that
- created by setParameterDistribution function, which
- includes all the parameter legal values and
- distribution/weights.}
+ \item{parameterPool}{The object that created by
+ setParameterDistribution function, which includes all the
+ parameter legal values and distribution/weights.}
- \item{parameterConstrains}{the object created by
+ \item{parameterConstrains}{The object created by
setParameterConstraint function that specifies the
constrains between each parameters,}
- \item{method}{takes string 'expand' or 'random', specify
+ \item{method}{Takes string 'expand' or 'random', specify
how to generate samples of parameters. 'expand' will do
all possible combinations of the parameter sets,}
- \item{sampleSize}{used when method=='random', specify how
+ \item{sampleSize}{Used when method=='random', specify how
many parameter sets to generate and run test of.}
}
+\value{
+ In the returned Object:
+
+ \describe{ \item{statsTable}{is the summary table show
+ stats from all the runs} \item{eachRun}{contains the
+ details of test run with each parameter set, including
+ portfolio name, account name, strategy used, parameters
+ used, stats of the single run, object in .blotter but as
+ a list named blotterl} \item{paramTable}{is parameter
+ samples used, in a table for print}
+ \item{paramConstrainTable}{is the constraints apply to
+ the parameters, in a table for print}
+ \item{parameterDistribution}{is the parameter
+ distribution passed in as argument}
+ \item{parameterConstrains}{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 specified strategy.
+ sets and test each set on the specified strategy.
}
\details{
- In the returned Object$: eachRun contains the details of
- test run with each parameter set. paramTable is parameter
- samples used, in a table for print. paramConstrainTable
- is the constraints apply to the parameters, in a table
- for print. parameterDistribution is the parameter
- distribution passed in as argument. parameterConstrains
- is the constraints apply to the parameters, passed in as
- argument.
+ The function support 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 ...
}
+\examples{
+\dontrun{
+require(foreach)
+require(doSMP)
+workers <- startWorkers(2)
+registerDoSMP(workers)
+
+#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)
+#or
+x<-applyParameter(strategy=stratMACD,portfolios=portfolio.st,parameterPool=tPD2,
+method='expand',parameterConstrains=pConstraint2)
+
+stopWorkers(workers)
+rmSessions(all=TRUE)
+}
+}
\author{
Yu Chen
}
More information about the Blotter-commits
mailing list