[Blotter-commits] r431 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 25 16:40:35 CEST 2010
Author: llevenson
Date: 2010-10-25 16:40:35 +0200 (Mon, 25 Oct 2010)
New Revision: 431
Modified:
pkg/quantstrat/R/orders.R
pkg/quantstrat/R/traderules.R
Log:
- revert iceberg handling comments from performance tuning
- add argument for 'prefer' to address R-Forge request 1146
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2010-10-25 12:46:19 UTC (rev 430)
+++ pkg/quantstrat/R/orders.R 2010-10-25 14:40:35 UTC (rev 431)
@@ -471,19 +471,19 @@
stoplimit =,
iceberg = {
if (isOHLCmktdata){
- #if( ordersubset[ii,"Order.Type"] == 'iceberg'){ # switch takes care of this
+ if( ordersubset[ii,"Order.Type"] == 'iceberg'){ # switch takes care of this
stop("iceberg orders not supported for OHLC data")
- #}
+ }
# check to see if price moved through the limit
- #if( orderPrice > as.numeric(Lo(mktdataTimestamp)) &
- # orderPrice < as.numeric(Hi(mktdataTimestamp)) )
- #{
- # txnprice = orderPrice
- # txntime = as.character(timestamp)
- #} else {
+ if( orderPrice > as.numeric(Lo(mktdataTimestamp)) &
+ orderPrice < as.numeric(Hi(mktdataTimestamp)) )
+ {
+ txnprice = orderPrice
+ txntime = as.character(timestamp)
+ } else {
# price did not move through my order
- # next() # should go to next order
- #}
+ next() # should go to next order
+ }
} else if(isBBOmktdata){
# check side/qty
if(orderQty > 0){ # positive quantity 'buy'
@@ -499,7 +499,7 @@
txntime = as.character(timestamp)
} else next()
}
- #if( ordersubset[ii,"Order.Type"] == 'iceberg'){
+ if( ordersubset[ii,"Order.Type"] == 'iceberg'){
#we've transacted, so the old order was closed, put in a new one
neworder<-addOrder(portfolio=portfolio,
symbol=symbol,
@@ -516,7 +516,7 @@
ordersubset[ii,"Order.Status"]<-'replaced'
ordersubset[ii,"Order.StatusTime"]<-as.character(timestamp)
next()
- #}
+ }
} else {
# no depth data, either OHLC or BBO, getPrice explicitly using symbol ?
if(orderPrice == getPrice(mktdataTimestamp, symbol=symbol, prefer='price')){
Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R 2010-10-25 12:46:19 UTC (rev 430)
+++ pkg/quantstrat/R/traderules.R 2010-10-25 14:40:35 UTC (rev 431)
@@ -33,9 +33,10 @@
#' @param ... any other passthru parameters
#' @param ruletype one of "risk","order","rebalance","exit","entry", see \code{\link{add.rule}}
#' @param TxnFees numeric fees (usually negative) or function name for calculating TxnFees (processing happens later, not in this function)
+#' @param prefer price method for getPrice
#' @seealso \code{\link{osNoOp}} , \code{\link{add.rule}}
#' @export
-ruleSignal <- function(data=mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside=NULL, threshold=NULL, tmult=FALSE, replace=TRUE, delay=0.0001, osFUN='osNoOp', pricemethod=c('market','opside','maker'), portfolio, symbol, ..., ruletype, TxnFees=0)
+ruleSignal <- function(data=mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside=NULL, threshold=NULL, tmult=FALSE, replace=TRUE, delay=0.0001, osFUN='osNoOp', pricemethod=c('market','opside','maker'), portfolio, symbol, ..., ruletype, TxnFees=0, prefer=NULL)
{
if(!is.function(osFUN)) osFUN<-match.fun(osFUN)
#print(paste(symbol,timestamp))
More information about the Blotter-commits
mailing list