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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 25 23:04:48 CEST 2011


Author: braverock
Date: 2011-10-25 23:04:47 +0200 (Tue, 25 Oct 2011)
New Revision: 828

Modified:
   pkg/blotter/R/calcPosAvgCost.R
Log:
- fix bug caused by spread trades with negative average cost


Modified: pkg/blotter/R/calcPosAvgCost.R
===================================================================
--- pkg/blotter/R/calcPosAvgCost.R	2011-10-23 18:38:39 UTC (rev 827)
+++ pkg/blotter/R/calcPosAvgCost.R	2011-10-25 21:04:47 UTC (rev 828)
@@ -12,6 +12,7 @@
     if(PosQty == 0)
         PosAvgCost = 0
     else {
+        if(PrevePosAvgCost<0) TxnValue= -1*TxnValue #fix bug with negative average cost 
         # PosAvgCost = abs((PrevPosQty * PrevPosAvgCost * ConMult + TxnValue)/(PosQty*ConMult))
         PosAvgCost = (PrevPosQty * PrevPosAvgCost * ConMult + TxnValue)/(PosQty*ConMult)
     }



More information about the Blotter-commits mailing list