[Blotter-commits] r1730 - in pkg/quantstrat: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 9 00:10:37 CET 2016
Author: bodanker
Date: 2016-01-09 00:10:37 +0100 (Sat, 09 Jan 2016)
New Revision: 1730
Modified:
pkg/quantstrat/R/ruleRevoke.R
pkg/quantstrat/man/ruleRevoke.Rd
Log:
Only cancel/revoke open orders
ruleRevoke would incorrectly revoke all orders, all the time (even
closed orders). Add curIndex handling for faster processing, and add a
check to ensure updateOrders is called appropriately (ruleSignal has
a similar check). Update docs to add '...' to function arguments.
Thanks to Joseph Dunn for the report and patch!
Modified: pkg/quantstrat/R/ruleRevoke.R
===================================================================
--- pkg/quantstrat/R/ruleRevoke.R 2015-12-26 19:19:52 UTC (rev 1729)
+++ pkg/quantstrat/R/ruleRevoke.R 2016-01-08 23:10:37 UTC (rev 1730)
@@ -18,15 +18,25 @@
#' @param portfolio text name of the portfolio to place orders in
#' @param symbol identifier of the instrument to revoke orders for
#' @param ruletype must be 'risk' for ruleRevoke, see \code{\link{add.rule}}
+#' @param ... any other passthru parameters
#' @author Niklas Kolster, Jan Humme
#' @seealso \code{\link{osNoOp}} , \code{\link{add.rule}}
#' @export
-ruleRevoke <- ruleCancel <- function(data=mktdata, timestamp, sigcol, sigval, orderside=NULL, orderset=NULL, portfolio, symbol, ruletype)
+ruleRevoke <- ruleCancel <- function(data=mktdata, timestamp, sigcol, sigval, orderside=NULL, orderset=NULL, portfolio, symbol, ruletype, ...)
{
- if(ruletype!='risk') stop('Ruletype for ruleRevoke or ruleCancel must be "risk".')
+ if (ruletype != 'risk') {
+ stop('Ruletype for ruleRevoke or ruleCancel must be "risk".')
+ }
- pos <- getPosQty(portfolio, symbol, timestamp)
- if(pos == 0)
+ # Get row index of timestamp for faster subsetting
+ if (hasArg(curIndex)) {
+ curIndex <- eval(match.call(expand.dots=TRUE)$curIndex, parent.frame())
+ } else {
+ curIndex <- mktdata[timestamp,which.i=TRUE]
+ }
+
+ if (curIndex > 0 && curIndex <= nrow(mktdata) &&
+ !is.na(mktdata[curIndex,sigcol]) && mktdata[curIndex,sigcol] == sigval)
{
updateOrders(portfolio=portfolio,
symbol=symbol,
Modified: pkg/quantstrat/man/ruleRevoke.Rd
===================================================================
--- pkg/quantstrat/man/ruleRevoke.Rd 2015-12-26 19:19:52 UTC (rev 1729)
+++ pkg/quantstrat/man/ruleRevoke.Rd 2016-01-08 23:10:37 UTC (rev 1730)
@@ -5,7 +5,7 @@
\title{rule to revoke(cancel) an unfilled limit order on a signal}
\usage{
ruleRevoke(data = mktdata, timestamp, sigcol, sigval, orderside = NULL,
- orderset = NULL, portfolio, symbol, ruletype)
+ orderset = NULL, portfolio, symbol, ruletype, ...)
}
\arguments{
\item{data}{an xts object containing market data. depending on rules, may need to be in OHLCV or BBO formats, and may include indicator and signal information}
@@ -25,6 +25,8 @@
\item{symbol}{identifier of the instrument to revoke orders for}
\item{ruletype}{must be 'risk' for ruleRevoke, see \code{\link{add.rule}}}
+
+\item{...}{any other passthru parameters}
}
\description{
As described elsewhere in the documentation, quantstrat models
More information about the Blotter-commits
mailing list