[Blotter-commits] r383 - in pkg/blotter: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 2 20:22:04 CEST 2010


Author: braverock
Date: 2010-09-02 20:22:04 +0200 (Thu, 02 Sep 2010)
New Revision: 383

Modified:
   pkg/blotter/DESCRIPTION
   pkg/blotter/R/updatePosPL.R
Log:
- fix issue with subsetting in latest xts, caused rbind to fail
  - reported by Ben McCann, Alex Bird. thx to Jeff Ryan for xts debugging help
- bump xts version requirement to 0.7-5

Modified: pkg/blotter/DESCRIPTION
===================================================================
--- pkg/blotter/DESCRIPTION	2010-08-26 11:26:06 UTC (rev 382)
+++ pkg/blotter/DESCRIPTION	2010-09-02 18:22:04 UTC (rev 383)
@@ -8,7 +8,7 @@
 Description: Transaction infrastructure for defining instruments, transactions, portfolios and accounts for trading systems and simulation.  Intends to provide portfolio support for multi-asset class and multi-currency portfolios.  Still in heavy development.
 License: GPL
 LazyLoad: yes
-Depends: R (>= 2.9.0), xts (>= 0.7-1), quantmod (>= 0.3-14), FinancialInstrument
+Depends: R (>= 2.9.0), xts (>= 0.7-5), quantmod (>= 0.3-14), FinancialInstrument
 Suggests: PerformanceAnalytics, PortfolioAnalytics, Hmisc, RUnit
 Contributors: Wolfgang Wu, Ben McCann 
 URL: https://r-forge.r-project.org/projects/blotter/

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-08-26 11:26:06 UTC (rev 382)
+++ pkg/blotter/R/updatePosPL.R	2010-09-02 18:22:04 UTC (rev 383)
@@ -48,14 +48,10 @@
 	Portfolio$symbols[[Symbol]][[paste('posPL',p.ccy.str,sep='.')]]<-Portfolio$symbols[[Symbol]][[paste('posPL',p.ccy.str,sep='.')]][paste('::',startDate,sep='')]
 	
 	Txns <- Portfolio$symbols[[Symbol]]$txn[dateRange]
-	if(nrow(Txns)==1){
-		newtxn <- last(Portfolio$symbols[[Symbol]]$posPL)[,colnames(Txns)]
-		Txns <- rbind(Txns,newtxn)
+	# if there are no transactions, get the last one before the current dateRange, we'll discard later
+	if(is.null(nrow(Txns))) {
+		Txns <- last(Portfolio$symbols[[Symbol]]$txn[paste('::',startDate,sep='')])
 		rmfirst=TRUE
-	}
-	if(nrow(Txns)==0) {
-		Txns <- last(Portfolio$symbols[[Symbol]]$posPL)
-		rmfirst=TRUE
 	} 
 	
 	#	 line up transaction with Dates list



More information about the Blotter-commits mailing list