[Blotter-commits] r425 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 22 20:20:35 CEST 2010
Author: llevenson
Date: 2010-10-22 20:20:35 +0200 (Fri, 22 Oct 2010)
New Revision: 425
Modified:
pkg/quantstrat/R/orders.R
pkg/quantstrat/R/traderules.R
Log:
- In ruleOrderProc moved remqty above if statement
- In addPosLimit fixed colnames(newrow)
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2010-10-22 18:12:16 UTC (rev 424)
+++ pkg/quantstrat/R/orders.R 2010-10-22 18:20:35 UTC (rev 425)
@@ -580,8 +580,8 @@
pos<-getPosQty(portfolio,symbol,timestamp)
side=ordersubset[ii,]$Order.Side
TxnQty=as.numeric(ordersubset[ii,]$Order.Qty)
+ remqty<-TxnQty+pos
if(side=="long"){
- remqty<-TxnQty+pos
if (remqty<0){
newqty<-TxnQty-remqty
warning("TxnQTy of",TxnQty,"would cross through zero, reducing qty to",newqty)
Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R 2010-10-22 18:12:16 UTC (rev 424)
+++ pkg/quantstrat/R/traderules.R 2010-10-22 18:20:35 UTC (rev 425)
@@ -180,9 +180,10 @@
addPosLimit <- function(portfolio, symbol, timestamp, maxpos, longlevels=1, minpos=0, shortlevels=0){
portf<-getPortfolio(portfolio)
newrow <- xts(cbind(maxpos, longlevels, minpos, shortlevels),order.by=as.POSIXct(timestamp))
+ colnames(newrow)<-c("MaxPos","LongLevels","MinPos","ShortLevels")
+
if(is.null(portf$symbols[[symbol]]$PosLimit)) {
- portf$symbols[[symbol]]$PosLimit <- newrow
- colnames(portf$symbols[[symbol]]$PosLimit)<-c("MaxPos","LongLevels","MinPos","ShortLevels")
+ portf$symbols[[symbol]]$PosLimit <- newrow
} else {
if(!is.null(portf[[symbol]]$PosLimit[timestamp])){
# it exists already, so replace
More information about the Blotter-commits
mailing list