[Blotter-commits] r68 - in pkg: . tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 12 03:23:48 CET 2009


Author: edd
Date: 2009-03-12 03:23:48 +0100 (Thu, 12 Mar 2009)
New Revision: 68

Added:
   pkg/tests/
   pkg/tests/txnFee.R
Log:
simple test of transaction cost function versus flat cost

Added: pkg/tests/txnFee.R
===================================================================
--- pkg/tests/txnFee.R	                        (rev 0)
+++ pkg/tests/txnFee.R	2009-03-12 02:23:48 UTC (rev 68)
@@ -0,0 +1,26 @@
+
+library(blotter)
+library(quantmod)
+
+verbose <- FALSE
+data(IBM)                               # data included in package
+symbols <- c("IBM")
+
+## simple portfolio with one transaction
+p1 <- initPortf(symbols=symbols)
+p1 <- addTxn(p1, "IBM", '2007-01-04', 100, 96.5, 0.05*100, verbose)
+p1 <- updatePortf(p1,'2007-01-03','2007-01-10')
+a1 <- initAcct(portfolios="p1")
+a1 <- updateAcct(a1,'2007-01')
+a1 <- updateEndEq(a1,'2007-01')
+
+## (really) simple transaction cost function
+fiveCents <- function(qty, prc) return(0.05*qty)
+p2 <- initPortf(symbols=symbols)
+p2 <- addTxn(p2, "IBM", '2007-01-04', 100, 96.5, fiveCents, verbose)
+p2 <- updatePortf(p2,'2007-01-03','2007-01-10')
+a2 <- initAcct(portfolios="p2")
+a2 <- updateAcct(a2,'2007-01')
+a2 <- updateEndEq(a2,'2007-01')
+
+stopifnot(identical(a1, a2))



More information about the Blotter-commits mailing list