[Blotter-commits] r56 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 23 05:44:07 CET 2009


Author: peter_carl
Date: 2009-01-23 05:44:07 +0100 (Fri, 23 Jan 2009)
New Revision: 56

Modified:
   pkg/R/calcPortfAttr.R
Log:
- fixed order.by to Date


Modified: pkg/R/calcPortfAttr.R
===================================================================
--- pkg/R/calcPortfAttr.R	2009-01-22 12:53:08 UTC (rev 55)
+++ pkg/R/calcPortfAttr.R	2009-01-23 04:44:07 UTC (rev 56)
@@ -11,44 +11,44 @@
     switch(Attribute,
         Trading.PL = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Trading.PL', Date = Date, Symbols = Symbols)
-            result = as.xts(t(t(apply(table, FUN='sum', MARGIN=1))))
+            result = xts(apply(table, FUN='sum', MARGIN=1), Date)
             colnames(result) = 'Trading.PL'
         },
         Txn.Fees = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Txn.Fees', Date = Date, Symbols = Symbols)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Txn.Fees'
         },
         Realized.PL = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Realized.PL', Date = Date, Symbols = Symbols)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Realized.PL'
         },
         Unrealized.PL = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Unrealized.PL', Date = Date, Symbols = Symbols)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Unrealized.PL'
         },
         Net.Value = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Date = Date, Symbols = Symbols)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Net.Value'
         },
         Gross.Value = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Date = Date, Symbols = Symbols)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Gross.Value'
         },
         Long.Value = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Date = Date, Symbols = Symbols)
             table = apply(table,MARGIN=c(1,2),FUN=max,0)
-            result = xts(rowSums(abs(table)), index(table))
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Long.Value'
         },
         Short.Value = {
             table = getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Date = Date, Symbols = Symbols)
-            table = apply(table,MARGIN=c(1,2),FUN=min,0)
-            result = xts(rowSums(abs(table)), index(table))
+            table = apply(table,MARGIN=c(1,2),FUN=min,0) # comes out a matrix
+            result = xts(rowSums(abs(table)), Date)
             colnames(result) = 'Short.Value'
         }
     )



More information about the Blotter-commits mailing list