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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 1 13:52:25 CET 2012


Author: braverock
Date: 2012-11-01 13:52:25 +0100 (Thu, 01 Nov 2012)
New Revision: 1233

Added:
   pkg/quantstrat/R/ruleCancel.R
   pkg/quantstrat/man/ruleCancel.Rd
Modified:
   pkg/quantstrat/NAMESPACE
Log:
- add ruleCancel function contributed by Niklas Kolster

Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE	2012-10-28 22:07:42 UTC (rev 1232)
+++ pkg/quantstrat/NAMESPACE	2012-11-01 12:52:25 UTC (rev 1233)
@@ -27,6 +27,7 @@
 export(osMaxPos)
 export(osNoOp)
 export(rm.strat)
+export(ruleCancel)
 export(ruleOrderProc)
 export(ruleSignal)
 export(save.strategy)

Added: pkg/quantstrat/R/ruleCancel.R
===================================================================
--- pkg/quantstrat/R/ruleCancel.R	                        (rev 0)
+++ pkg/quantstrat/R/ruleCancel.R	2012-11-01 12:52:25 UTC (rev 1233)
@@ -0,0 +1,51 @@
+#' rule to cancel an unfilled limit order on a signal
+#' 
+#' 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 cancelled manually or replaced by other orders.
+#' 
+#' This function is used for canceling the orders based on a signal.
+#' 
+#' @param 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
+#' @param timestamp timestamp coercible to POSIXct that will be the time the order will be inserted on 
+#' @param sigcol column name to check for signal
+#' @param sigval signal value to match against
+#' @param orderside one of either "long" or "short", default NULL, see details 
+#' @param orderset tag to identify an orderset
+#' @param portfolio text name of the portfolio to place orders in
+#' @param symbol identifier of the instrument to cancel orders for
+#' @param ruletype must be 'risk' for ruleCancel, see \code{\link{add.rule}}
+#' @author Niklas Kolster
+#' @seealso \code{\link{osNoOp}} , \code{\link{add.rule}}
+#' @export
+ruleCancel <- function(data=mktdata, timestamp, sigcol, sigval, orderside=NULL, orderset=NULL, portfolio, symbol, ruletype)
+{
+ 
+
+  if (ruletype!='risk') {
+    stop(paste('Ruletype can only be risk'))
+  }
+  
+  if(is.null(orderset)) orderset=NA
+    
+  updateOrder(portfolio=portfolio, 
+              symbol=symbol, 
+              timespan=timespan,
+              orderset=orderset, 
+              newstatus='canceled'
+             )
+  
+}
+
+###############################################################################
+# R (http://r-project.org/) Quantitative Strategy Model Framework
+#
+# Copyright (c) 2012
+# Niklas Kolster
+#
+# This library is distributed under the terms of the GNU Public License (GPL)
+# for full details see the file COPYING
+#
+# $Id$
+#
+###############################################################################


Property changes on: pkg/quantstrat/R/ruleCancel.R
___________________________________________________________________
Added: svn:keywords
   + Id Author Date

Added: pkg/quantstrat/man/ruleCancel.Rd
===================================================================
--- pkg/quantstrat/man/ruleCancel.Rd	                        (rev 0)
+++ pkg/quantstrat/man/ruleCancel.Rd	2012-11-01 12:52:25 UTC (rev 1233)
@@ -0,0 +1,52 @@
+\name{ruleCancel}
+\alias{ruleCancel}
+\title{rule to cancel an unfilled limit order on a signal}
+\usage{
+  ruleCancel(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 cancel
+  orders for}
+
+  \item{ruletype}{must be 'risk' for ruleCancel, 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
+  cancelled manually or replaced by other orders.
+}
+\details{
+  This function is used for canceling the orders based on a
+  signal.
+}
+\author{
+  Niklas Kolster
+}
+\seealso{
+  \code{\link{osNoOp}} , \code{\link{add.rule}}
+}
+



More information about the Blotter-commits mailing list