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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 30 18:52:08 CEST 2010


Author: peter_carl
Date: 2010-06-30 18:52:07 +0200 (Wed, 30 Jun 2010)
New Revision: 348

Modified:
   pkg/blotter/R/getBySymbol.R
Log:
- fixed to get the summary by portfolio currency


Modified: pkg/blotter/R/getBySymbol.R
===================================================================
--- pkg/blotter/R/getBySymbol.R	2010-06-29 01:18:19 UTC (rev 347)
+++ pkg/blotter/R/getBySymbol.R	2010-06-30 16:52:07 UTC (rev 348)
@@ -1,4 +1,4 @@
-.getBySymbol <- function(Portfolio, Attribute, Dates=NULL, Symbols = NULL)
+.getBySymbol <- function(Portfolio, Attribute, Dates=NULL, Symbols=NULL, Local=FALSE)
 { # @author Peter Carl
 
     # DESCRIPTION:
@@ -16,9 +16,17 @@
     # regular xts object of values by symbol
 
     # FUNCTION
-    if(is.null(Dates)) # if no date is specified, get all available dates
+    if(is.null(Dates) | is.na(Dates)) # if no date is specified, get all available dates
         Dates = time(Portfolio[[1]]$posPL)
     # else  Dates = time(Portfolio[[1]]$posPL[Dates])
+    if(!is.null(attr(Portfolio,'currency')) & Local==FALSE) {
+        p.ccy.str<-attr(Portfolio,'currency')
+        namePosPL = paste("posPL", p.ccy.str, sep=".")
+    } else {
+        print("Returning position values in Local values")
+        namePosPL = "posPL"
+        # Alternatively, we could just use posPL without ccy extension
+    }
 
     table = NULL 
       ## Need a reference time index
@@ -28,7 +36,7 @@
         symbols = Symbols
     
     for (symbol in symbols) {
-        tmp_col = Portfolio[[symbol]]$posPL[Dates,Attribute,drop=FALSE]
+        tmp_col = Portfolio[[symbol]][[namePosPL]][Dates,Attribute,drop=FALSE]
         if(is.null(table)) table = tmp_col
         else table = merge(table, tmp_col)
     }



More information about the Blotter-commits mailing list