[Blotter-commits] r149 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 14 14:54:23 CET 2010
Author: braverock
Date: 2010-01-14 14:54:19 +0100 (Thu, 14 Jan 2010)
New Revision: 149
Modified:
pkg/blotter/R/addTxn.R
Log:
- add contract multiplier
Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R 2010-01-14 13:51:38 UTC (rev 148)
+++ pkg/blotter/R/addTxn.R 2010-01-14 13:54:19 UTC (rev 149)
@@ -7,11 +7,13 @@
#' @param TxnDate transaction date as ISO 8106, e.g., '2008-09-01'
#' @param TxnQty total units (such as shares) transacted. Positive values indicate a 'buy'; negative values indicate a 'sell'
#' @param TxnPrice price at which the transaction was done
-#' @param TxnFees fees associated with the transaction, e.g. commissions., See Details
-#' @param verbose
+#' @param \dots any other passthrough parameters
+#' @param TxnFees fees associated with the transaction, e.g. commissions., See Details
+#' @param ConMult
+#' @param verbose TRUE/FALSE
#' @author Peter Carl
#' @export
-addTxn <- function(Portfolio, Symbol, TxnDate, TxnQty, TxnPrice, TxnFees=0, verbose=TRUE)
+addTxn <- function(Portfolio, Symbol, TxnDate, TxnQty, TxnPrice, ..., TxnFees=0, ConMult=1, verbose=TRUE)
{ # @author Peter Carl
pname<-Portfolio
Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
@@ -24,7 +26,7 @@
# Compute transaction fees if a function was supplied
txnfees <- ifelse( is.function(TxnFees), TxnFees(TxnQty, TxnPrice), TxnFees)
# Calculate the value and average cost of the transaction
- TxnValue = calcTxnValue(TxnQty, TxnPrice, txnfees)
+ TxnValue = calcTxnValue(TxnQty, TxnPrice, txnfees, ConMult)
TxnAvgCost = calcTxnAvgCost(TxnValue, TxnQty)
# Calculate the change in position
@@ -39,7 +41,7 @@
RealizedPL = calcRealizedPL(TxnQty, TxnAvgCost, PrevPosAvgCost, PosQty, PrevPosQty)
# Store the transaction and calculations
- NewTxn = xts(t(c(TxnQty, TxnPrice, txnfees, TxnValue, TxnAvgCost, PosQty, PosAvgCost, RealizedPL)), order.by=as.POSIXct(TxnDate))
+ NewTxn = xts(t(c(TxnQty, TxnPrice, txnfees, TxnValue, TxnAvgCost, PosQty, PosAvgCost, RealizedPL, ConMult)), order.by=as.POSIXct(TxnDate))
#colnames(NewTxn) = c('Txn.Qty', 'Txn.Price', 'Txn.Fees', 'Txn.Value', 'Txn.Avg.Cost', 'Pos.Qty', 'Pos.Avg.Cost', 'Realized.PL')
Portfolio[[Symbol]]$txn<-rbind(Portfolio[[Symbol]]$txn, NewTxn)
More information about the Blotter-commits
mailing list