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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 27 21:19:23 CET 2010


Author: braverock
Date: 2010-01-27 21:19:23 +0100 (Wed, 27 Jan 2010)
New Revision: 208

Modified:
   pkg/blotter/R/updateAcct.R
Log:
- add more error handling

Modified: pkg/blotter/R/updateAcct.R
===================================================================
--- pkg/blotter/R/updateAcct.R	2010-01-27 20:18:14 UTC (rev 207)
+++ pkg/blotter/R/updateAcct.R	2010-01-27 20:19:23 UTC (rev 208)
@@ -20,15 +20,15 @@
     
 
     # FUNCTION
-    Account<-get(paste("account",name,sep='.'), envir=.blotter)
     Portfolios = names(Account)[-1]
-    # TODO fix this so that it finds the date range in *any*/all portfolios
-    Portfolio = get(Portfolios[1],envir=.blotter)
+    Portfolio = getPortfolio(Portfolios[1])
+    # TODO FIXME this so that it finds the date range in *any*/all portfolios, not just the first
     if(is.null(Dates)) 
-        Dates = time(Portfolio[[1]]$posPL) # if no date is specified, get all available dates
+        #[[1]] here is the first instrument in the portfolio
+        Dates = time(Portfolio[[1]]$txn ) # if no date is specified, get all available dates
     if(length(Dates)==1){
         # Dates is an xts range, turn it into a list of Dates
-        Dates = time(Portfolio[[1]]$posPL[Dates])
+        Dates = time(Portfolio[[1]]$txn[Dates])
     } 
 
     # For each date, calculate realized and unrealized P&L
@@ -43,7 +43,7 @@
         }
 
         # Now aggregate the portfolio information into the TOTAL slot
-        TxnFees = as.numeric(calcAcctAttr(Account = Account, Attribute = 'Txn.Fees', Date = Dates[d]))
+        TxnFees = as.numeric(calcAcctAttr(Account, Attribute = 'Txn.Fees', Date = Dates[d]))
         RealizedPL = as.numeric(calcAcctAttr(Account, 'Realized.PL', Dates[d]))
         UnrealizedPL = as.numeric(calcAcctAttr(Account, 'Unrealized.PL', Dates[d]))
         TradingPL = as.numeric(calcAcctAttr(Account, 'Trading.PL', Dates[d]))



More information about the Blotter-commits mailing list