[Blotter-commits] r355 - in pkg/quantstrat: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 16 21:08:44 CEST 2010
Author: braverock
Date: 2010-07-16 21:08:41 +0200 (Fri, 16 Jul 2010)
New Revision: 355
Modified:
pkg/quantstrat/R/rules.R
pkg/quantstrat/R/traderules.R
pkg/quantstrat/man/add.rule.Rd
pkg/quantstrat/man/osMaxPos.Rd
pkg/quantstrat/man/osNoOp.Rd
Log:
- fix 'enter'/'entry' confusion
- normalize docs and code
- accept either argument
Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R 2010-07-16 18:00:48 UTC (rev 354)
+++ pkg/quantstrat/R/rules.R 2010-07-16 19:08:41 UTC (rev 355)
@@ -38,14 +38,14 @@
#' @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 label arbitrary text label for rule output, NULL default will be converted to '<name>.rule'
-#' @param type one of "risk","order","rebalance","exit","entry", see Details
+#' @param type one of "risk","order","rebalance","exit","enter", see Details
#' @param ... any other passthru parameters
#' @param enabled TRUE/FALSE whether the rule is enabled for use in applying the strategy, default TRUE
#' @param indexnum if you are updating a specific rule, the index number in the $rules[type] list to update
#' @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","entry"), ..., enabled=TRUE, indexnum=NULL, path.dep=TRUE, store=FALSE) {
+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) {
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")
@@ -206,7 +206,7 @@
ruleOrderProc(portfolio=portfolio, symbol=symbol, mktdata=mktdata, timespan=timespan)
}
},
- rebalance =, exit = , enter = {
+ rebalance =, exit = , enter = , entry = {
if(isTRUE(hold)) next()
if(type=='exit'){
# must have a position for an exit rules to fire
Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R 2010-07-16 18:00:48 UTC (rev 354)
+++ pkg/quantstrat/R/traderules.R 2010-07-16 19:08:41 UTC (rev 355)
@@ -96,7 +96,7 @@
#' @param portfolio text name of the portfolio to place orders in
#' @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 ruletype one of "risk","order","rebalance","exit","enter", see \code{\link{add.rule}}
#' @export
osNoOp <- function(timestamp, orderqty, portfolio, symbol, ruletype, ...){
if(orderqty=='all'){
@@ -177,12 +177,13 @@
#' @param orderside one of either "long" or "short"
#' @param portfolio text name of the portfolio to place orders in
#' @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 ruletype one of "risk","order","rebalance","exit","entry", see \code{\link{add.rule}}
+#' @param ruletype one of "risk","order","rebalance","exit","enter", see \code{\link{add.rule}}
#' @param ... any other passthru parameters
#' @seealso \code{\link{addPosLimit}},\code{\link{getPosLimit}}
#' @export
osMaxPos <- function(mktdata, timestamp, orderqty, ordertype, orderside, portfolio, symbol, ruletype, ...){
- # check for current position
+ # TODO integrate orderqty='all' into osMaxPos by combining side
+ # check for current position
pos<-getPosQty(portfolio,symbol,timestamp)
# check against max position
PosLimit<-getPosLimit(portfolio,symbol,timestamp)
Modified: pkg/quantstrat/man/add.rule.Rd
===================================================================
--- pkg/quantstrat/man/add.rule.Rd 2010-07-16 18:00:48 UTC (rev 354)
+++ pkg/quantstrat/man/add.rule.Rd 2010-07-16 19:08:41 UTC (rev 355)
@@ -2,7 +2,7 @@
\alias{add.rule}
\title{add a rule to a strategy...}
\usage{add.rule(strategy, name, arguments, label, type=c(NULL, "risk",
- "order", "rebalance", "exit", "entry"), ..., enabled=TRUE,
+ "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.
@@ -42,7 +42,7 @@
\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{label}{arbitrary text label for rule output, NULL default will be converted to '<name>.rule'}
-\item{type}{one of "risk","order","rebalance","exit","entry", see Details}
+\item{type}{one of "risk","order","rebalance","exit","enter", see Details}
\item{...}{any other passthru parameters}
\item{enabled}{TRUE/FALSE whether the rule is enabled for use in applying the strategy, default TRUE}
\item{indexnum}{if you are updating a specific rule, the index number in the $rules[type] list to update}
Modified: pkg/quantstrat/man/osMaxPos.Rd
===================================================================
--- pkg/quantstrat/man/osMaxPos.Rd 2010-07-16 18:00:48 UTC (rev 354)
+++ pkg/quantstrat/man/osMaxPos.Rd 2010-07-16 19:08:41 UTC (rev 355)
@@ -18,5 +18,5 @@
\item{orderside}{one of either "long" or "short"}
\item{portfolio}{text name of the portfolio to place orders in}
\item{symbol}{identifier of the instrument to place orders for. The name of any associated price objects (xts prices, usually OHLC) should match these}
-\item{ruletype}{one of "risk","order","rebalance","exit","entry", see \code{\link{add.rule}}}
+\item{ruletype}{one of "risk","order","rebalance","exit","enter", see \code{\link{add.rule}}}
\item{...}{any other passthru parameters}}
Modified: pkg/quantstrat/man/osNoOp.Rd
===================================================================
--- pkg/quantstrat/man/osNoOp.Rd 2010-07-16 18:00:48 UTC (rev 354)
+++ pkg/quantstrat/man/osNoOp.Rd 2010-07-16 19:08:41 UTC (rev 355)
@@ -11,4 +11,4 @@
\item{portfolio}{text name of the portfolio to place orders in}
\item{symbol}{identifier of the instrument to place orders for. The name of any associated price objects (xts prices, usually OHLC) should match these}
\item{...}{any other passthru parameters}
-\item{ruletype}{one of "risk","order","rebalance","exit","entry", see \code{\link{add.rule}}}}
+\item{ruletype}{one of "risk","order","rebalance","exit","enter", see \code{\link{add.rule}}}}
More information about the Blotter-commits
mailing list