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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 17 23:03:21 CET 2010


Author: braverock
Date: 2010-03-17 23:03:21 +0100 (Wed, 17 Mar 2010)
New Revision: 295

Modified:
   pkg/blotter/R/updatePosPL.R
Log:
- fix unrealized GL calculation

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-03-17 15:22:31 UTC (rev 294)
+++ pkg/blotter/R/updatePosPL.R	2010-03-17 22:03:21 UTC (rev 295)
@@ -90,7 +90,8 @@
         PrevPosValue = calcPosValue(PrevPosQty, PrevClosePrice, ConMult) ### @TODO: PrevConMult?
         TradingPL = calcTradingPL(PosValue, PrevPosValue, TxnValue)
         RealizedPL = getRealizedPL(pname, Symbol, CurrentSpan)
-        UnrealizedPL = TradingPL - RealizedPL # TODO: calcUnrealizedPL(TradingPL, RealizedPL)
+        #$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
 
         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