[Blotter-commits] r50 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 13 05:59:15 CET 2009


Author: peter_carl
Date: 2009-01-13 05:59:15 +0100 (Tue, 13 Jan 2009)
New Revision: 50

Modified:
   pkg/R/calcPortfAttr.R
Log:
- fixed strange timeseries alignment issues, thanks to Jeffrey Ryan


Modified: pkg/R/calcPortfAttr.R
===================================================================
--- pkg/R/calcPortfAttr.R	2009-01-13 04:57:43 UTC (rev 49)
+++ pkg/R/calcPortfAttr.R	2009-01-13 04:59:15 UTC (rev 50)
@@ -16,39 +16,39 @@
         },
         Txn.Fees = {
             table = getBySymbol(Portfolio, 'Txn.Fees', Date)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Txn.Fees'
         },
         Realized.PL = {
             table = getBySymbol(Portfolio, 'Realized.PL', Date)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Realized.PL'
         },
         Unrealized.PL = {
             table = getBySymbol(Portfolio, 'Unrealized.PL', Date)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Unrealized.PL'
         },
         Net.Value = {
             table = getBySymbol(Portfolio, 'Pos.Value', Date)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Net.Value'
         },
         Gross.Value = {
             table = getBySymbol(Portfolio, 'Pos.Value', Date)
-            result = as.xts(t(t(apply(abs(table), FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Gross.Value'
         },
         Long.Value = {
             table = getBySymbol(Portfolio, 'Pos.Value', Date)
             table = apply(table,MARGIN=c(1,2),FUN=max,0)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Long.Value'
         },
         Short.Value = {
             table = getBySymbol(Portfolio, 'Pos.Value', Date)
             table = apply(table,MARGIN=c(1,2),FUN=min,0)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1)))) ## WTF?
+            result = xts(rowSums(abs(table)), index(table))
             colnames(result) = 'Short.Value'
         }
     )



More information about the Blotter-commits mailing list