[Blotter-commits] r1644 - in pkg/blotter: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Nov 1 21:32:11 CET 2014
Author: braverock
Date: 2014-11-01 21:32:11 +0100 (Sat, 01 Nov 2014)
New Revision: 1644
Modified:
pkg/blotter/DESCRIPTION
pkg/blotter/R/addTxn.R
pkg/blotter/man/addTxn.Rd
pkg/blotter/man/pennyPerShare.Rd
Log:
- resolves R-Forge feature request 5968 by adding arguments to TxnFees fn
Modified: pkg/blotter/DESCRIPTION
===================================================================
--- pkg/blotter/DESCRIPTION 2014-10-27 21:06:03 UTC (rev 1643)
+++ pkg/blotter/DESCRIPTION 2014-11-01 20:32:11 UTC (rev 1644)
@@ -2,7 +2,7 @@
Type: Package
Title: Tools for transaction-oriented trading systems
development.
-Version: 0.9.1643
+Version: 0.9.1644
Date: $Date$
Author: Peter Carl, Brian G. Peterson
Maintainer: Brian G. Peterson <brian at braverock.com>
Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R 2014-10-27 21:06:03 UTC (rev 1643)
+++ pkg/blotter/R/addTxn.R 2014-11-01 20:32:11 UTC (rev 1644)
@@ -34,6 +34,12 @@
#' have "TxnQty" and "TxnPrice" columns, while the "TxnFees"
#' column is optional.
#'
+#' If \code{TxnFees} is the name of a function, the function
+#' will be called with \code{TxnFees(TxnQty, TxnPrice, Symbol)}
+#' so a user supplied fee function must at the very least take
+#' dots to avoid an error. We have chosen not to use named arguments
+#' to reduce issues from user-supplied fee functions.
+#'
#' @param Portfolio A portfolio name that points to a portfolio object structured with \code{initPortf()}
#' @param Symbol An instrument identifier for a symbol included in the portfolio, e.g., "IBM"
#' @param TxnDate Transaction date as ISO 8601, e.g., '2008-09-01' or '2010-01-05 09:54:23.12345'
@@ -98,8 +104,12 @@
if (!inherits(TF,"try-error")) TxnFees<-TF
}
# Compute transaction fees if a function was supplied
- if (is.function(TxnFees)) txnfees <- TxnFees(TxnQty, TxnPrice) else txnfees<- as.numeric(TxnFees)
-
+ if (is.function(TxnFees)) {
+ txnfees <- TxnFees(TxnQty, TxnPrice, Symbol)
+ } else {
+ txnfees<- as.numeric(TxnFees)
+ }
+
if(is.null(txnfees) | is.na(txnfees)) txnfees = 0
if(txnfees>0 && !isTRUE(allowRebates)) stop('Positive Transaction Fees should only be used in the case of broker/exchange rebates for TxnFees ',TxnFees,'. See Documentation.')
@@ -141,8 +151,9 @@
#' Example TxnFee cost function
#' @param TxnQty total units (such as shares or contracts) transacted. Positive values indicate a 'buy'; negative values indicate a 'sell'
#' This is an example intended to demonstrate how a cost function could be used in place of a flat numeric fee.
+#' @param \dots any other passthrough parameters
#' @export
-pennyPerShare <- function(TxnQty) {
+pennyPerShare <- function(TxnQty, ...) {
return(abs(TxnQty) * -0.01)
}
Modified: pkg/blotter/man/addTxn.Rd
===================================================================
--- pkg/blotter/man/addTxn.Rd 2014-10-27 21:06:03 UTC (rev 1643)
+++ pkg/blotter/man/addTxn.Rd 2014-11-01 20:32:11 UTC (rev 1644)
@@ -70,6 +70,12 @@
adding them one at a time. The \code{TxnData} object must
have "TxnQty" and "TxnPrice" columns, while the "TxnFees"
column is optional.
+
+If \code{TxnFees} is the name of a function, the function
+will be called with \code{TxnFees(TxnQty, TxnPrice, Symbol)}
+so a user supplied fee function must at the very least take
+dots to avoid an error. We have chosen not to use named arguments
+to reduce issues from user-supplied fee functions.
}
\note{
The addTxn function will eventually also handle other transaction types,
Modified: pkg/blotter/man/pennyPerShare.Rd
===================================================================
--- pkg/blotter/man/pennyPerShare.Rd 2014-10-27 21:06:03 UTC (rev 1643)
+++ pkg/blotter/man/pennyPerShare.Rd 2014-11-01 20:32:11 UTC (rev 1644)
@@ -3,11 +3,13 @@
\alias{pennyPerShare}
\title{Example TxnFee cost function}
\usage{
-pennyPerShare(TxnQty)
+pennyPerShare(TxnQty, ...)
}
\arguments{
\item{TxnQty}{total units (such as shares or contracts) transacted. Positive values indicate a 'buy'; negative values indicate a 'sell'
This is an example intended to demonstrate how a cost function could be used in place of a flat numeric fee.}
+
+\item{\dots}{any other passthrough parameters}
}
\description{
Example TxnFee cost function
More information about the Blotter-commits
mailing list