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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 25 19:13:21 CET 2010


Author: peter_carl
Date: 2010-03-25 19:13:21 +0100 (Thu, 25 Mar 2010)
New Revision: 301

Modified:
   pkg/blotter/R/updatePosPL.R
Log:
- fixed UnrealizedPL calc


Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-03-24 12:32:00 UTC (rev 300)
+++ pkg/blotter/R/updatePosPL.R	2010-03-25 18:13:21 UTC (rev 301)
@@ -91,7 +91,7 @@
         TradingPL = calcTradingPL(PosValue, PrevPosValue, TxnValue)
         RealizedPL = getRealizedPL(pname, Symbol, CurrentSpan)
         #$unrealized_gl    = $end_return['calc_position'] * ($end_return['last_price'] - $end_return['average_cost']);
-        UnrealizedPL = PosValue-getPosAvgCost(Portfolio=pname, Symbol, CurrentDate) #TODO put this into calcUnrealizedPL
+        UnrealizedPL = PosQty*(ClosePrice-getPosAvgCost(Portfolio=pname, Symbol, CurrentDate))*ConMult
 
         NewPeriod = as.xts(t(c(PosQty, ConMult, CcyMult, PosValue, TxnValue, TxnFees, RealizedPL, UnrealizedPL, TradingPL)), order.by=as.POSIXct(CurrentDate)) #, format=tformat
         colnames(NewPeriod) = c('Pos.Qty', 'Con.Mult', 'Ccy.Mult', 'Pos.Value', 'Txn.Value', 'Txn.Fees', 'Realized.PL', 'Unrealized.PL', 'Trading.PL')



More information about the Blotter-commits mailing list