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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 28 20:02:52 CET 2012


Author: braverock
Date: 2012-11-28 20:02:51 +0100 (Wed, 28 Nov 2012)
New Revision: 1271

Added:
   pkg/quantstrat/man/ruleRevoke.Rd
Modified:
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/R/signals.R
   pkg/quantstrat/man/addOrder.Rd
   pkg/quantstrat/man/ruleSignal.Rd
   pkg/quantstrat/man/sigComparison.Rd
   pkg/quantstrat/man/sigCrossover.Rd
   pkg/quantstrat/man/sigThreshold.Rd
Log:
- add offsets for sigComarison/sigCrossover
- update roxygen docs
- bump version

Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/DESCRIPTION	2012-11-28 19:02:51 UTC (rev 1271)
@@ -1,7 +1,7 @@
 Package: quantstrat
 Type: Package
 Title: Quantitative Strategy Model Framework
-Version: 0.7.6
+Version: 0.7.7
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
 Depends:

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/R/signals.R	2012-11-28 19:02:51 UTC (rev 1271)
@@ -173,8 +173,10 @@
 #' @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
+#' @param offset1 numeric offset to be added to the first column prior to comparison
+#' @param offset2 numeric offset to be added to the second column prior to comparison
 #' @export
-sigComparison <- function(label,data=mktdata, columns, relationship=c("gt","lt","eq","gte","lte")) {
+sigComparison <- function(label,data=mktdata, columns, relationship=c("gt","lt","eq","gte","lte"), offset1=0, offset2=0) {
     relationship=relationship[1] #only use the first one
     if (length(columns)==2){
         ret_sig=NULL
@@ -203,7 +205,7 @@
 					 	lte =, lteq =, le =, "<=" = "<="
 					 )
 
-		ret_sig <- do.call( opr, list(data[,colNums[1]], data[,colNums[2]]))
+		ret_sig <- do.call( opr, list(data[,colNums[1]]+offset1, data[,colNums[2]]+offset2))
 
     } else {
         stop("comparison of more than two columns not supported, see sigFormula")
@@ -226,12 +228,14 @@
 #' @param data data to apply crossover to
 #' @param columns named columns to apply crossover of the first against the second
 #' @param relationship one of c("gt","lt","eq","gte","lte") or reasonable alternatives
+#' @param offset1 numeric offset to be added to the first column prior to comparison
+#' @param offset2 numeric offset to be added to the second column prior to comparison
 #' @export
-sigCrossover <- function(label,data=mktdata, columns, relationship=c("gt","lt","eq","gte","lte")) {
+sigCrossover <- function(label,data=mktdata, columns, relationship=c("gt","lt","eq","gte","lte"), offset1=0, offset2=0) {
     ret_sig = FALSE
     lng<-length(columns)
     for (i in 1:(lng-1)) {
-        ret_sig = suppressWarnings(ret_sig | diff(sigComparison(label=label,data=data,columns=columns[c(i,lng)],relationship=relationship))==1)
+        ret_sig = suppressWarnings(ret_sig | diff(sigComparison(label=label,data=data,columns=columns[c(i,lng)],relationship=relationship,offset1=offset1, offset2=offset2))==1)
     }
     is.na(ret_sig) <- which(!ret_sig)
     colnames(ret_sig)<-label
@@ -271,7 +275,7 @@
 #' @param label text label to apply to the output
 #' @param data data to apply comparison to
 #' @param column named column to apply comparison to
-#' @param threshold numeric threhold to test for
+#' @param threshold numeric threshold to test for
 #' @param relationship one of c("gt","lt","eq","gte","lte") or reasonable alternatives
 #' @param cross if TRUE, will return TRUE only for the first observation to cross the threshold in a run
 #' @export

Modified: pkg/quantstrat/man/addOrder.Rd
===================================================================
--- pkg/quantstrat/man/addOrder.Rd	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/man/addOrder.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -5,7 +5,7 @@
   addOrder(portfolio, symbol, timestamp, qty, price,
     ordertype, side, threshold = NULL, orderset = "",
     status = "open", statustimestamp = "", prefer = NULL,
-    delay = 0.00001, tmult = FALSE, replace = TRUE,
+    delay = 1e-05, tmult = FALSE, replace = TRUE,
     return = FALSE, ..., TxnFees = 0, label = "")
 }
 \arguments{

Added: pkg/quantstrat/man/ruleRevoke.Rd
===================================================================
--- pkg/quantstrat/man/ruleRevoke.Rd	                        (rev 0)
+++ pkg/quantstrat/man/ruleRevoke.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -0,0 +1,52 @@
+\name{ruleRevoke}
+\alias{ruleRevoke}
+\title{rule to revoke an unfilled limit order on a signal}
+\usage{
+  ruleRevoke(data = mktdata, timestamp, sigcol, sigval,
+    orderside = NULL, 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}
+
+  \item{timestamp}{timestamp coercible to POSIXct that will
+  be the time the order will be inserted on}
+
+  \item{sigcol}{column name to check for signal}
+
+  \item{sigval}{signal value to match against}
+
+  \item{orderside}{one of either "long" or "short", default
+  NULL, see details}
+
+  \item{orderset}{tag to identify an orderset}
+
+  \item{portfolio}{text name of the portfolio to place
+  orders in}
+
+  \item{symbol}{identifier of the instrument to revoke
+  orders for}
+
+  \item{ruletype}{must be 'risk' for ruleRevoke, see
+  \code{\link{add.rule}}}
+}
+\description{
+  As described elsewhere in the documentation, quantstrat
+  models \emph{orders}.  All orders in quantstrat are GTC
+  orders, which means that unfilled limit orders have to be
+  revokeled manually or replaced by other orders.
+}
+\details{
+  This function is used for revokeing the orders based on a
+  signal.
+}
+\author{
+  Niklas Kolster, Jan Humme
+}
+\seealso{
+  \code{\link{osNoOp}} , \code{\link{add.rule}}
+}
+

Modified: pkg/quantstrat/man/ruleSignal.Rd
===================================================================
--- pkg/quantstrat/man/ruleSignal.Rd	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/man/ruleSignal.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -5,7 +5,7 @@
   ruleSignal(mktdata = mktdata, timestamp, sigcol, sigval,
     orderqty = 0, ordertype, orderside = NULL,
     orderset = NULL, threshold = NULL, tmult = FALSE,
-    replace = TRUE, delay = 0.0001, osFUN = "osNoOp",
+    replace = TRUE, delay = 1e-04, osFUN = "osNoOp",
     pricemethod = c("market", "opside", "active"),
     portfolio, symbol, ..., ruletype, TxnFees = 0,
     prefer = NULL, sethold = FALSE, label = "")

Modified: pkg/quantstrat/man/sigComparison.Rd
===================================================================
--- pkg/quantstrat/man/sigComparison.Rd	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/man/sigComparison.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -3,7 +3,8 @@
 \title{generate comparison signal}
 \usage{
   sigComparison(label, data = mktdata, columns,
-    relationship = c("gt", "lt", "eq", "gte", "lte"))
+    relationship = c("gt", "lt", "eq", "gte", "lte"),
+    offset1 = 0, offset2 = 0)
 }
 \arguments{
   \item{label}{text label to apply to the output}
@@ -15,6 +16,12 @@
   \item{relationship}{one of
   c("gt","lt","eq","gte","lte","op") or reasonable
   alternatives}
+
+  \item{offset1}{numeric offset to be added to the first
+  column prior to comparison}
+
+  \item{offset2}{numeric offset to be added to the second
+  column prior to comparison}
 }
 \description{
   Currently, this function compares two columns. Patches to

Modified: pkg/quantstrat/man/sigCrossover.Rd
===================================================================
--- pkg/quantstrat/man/sigCrossover.Rd	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/man/sigCrossover.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -3,7 +3,8 @@
 \title{generate a crossover signal}
 \usage{
   sigCrossover(label, data = mktdata, columns,
-    relationship = c("gt", "lt", "eq", "gte", "lte"))
+    relationship = c("gt", "lt", "eq", "gte", "lte"),
+    offset1 = 0, offset2 = 0)
 }
 \arguments{
   \item{label}{text label to apply to the output}
@@ -15,6 +16,12 @@
 
   \item{relationship}{one of c("gt","lt","eq","gte","lte")
   or reasonable alternatives}
+
+  \item{offset1}{numeric offset to be added to the first
+  column prior to comparison}
+
+  \item{offset2}{numeric offset to be added to the second
+  column prior to comparison}
 }
 \description{
   This will generate a crossover signal, which is a

Modified: pkg/quantstrat/man/sigThreshold.Rd
===================================================================
--- pkg/quantstrat/man/sigThreshold.Rd	2012-11-28 18:25:56 UTC (rev 1270)
+++ pkg/quantstrat/man/sigThreshold.Rd	2012-11-28 19:02:51 UTC (rev 1271)
@@ -14,7 +14,7 @@
 
   \item{column}{named column to apply comparison to}
 
-  \item{threshold}{numeric threhold to test for}
+  \item{threshold}{numeric threshold to test for}
 
   \item{relationship}{one of c("gt","lt","eq","gte","lte")
   or reasonable alternatives}



More information about the Blotter-commits mailing list