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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 8 16:49:07 CEST 2013


Author: bodanker
Date: 2013-10-08 16:49:07 +0200 (Tue, 08 Oct 2013)
New Revision: 1518

Modified:
   pkg/blotter/R/getBySymbol.R
   pkg/blotter/R/updatePortf.R
Log:
- Patch Dates==NULL handling


Modified: pkg/blotter/R/getBySymbol.R
===================================================================
--- pkg/blotter/R/getBySymbol.R	2013-10-03 20:10:10 UTC (rev 1517)
+++ pkg/blotter/R/getBySymbol.R	2013-10-08 14:49:07 UTC (rev 1518)
@@ -18,7 +18,8 @@
 
     # FUNCTION
     if(all(is.null(Dates)) || all(is.na(Dates))) # if no date is specified, get all available dates
-        Dates = xts:::time.xts(Portfolio$symbols[[1]]$posPL)
+        Dates <- unique(do.call(c,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]])), use.names=FALSE, recursive=FALSE)))
+
     # else  Dates = xts:::time.xts(Portfolio$symbols[[1]]$posPL[Dates])
     if(!is.null(attr(Portfolio,'currency')) & native==FALSE) {
         p.ccy.str<-attr(Portfolio,'currency')

Modified: pkg/blotter/R/updatePortf.R
===================================================================
--- pkg/blotter/R/updatePortf.R	2013-10-03 20:10:10 UTC (rev 1517)
+++ pkg/blotter/R/updatePortf.R	2013-10-08 14:49:07 UTC (rev 1518)
@@ -31,8 +31,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 <- unique(do.call(c,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]][Dates]) ), use.names=FALSE, recursive=FALSE)))
+     if(is.null(Dates)) Dates <- unique(do.call(c,c(lapply(Portfolio$symbols, function(x) index(x[["posPL"]])), 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')



More information about the Blotter-commits mailing list