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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 31 00:28:19 CEST 2010


Author: peter_carl
Date: 2010-03-31 00:28:19 +0200 (Wed, 31 Mar 2010)
New Revision: 317

Modified:
   pkg/blotter/R/updatePosPL.R
Log:
- additions will have the same date format as prices


Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-03-29 03:48:27 UTC (rev 316)
+++ pkg/blotter/R/updatePosPL.R	2010-03-30 22:28:19 UTC (rev 317)
@@ -19,7 +19,7 @@
     PosQty = 0
     
     if(is.null(Prices)){
-        Prices=Cl(get(Symbol))
+        Prices=Cl(get(Symbol, envir=as.environment(.GlobalEnv)))
     } 
     
 
@@ -141,7 +141,7 @@
         UnrealizedPL = PosQty*(ClosePrice-(getPosAvgCost(Portfolio=pname, Symbol, CurrentDate)*CcyMult))*ConMult
         RealizedPL = round(GrossTradingPL - UnrealizedPL,2)
 
-        NewPeriod = as.xts(t(c(PosQty, ConMult, CcyMult, PosValue, TxnValue, RealizedPL, UnrealizedPL, GrossTradingPL, TxnFees, NetTradingPL)), order.by=as.POSIXct(CurrentDate)) #, format=tformat
+        NewPeriod = as.xts(t(c(PosQty, ConMult, CcyMult, PosValue, TxnValue, RealizedPL, UnrealizedPL, GrossTradingPL, TxnFees, NetTradingPL)), order.by=CurrentDate) #, format=tformat
         colnames(NewPeriod) = c('Pos.Qty', 'Con.Mult', 'Ccy.Mult', 'Pos.Value', 'Txn.Value',  'Realized.PL', 'Unrealized.PL','Gross.Trading.PL', 'Txn.Fees', 'Net.Trading.PL')
         Portfolio[[Symbol]]$posPL <- rbind(Portfolio[[Symbol]]$posPL, NewPeriod) 
     }



More information about the Blotter-commits mailing list