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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 12 04:27:56 CET 2010


Author: peter_carl
Date: 2010-01-12 04:27:55 +0100 (Tue, 12 Jan 2010)
New Revision: 135

Modified:
   pkg/blotter/R/calcPosAvgCost.R
   pkg/blotter/R/calcPosValue.R
   pkg/blotter/R/calcRealizedPL.R
   pkg/blotter/R/calcTxnAvgCost.R
   pkg/blotter/R/calcTxnValue.R
Log:
- added contract multiplier with a default of 1


Modified: pkg/blotter/R/calcPosAvgCost.R
===================================================================
--- pkg/blotter/R/calcPosAvgCost.R	2010-01-11 22:32:02 UTC (rev 134)
+++ pkg/blotter/R/calcPosAvgCost.R	2010-01-12 03:27:55 UTC (rev 135)
@@ -1,5 +1,5 @@
 `calcPosAvgCost` <-
-function(PrevPosQty, PrevPosAvgCost, TxnValue, PosQty)
+function(PrevPosQty, PrevPosAvgCost, TxnValue, PosQty, ConMult=1)
 { # @author Peter Carl
 
     # DESCRIPTION:
@@ -18,7 +18,7 @@
     if(PosQty == 0)
         PosAvgCost = 0
     else {
-        PosAvgCost = (PrevPosQty*PrevPosAvgCost+TxnValue)/PosQty
+        PosAvgCost = (PrevPosQty * PrevPosAvgCost + TxnValue)/(PosQty * ConMult)
     }
     return(PosAvgCost)
 }

Modified: pkg/blotter/R/calcPosValue.R
===================================================================
--- pkg/blotter/R/calcPosValue.R	2010-01-11 22:32:02 UTC (rev 134)
+++ pkg/blotter/R/calcPosValue.R	2010-01-12 03:27:55 UTC (rev 135)
@@ -1,4 +1,5 @@
-calcPosValue <- function(PosQty,ClosePrice) {
-  PosValue <- PosQty * ClosePrice
+`calcPosValue` <-
+function(PosQty, ClosePrice, ConMult=1) {
+  PosValue <- PosQty * ClosePrice * ConMult
   return(PosValue)
 }

Modified: pkg/blotter/R/calcRealizedPL.R
===================================================================
--- pkg/blotter/R/calcRealizedPL.R	2010-01-11 22:32:02 UTC (rev 134)
+++ pkg/blotter/R/calcRealizedPL.R	2010-01-12 03:27:55 UTC (rev 135)
@@ -1,5 +1,5 @@
 `calcRealizedPL` <-
-function(TxnQty, TxnAvgCost, PrevPosAvgCost, PosQty, PrevPosQty)
+function(TxnQty, TxnAvgCost, PrevPosAvgCost, PosQty, PrevPosQty, ConMult=1)
 { # @author Peter Carl
 
     # DESCRIPTION
@@ -25,7 +25,7 @@
     # if prev position is positive and position is smaller,
     # then calc RealizedPL
     else
-        RealizedPL = TxnQty * (PrevPosAvgCost - TxnAvgCost)
+        RealizedPL = TxnQty * ConMult * (PrevPosAvgCost - TxnAvgCost)
 
     return(RealizedPL)
 }

Modified: pkg/blotter/R/calcTxnAvgCost.R
===================================================================
--- pkg/blotter/R/calcTxnAvgCost.R	2010-01-11 22:32:02 UTC (rev 134)
+++ pkg/blotter/R/calcTxnAvgCost.R	2010-01-12 03:27:55 UTC (rev 135)
@@ -1,5 +1,5 @@
 `calcTxnAvgCost` <-
-function(TxnValue, TxnQty)
+function(TxnValue, TxnQty, ConMult=1)
 { # @author Peter Carl
 
     # DESCRIPTION:
@@ -14,7 +14,7 @@
     # Outputs
     # TxnAvgCost: unit normalized (per share) cost implied by the transaction
 
-    TxnAvgCost = TxnValue/TxnQty
+    TxnAvgCost = TxnValue/(TxnQty*ConMult)
     return(TxnAvgCost)
 }
 

Modified: pkg/blotter/R/calcTxnValue.R
===================================================================
--- pkg/blotter/R/calcTxnValue.R	2010-01-11 22:32:02 UTC (rev 134)
+++ pkg/blotter/R/calcTxnValue.R	2010-01-12 03:27:55 UTC (rev 135)
@@ -1,5 +1,5 @@
 `calcTxnValue` <-
-function(TxnQty, TxnPrice, TxnFees)
+function(TxnQty, TxnPrice, TxnFees, ConMult=1)
 { # @author Peter Carl
 
     # DESCRIPTION:
@@ -14,7 +14,7 @@
     # Outputs
     # TxnValue: total dollar value of the transaction, including fees
 
-    TxnValue = TxnQty * TxnPrice - TxnFees
+    TxnValue = TxnQty * TxnPrice * ConMult - TxnFees
     return(TxnValue)
 }
 



More information about the Blotter-commits mailing list