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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 11 15:23:33 CEST 2010


Author: llevenson
Date: 2010-10-11 15:23:33 +0200 (Mon, 11 Oct 2010)
New Revision: 415

Modified:
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/R/traderules.R
Log:
- Fixed creation of xts object newrow with cbind (traderules.R, line 180)
- Added as.numeric wrapper around qty[i] (orders.R, line 262)


Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2010-10-11 12:11:57 UTC (rev 414)
+++ pkg/quantstrat/R/orders.R	2010-10-11 13:23:33 UTC (rev 415)
@@ -259,7 +259,7 @@
 
 	order<-NULL
 	for (i in 1:length(price)){
-		neworder<-xts(as.matrix(t(c(qty[i], price[i], ordertype[i], side, threshold[i], status, statustimestamp, order.set,TxnFees))),order.by=(ordertime))
+		neworder<-xts(as.matrix(t(c(as.numeric(qty[i]), price[i], ordertype[i], side, threshold[i], status, statustimestamp, order.set,TxnFees))),order.by=(ordertime))
 		if(is.null(order)) order<-neworder
 		else order <- rbind(order,neworder)
 	}

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2010-10-11 12:11:57 UTC (rev 414)
+++ pkg/quantstrat/R/traderules.R	2010-10-11 13:23:33 UTC (rev 415)
@@ -177,7 +177,7 @@
 #' @export
 addPosLimit <- function(portfolio, symbol, timestamp, maxpos, longlevels=1, minpos=0, shortlevels=0){
     portf<-getPortfolio(portfolio)
-    newrow <- xts(c(maxpos, longlevels, minpos, shortlevels),order.by=as.POSIXct(timestamp))
+    newrow <- xts(cbind(maxpos, longlevels, minpos, shortlevels),order.by=as.POSIXct(timestamp))
     if(is.null(portf$symbols[[symbol]]$PosLimit)) {
         portf$symbols[[symbol]]$PosLimit <- newrow 
         colnames(portf$symbols[[symbol]]$PosLimit)<-c("MaxPos","LongLevels","MinPos","ShortLevels")



More information about the Blotter-commits mailing list