[Blotter-commits] r1047 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 14 19:53:09 CEST 2012


Author: opentrades
Date: 2012-06-14 19:53:09 +0200 (Thu, 14 Jun 2012)
New Revision: 1047

Modified:
   pkg/quantstrat/R/orders.R
Log:
fixed case where prefer = NULL



Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2012-06-14 17:28:03 UTC (rev 1046)
+++ pkg/quantstrat/R/orders.R	2012-06-14 17:53:09 UTC (rev 1047)
@@ -209,7 +209,7 @@
 #' @seealso updateOrders
 #' @concept order book
 #' @export
-addOrder <- function(portfolio, symbol, timestamp, qty, price, ordertype, side, orderset='', threshold=NULL, status="open", statustimestamp='' , prefer='', delay=.00001, tmult=FALSE, replace=TRUE, return=FALSE, ..., TxnFees=0,label='')
+addOrder <- function(portfolio, symbol, timestamp, qty, price, ordertype, side, orderset='', threshold=NULL, status="open", statustimestamp='' , prefer=NULL, delay=.00001, tmult=FALSE, replace=TRUE, return=FALSE, ..., TxnFees=0,label='')
 {
     # get order book
     #orderbook <- getOrderBook(portfolio)
@@ -280,6 +280,7 @@
     else ordertime<-as.POSIXct(timestamp)+delay
     orders<-NULL
     for (i in 1:length(price)) {
+        if(is.null(prefer[i])) prefer[i] = ''
         neworder<-xts(as.matrix(t(c(as.character(qty[i]), 
                                     price[i], 
                                     ordertype[i], 
@@ -287,7 +288,7 @@
                                     threshold[i], 
                                     status, 
                                     statustimestamp, 
-				    prefer,
+				    prefer[i],
                                     orderset[i], 
                                     TxnFees, label))), 
                                 order.by=(ordertime))



More information about the Blotter-commits mailing list