[Blotter-commits] r409 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 7 22:21:22 CEST 2010


Author: braverock
Date: 2010-10-07 22:21:22 +0200 (Thu, 07 Oct 2010)
New Revision: 409

Modified:
   pkg/blotter/R/updatePosPL.R
Log:
- remove edge case bug where priorPL has no rows

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-10-07 16:54:31 UTC (rev 408)
+++ pkg/blotter/R/updatePosPL.R	2010-10-07 20:21:22 UTC (rev 409)
@@ -49,6 +49,11 @@
 	Portfolio$symbols[[Symbol]]$posPL<-Portfolio$symbols[[Symbol]]$posPL[paste('::',startDate,sep='')]
 	Portfolio$symbols[[Symbol]][[paste('posPL',p.ccy.str,sep='.')]]<-Portfolio$symbols[[Symbol]][[paste('posPL',p.ccy.str,sep='.')]][paste('::',startDate,sep='')]
 	priorPL<-last(Portfolio$symbols[[Symbol]]$posPL)
+	if(nrow(priorPL)==0) {
+		cn<-colnames(priorPL)
+		priorPL = xts(t(rep(0,ncol(priorPL))),order.by=startDate-1)
+		colnames(priorPL)<-cn
+	}
 	
 	Txns <- Portfolio$symbols[[Symbol]]$txn[dateRange]
 	# if there are no transactions, get the last one before the current dateRange, we'll discard later



More information about the Blotter-commits mailing list