[Blotter-commits] r8 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 16 04:06:39 CET 2008


Author: peter_carl
Date: 2008-12-16 04:06:37 +0100 (Tue, 16 Dec 2008)
New Revision: 8

Added:
   pkg/R/getTxnAvgCost.R
Log:
- Initial code commit


Added: pkg/R/getTxnAvgCost.R
===================================================================
--- pkg/R/getTxnAvgCost.R	                        (rev 0)
+++ pkg/R/getTxnAvgCost.R	2008-12-16 03:06:37 UTC (rev 8)
@@ -0,0 +1,32 @@
+`getTxnAvgCost` <-
+function(Portfolio, Symbol, Date)
+{ # @author Peter Carl
+
+    # DESCRIPTION:
+    # Gets the value of that period's transactions and returns the sum 
+
+    # Inputs
+    # Portfolio: a portfolio object containing transactions
+    # Symbol: an instrument identifier for a symbol included in the portfolio
+    # Date: timestamp as of which to have the most recent position
+
+    # Outputs
+    # Numeric value of the most recent position.
+
+    # FUNCTION
+    TxnData = Portfolio[[Symbol]]$txn
+    TxnValue = sum(TxnData[Date,'Txn.Avg.Cost'])
+    return(TxnValue)
+}
+
+###############################################################################
+# Blotter: Tools for transaction-oriented trading systems development
+# for R (see http://r-project.org/) 
+# Copyright (c) 2008 Peter Carl and Brian G. Peterson
+#
+# This library is distributed under the terms of the GNU Public License (GPL)
+# for full details see the file COPYING
+#
+# $Id:  $
+#
+###############################################################################



More information about the Blotter-commits mailing list