[Blotter-commits] r1504 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Sep 14 00:50:16 CEST 2013
Author: bodanker
Date: 2013-09-14 00:50:16 +0200 (Sat, 14 Sep 2013)
New Revision: 1504
Modified:
pkg/blotter/R/updatePortf.R
Log:
- complete Brian's patch to get all index values from all symbols
Modified: pkg/blotter/R/updatePortf.R
===================================================================
--- pkg/blotter/R/updatePortf.R 2013-09-13 21:37:20 UTC (rev 1503)
+++ pkg/blotter/R/updatePortf.R 2013-09-13 22:50:16 UTC (rev 1504)
@@ -32,7 +32,7 @@
# Calculate and store portfolio summary table
Portfolio<-getPortfolio(pname) # refresh with an updated object
#if(is.null(Dates)) Dates <- xts:::time.xts(Portfolio$symbols[[1]]$posPL) #not quite right, only using first symbol...
- if(is.null(Dates)) Dates <- xts(,do.call(unlist,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]][Dates]) ))))
+ if(is.null(Dates)) Dates <- unique(do.call(c,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]][Dates]) ), use.names=FALSE, recursive=FALSE)))
#Symbols = ls(Portfolio$symbols)
Attributes = c('Long.Value', 'Short.Value', 'Net.Value', 'Gross.Value', 'Period.Realized.PL', 'Period.Unrealized.PL', 'Gross.Trading.PL', 'Txn.Fees', 'Net.Trading.PL')
@@ -94,7 +94,7 @@
# if(!is.timeBased(Dates)) Dates = xts:::time.xts(Portfolio$symbols[[1]][["posPL"]][Dates])
#xts(,do.call(unlist,c(lapply(symbols,index),use.names=FALSE)))
- if(!is.timeBased(Dates)) Dates <- xts(,do.call(unlist,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]][Dates]) ))))
+ if(!is.timeBased(Dates)) Dates <- unique(do.call(c,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]][Dates]) ), use.names=FALSE, recursive=FALSE)))
startDate = first(xts:::.parseISO8601(Dates))$first.time-.00001
# trim summary slot to not double count, related to bug 831 on R-Forge, and rbind new summary
if( as.POSIXct(attr(Portfolio,'initDate'))>=startDate || length(Portfolio$summary)==0 ){
More information about the Blotter-commits
mailing list