[Blotter-commits] r984 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 25 18:25:20 CEST 2012
Author: braverock
Date: 2012-03-25 18:25:19 +0200 (Sun, 25 Mar 2012)
New Revision: 984
Modified:
pkg/quantstrat/R/orders.R
Log:
- add threshold patch to use threshold on creation of limit order provided by Jan Humme <jan <at> opentrades <dot> nl>
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2012-03-25 16:12:43 UTC (rev 983)
+++ pkg/quantstrat/R/orders.R 2012-03-25 16:25:19 UTC (rev 984)
@@ -194,7 +194,7 @@
#' @param price numeric price at which the order is to be inserted
#' @param ordertype one of "market","limit","stoplimit", "stoptrailing",or "iceberg"
#' @param side one of either "long" or "short"
-#' @param threshold numeric threshold to apply to trailing stop orders, default NULL
+#' @param threshold numeric threshold to apply to trailing stop orders and limit orders, default NULL
#' @param status one of "open", "closed", "canceled", or "replaced", default "open"
#' @param statustimestamp timestamp of a status update, will be blank when order is initiated
#' @param delay what delay to add to timestamp when inserting the order into the order book, in seconds
@@ -227,9 +227,10 @@
if(!is.null(side) & !length(grep(side,c('long','short')))==1) stop(paste("side:",side," must be one of 'long' or 'short'"))
if(is.na(charmatch(ordertype,c("market","limit","stoplimit","stoptrailing","iceberg")))) stop(paste("ordertype:",ordertype,' must be one of "market","limit","stoplimit","stoptrailing", or"iceberg"'))
if(!is.null(threshold) & length(price)>=1 ) {
- if(length(grep(ordertype,c("stoplimit","stoptrailing","iceberg")))==1) {
+ if(length(grep(paste("^",ordertype,"$",sep=""),c("limit","stoplimit","stoptrailing","iceberg")))==1) {
#we have a threshold set on a stop* order, process it
switch(ordertype,
+ limit =,
stoplimit =,
iceberg =,
stoptrailing = {
@@ -247,7 +248,7 @@
}
) #end type switch
} else {
- stop(paste("Threshold may only be applied to a stop or iceberg order type",ordertype,threshold))
+ stop(paste("Threshold may only be applied to a limit, stop or iceberg order type",ordertype,threshold))
}
}
More information about the Blotter-commits
mailing list